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