|
System.Diagnostics.Process.Start(); What can be done? It mainly has the following functions: 1. Open a link URL (pop-up window). 2. Locate and open a file directory. 3. Open a special folder on the system, such as "Control Panel", etc. So how does it implement these functions? Before we talk about applications, let's take a look at the construction method of Process.Star().
name | illustrate | | Process.Start () | Start (or reuse) this Process componentStartInfoproperty specifies the process resource and associates it with that component. | | Process.Start (ProcessStartInfo) | Start a process resource specified by a parameter that contains process startup information (for example, the file name of the process to start) and associate that resource with a new Process component. | | Process.Start (String) | By designationThe name of the document or application fileto start a process resource and associate the resource with a new Process component. | | Process.Start (String, String) | By designationThe name of the application and a set of command-line argumentsto start a process resource and associate that resource with a new Process component. | | Process.Start (String, String, SecureString, String) | By designationThe app's name, username, password, and domainto start a process resource and associate that resource with a new Process component. | | Process.Start (String, String, String, SecureString, String) | By designationThe name of the application and a set of command-line arguments, username, password, and domainto start a process resource and associate that resource with a new Process component. |
(1) publicboolStart ()
System.Diagnostics.Process process = new System.Diagnostics.Process(); process. StartInfo.FileName = "iexplore.exe"; Internet Explorer, can be replaced
process. StartInfo.Arguments = "http://www.baidu.com"; process. Start();
(2) publicstaticProcessStart (ProcessStartInfostartInfo)
System.Diagnostics.ProcessStartInfo processStartInfo = new System.Diagnostics.ProcessStartInfo(); processStartInfo.FileName = "explorer.exe"; Explorer
processStartInfo.Arguments = @"D:\"; System.Diagnostics.Process.Start(processStartInfo);
(3) publicstaticProcessStart (stringfileName) System.Diagnostics.Process.Start(@"D:\Program Files\Tencent\QQ\Bin\QQ.exe"); Open file call directly
(4) Process.Start (StringfileName, Stringarguments) System.Diagnostics.Process.Start("explorer.exe", "D:\\Readme.txt"); Open the file directly Readme.txt
The above is an example of how to open a website with process.start(), and now let's talk about how to use processs.star() to locate a file. This localization method is similar to the search target on the shortcut ://explorer /select, "D:\Program Files\Tencent\QQ\Bin\QQ.exe"
String path = @"D:\Program Files\Tencent\QQ\Bin\QQ.exe";
System.Diagnostics.Process.Start("explorer.exe", "/select," +path); Locate and open the D:\Program Files\Tencent\QQ\Bin file directory and select QQ.exe
Note: There is also a comma (,) after /select.
Next, let's talk about opening some system-specific files by calling rundll32.exe, and briefly introduce the functions and functions of the rundll32.exe. As the name suggests, rundll32 is "executing 32-bit DLL files", that is, internal functions in the execution DLL file, which can call the Windows 32-bit dynamic link library in the form of a command line. Similarly, rundll.exe is to "execute a 16-bit dll file", calling a 16-bit dynamic link library. We perform some functions by executing instructions rundll32.exe. For example: System.Diagnostics.Process.Start("rundll32.exe","user.exe,restartwindows"); System restart command
rundll32 command encyclopedia
Command line :rundll32.exe user.exe, restartwindows Function: System reboot
Command line :rundll32.exe user.exe, exitwindows Function: Shut down the system
Command line: rundll32.exe shell32.dll, Control_RunDLL Function: Display control panel
Command line: rundll32.exe shell32.dll,Control_RunDLL access.cpl,,1 Function: Displays the "Control Panel - Accessibility Options - Keyboard" option window
Command line: rundll32.exe shell32.dll, Control_RunDLL access.cpl, , 2 Function: Displays the "Control Panel - Accessibility Options - Sound" option window
Command line: rundll32.exe shell32.dll, Control_RunDLL access.cpl, 3 Function: Displays the "Control Panel - Accessibility Options - Display" option window
Command line: rundll32.exe shell32.dll, Control_RunDLL access.cpl, 4 Function: Displays the "Control Panel - Accessibility Options - Mouse" option window
Command line: rundll32.exe shell32.dll, Control_RunDLL access.cpl, 5 Function: Displays the "Control Panel - Accessibility Options - Traditional" option window
Command line: rundll32.exe shell32.dll,Control_RunDLL sysdm.cpl @1 Function: Run the Control Panel - Add New Hardware wizard.
Command line: rundll32.exe shell32.dll,SHHelpShortcuts_RunDLL AddPrinter Function: Execute the Control Panel - Add New Printer wizard.
Command line: rundll32.exe shell32.dll, Control_RunDLL appwiz.cpl, , 1 Function: Displays the Control Panel - Add/Remove Programs panel.
Command line: rundll32.exe shell32.dll, Control_RunDLL appwiz.cpl, , 1
Functions: Displays the "Control Panel - Add/Remove Programs - Install/Uninstall" panel.
Command line: rundll32.exe shell32.dll, Control_RunDLL appwiz.cpl, , 2 Function: Displays the "Control Panel - Add/Remove Programs - Install Windows" panel.
Command line: rundll32.exe shell32.dll,Control_RunDLL appwiz.cpl,,3 Function: Displays the "Control Panel - Add/Remove Programs - Startup Disk" panel.
Command line: rundll32.exe syncui.dll, Briefcase_Create Function: Create a new "My Briefcase" on your desktop.
Command line: rundll32.exe diskcopy.dll, DiskCopyRunDll Function: Displays the copy floppy disk window
Command line: rundll32.exe apwiz.cpl, NewLinkHere %1 Function: Displays the "Create Shortcut" dialog box, and the position of the created shortcut is determined by the %1 parameter.
Command line: rundll32.exe shell32.dll,Control_RunDLL timedate.cpl,,0 Function: Displays the Date & Time option window.
Command line: rundll32.exe shell32.dll, Control_RunDLL timedate.cpl, , 1 Function: Displays the Time Zone option window.
Command line: rundll32.exe rnaui.dll,RnaDial [name of a dial-up connection] Function: Displays the dialing window for a dial-up connection. If you have already dialed a connection, a window displays the current connection status.
Command line: rundll32.exe rnaui.dll, RnaWizard Function: Displays a window for the New Dial-up Connection wizard.
Command line: rundll32.exe shell32.dll,Control_RunDLL desk.cpl,,0 Function: Displays the "Show Properties - Background" option window.
Command line: rundll32.exe shell32.dll, Control_RunDLL desk.cpl, , 1 Function: Displays the "Display Properties - Screen Protection" option window.
Command line: rundll32.exe shell32.dll,Control_RunDLL desk.cpl,,2 Function: Displays the "Display Properties - Appearance" option window.
Command line: rundll32.exe shell32.dll, Control_RunDLL desk.cpl, 3 Function: Displays the Show Properties - Properties option window.
Command line: rundll32.exe shell32.dll, SHHelpShortcuts_RunDLL FontsFolder Function: Displays the Windows Fonts folder.
Command line: rundll32.exe shell32.dll,Control_RunDLL main.cpl @3 Function: Also displays the Windows Fonts folder.
Command line: rundll32.exe shell32.dll, SHFormatDrive Function: Displays the Format Floppy Disk dialog box.
Command line: rundll32.exe shell32.dll,Control_RunDLL joy.cpl,,0 Function: Displays the "Control Panel - Game Controllers - General" options window.
Command line: rundll32.exe shell32.dll,Control_RunDLL joy.cpl,,1 Function: Displays the "Control Panel - Game Controller - Advanced" option window.
Command Line: rundll32.exe mshtml.dll, PrintHTML (HTML document) Function: Print HTML documents.
Command line: rundll32.exe shell32.dll, Control_RunDLL mlcfg32.cpl Function: Displays the Microsoft Exchange General Options window.
Command line: rundll32.exe shell32.dll,Control_RunDLL main.cpl @0 Function: Displays the Control Panel - Mouse option.
Command line: rundll32.exe shell32.dll,Control_RunDLL main.cpl @1 Function: Displays the "Control Panel - Keyboard Properties - Speed" option window.
Command line: rundll32.exe shell32.dll,Control_RunDLL main.cpl @1,,1 Function: Displays the "Control Panel - Keyboard Properties - Language" option window.
Command line: rundll32.exe shell32.dll,Control_RunDLL main.cpl @2 Function: Displays the Windows Printer folder.
Command line: rundll32.exe shell32.dll,Control_RunDLL main.cpl @4 Function: Displays the "Control Panel - Input Method Properties - Input Method" option window.
Command line: rundll32.exe shell32.dll, Control_RunDLL modem.cpl, add Function: Execute the Add New Modem wizard.
Command line: rundll32.exe shell32.dll,Control_RunDLL mmsys.cpl,,0 Function: Displays the "Control Panel - Multimedia Properties - Audio" property page.
Command line: rundll32.exe shell32.dll,Control_RunDLL mmsys.cpl,,1 Function: Displays the "Control Panel - Multimedia Properties - Video" property page.
Command line: rundll32.exe shell32.dll, Control_RunDLL mmsys.cpl, , 2 Function: Displays the "Control Panel - Multimedia Properties - MIDI" property page.
Command line: rundll32.exe shell32.dll, Control_RunDLL mmsys.cpl, 3 Function: Displays the "Control Panel - Multimedia Properties - CD Music" property page.
Command line: rundll32.exe shell32.dll, Control_RunDLL mmsys.cpl, 4 Function: Displays the Control Panel - Multimedia Properties - Devices property page.
Command line: rundll32.exe shell32.dll,Control_RunDLL mmsys.cpl @1 Function: Displays the "Control Panel - Sound" option window.
Command line: rundll32.exe shell32.dll, Control_RunDLL netcpl.cpl Function: Displays the Control Panel - Network options window.
Command line: rundll32.exe shell32.dll, Control_RunDLL odbccp32.cpl Function: Displays the ODBC32 data management options window.
Command line: rundll32.exe shell32.dll,OpenAs_RunDLL {drive:/path/filename} Function: Displays the Open By dialog box for a specified file (drive:/path/filename).
Command line: rundll32.exe shell32.dll, Control_RunDLL password.cpl Function: Displays the "Control Panel - Password" option window.
Command line: rundll32.exe shell32.dll, Control_RunDLL powercfg.cpl Function: Displays the "Control Panel - Power Management Properties" option window.
Command line: rundll32.exe shell32.dll,SHHelpShortcuts_RunDLL PrintersFolder Function: Displays the Windows Printer folder. (Same rundll32.exe shell32.dll, Control_RunDLL main.cpl @2)
Command line: rundll32.exe shell32.dll,Control_RunDLL intl.cpl,,0 Function: Displays the "Control Panel - Locale Properties - Locale" option window.
Command line: rundll32.exe shell32.dll, Control_RunDLL intl.cpl, , 1 Function: Displays the "Control Panel - Locale Properties - Numbers" option window.
Command line: rundll32.exe shell32.dll, Control_RunDLL intl.cpl, , 2 Function: Displays the "Control Panel - Locale Properties - Currency" option window.
Command line: rundll32.exe shell32.dll, Control_RunDLL intl.cpl, 3 Function: Displays the "Control Panel - Locale Properties - Time" option window.
Command line: rundll32.exe shell32.dll, Control_RunDLL intl.cpl, 4 Function: Displays the "Control Panel - Locale Properties - Date" option window.
command line: rundll32.exe desk.cpl,InstallScreenSaver [screen protector filename] Function: Set the specified screen protection file as a Windows screensaver and display the screen protection properties window.
Command line: rundll32.exe shell32.dll,Control_RunDLL sysdm.cpl,,0 Function: Displays the "Control Panel - System Properties - Traditional" property window.
Command line: rundll32.exe shell32.dll,Control_RunDLL sysdm.cpl,,1 Function: Displays the "Control Panel - System Properties - Device Manager" property window.
Command line: rundll32.exe shell32.dll, Control_RunDLL sysdm.cpl, 2 Function: Displays the "Control Panel - System Properties - Hardware Configuration Files" property window.
Command line: rundll32.exe shell32.dll, Control_RunDLL sysdm.cpl, 3 Function: Displays the "Control Panel - System Properties - Performance" property window.
Command line: rundll32.exe shell32.dll, Control_RunDLL telephon.cpl Function: Displays the Dial Properties option window
Command line: rundll32.exe shell32.dll, Control_RunDLL themes.cpl Function: Displays the Desktop Theme options panel
Command line: rundll32.exe shell32.dll, Control_RunDLL firewall.cpl Function: Displays the Windows Firewall panel
Command line: rundll32.exe shell32.dll, Control_RunDLL NetSetup.cpl, @0, WNSW Function: Displays the "Wireless Network Settings" panel More commands can be downloaded here:http://download.csdn.net/detail/czw2010/4530206
System.Diagnostics.Process.Start("notepad.exe"); -- Open Notepad
System.Diagnostics.Process.Start("calc.exe "); -- Open the calculator System.Diagnostics.Process.Start("regedit.exe "); -- Open the registry
System.Diagnostics.Process.Start("mspaint.exe "); -- Open the drawing board System.Diagnostics.Process.Start("write.exe "); -- Open WordPad
System.Diagnostics.Process.Start("mplayer2.exe "); --Open the player
System.Diagnostics.Process.Start("taskmgr.exe "); --Open Task Manager System.Diagnostics.Process.Start("eventvwr.exe "); --Open the event viewer System.Diagnostics.Process.Start("winmsd.exe "); --Open System Information System.Diagnostics.Process.Start("winver.exe "); --Open Windows version information System.Diagnostics.Process.Start("mailto: "+ address); -- Send an email
shutdown.exe: Parameters: -s shutdown -r restart -f force -t time -a cancel shutdown -l logout -i display user interface
System.Diagnostics.Process.Start("shutdown.exe","-r"); -- Shut down and restart your computer System.Diagnostics.Process.Start("shutdown.exe","-s -f"); -- Shut down the computer System.Diagnostics.Process.Start("shutdown.exe","-s -f 30"); -- Shut down the computer after 30s System.Diagnostics.Process.Start("shutdown.exe","-l"); --Log out of the computer System.Diagnostics.Process.Start("shutdown.exe","-a"); --Undo shut down the computer
SpecialFolderEnumerate members:
Member Names | illustrate | | ApplicationData | directory, which serves as a public repository for application-specific data for the currently roaming user. Roaming users work on multiple computers on a network. The roaming user's profile is saved on a web server and is loaded on a system when the user logs in. | | CommonApplicationData | directory, which serves as a public repository for application-specific data used by all users. | | CommonProgramFiles | A directory of components used to be shared between applications. | | Cookies | A directory used as a public repository for Internet cookies. | | Desktop | Logical desktops, not physical file system locations. | | DesktopDirectory | A directory used to physically store file objects on the desktop. This directory should not be confused with the desktop folder itself, which is a virtual folder. | | Favorites | A directory that serves as a public repository for user favorite items. | | History | A directory that serves as a public repository for Internet history items. | | InternetCache | A directory used as a public repository for temporary files on the Internet. | | LocalApplicationData | Directory, which serves as a public repository for application-specific data currently used by non-roaming users. | | MyComputer | My Computer folder.Note | Since no path is defined for the My Computer folder, the MyComputer constant will always generate an empty string (""). |
| | MyDocuments | My Computer folder. | | MyMusic | "My Music" folder. | | MyPictures | "My Pictures" folder. | | Personal | A directory used as a public repository for documents. | | ProgramFiles | Program files directory. | | Programs | Contains a directory of user program groups. | | Recent | A table of contents containing the user's most recently used documents. | | SendTo | A table of contents that contains the Send menu item. | | StartMenu | A table of contents that contains Start menu items. | | Startup | The directory corresponding to the user's Startup group. These programs are launched whenever a user logs in, boots Windows NT or later, or starts Windows 98. | | System | "System" directory. | | Templates | A directory that serves as a public repository for document templates. |
via Environment.GetFolderPath(Environment.SpecialFolder.XXXXX); We can easily get the specific path to a special folder on the system and then open the folder with the Process.Start() method. For example:
System.Diagnostics.Process.Start(Environment.GetFolderPath(Environment.SpecialFolder.System)); Open the system folder (System32 folder)
[System.Runtime.InteropServices.DllImportAttribute("user32.dll")] private static extern int FindWindow(string ClassName, string WindowName); [System.Runtime.InteropServices.DllImport("user32.dll")] private static extern int ShowWindow(int handle, int cmdShow); [System.Runtime.InteropServices.DllImport("winmm.dll", EntryPoint = "mciSendString", CharSet = System.Runtime.InteropServices.CharSet.Auto)] private static extern int mciSendString(string lpstrCommand, string lpstrReturnstring, int uReturnLength, int hwndCallback);
private const int SW_HIDE = 0; API parameters represent hidden windows private const int SW_SHOW = 5; API parameters indicate that the window is displayed at its current size and position ShowWindow(FindWindow("Shell_TrayWnd", null), SW_HIDE); -- Hide hidden taskbar ShowWindow(FindWindow("Shell_TrayWnd", null), SW_SHOW); -- Show taskbar
mciSendString("set CDAudio door open", null, 127, 0); -- Pop up the optical drive mciSendString("set CDAudio door closed", null, 127, 0); --Turn off the optical drive
|