Several ways to start Task Manager with C # code

Source: Internet
Author: User

Original: C # code several ways to start Task Manager

1. Direct start

     ProcessStartInfo info = new ProcessStartInfo ();             Info. FileName = Path.Combine (environment.getenvironmentvariable ("windir"), "Explorer.exe");            Process.Start (info). WaitForExit ();

2. Similar 1

            ProcessStartInfo info = new ProcessStartInfo ();            Info. CreateNoWindow = true;            Info. UseShellExecute = true;            Info. WindowStyle = Processwindowstyle.hidden;            Info. FileName = Path.Combine (environment.getenvironmentvariable ("windir"), "Explorer.exe");            Process.Start (info);

 3.shell External methods

   private void Button1_Click (object sender, EventArgs e)        {            ShellExecute (IntPtr.Zero, NULL, "Explorer.exe", NULL, NULL, showcommands.sw_show);        }        Public enum Showcommands:int        {            sw_hide = 0,            sw_shownormal = 1,            sw_normal = 1,            sw_showminimized = 2,< c10/>sw_showmaximized = 3,            sw_maximize = 3,            sw_shownoactivate = 4,            sw_show = 5,            sw_minimize = 6,
   sw_showminnoactive = 7,            Sw_showna = 8,            Sw_restore = 9,            Sw_showdefault = ten,            sw_forceminimize = 11,            Sw_max = one        }        [DllImport ("Shell32.dll")]        static extern IntPtr ShellExecute (            IntPtr hwnd,            string lpoperation,            string lpfile,            string Lpparameters,            string lpdirectory,            showcommands nshowcmd);

4.shell Window General

   Process.Start (Path.Combine (environment.getenvironmentvariable ("windir"), "Explorer.exe"));             Shellwindows  win= New Shdocvw.shellwindows ();

5.cmd Command Execution Explorer.exe

System.Diagnostics.Process Process = new System.Diagnostics.Process ();            System.Diagnostics.ProcessStartInfo startinfo = new System.Diagnostics.ProcessStartInfo ();            Startinfo.windowstyle = System.Diagnostics.ProcessWindowStyle.Hidden;            Startinfo.filename = "cmd.exe";             Process. StartInfo = StartInfo;            Process. Startinfo.redirectstandardinput = true;            Process. Startinfo.redirectstandardoutput = true;            Process. Startinfo.useshellexecute = false;            Process. Start ();            Process. Standardinput.writeline (environment.getenvironmentvariable ("windir") + "\\explorer.exe");            Process. Standardinput.flush ();            Process. Standardinput.close ();            Process. WaitForExit ();

Thank everyone who read this article, hope to help you.

Several ways to start Task Manager with C # code

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.