Go from blog: http://blog.csdn.net/ypist/article/details/8485049
#1, System () mode
Create a new folder under the C packing directory with the name 12:system ("MD C://12");
The command window will flash at execution time and cannot see the execution result;
DOS itself provides the ability to execute multiple commands, and the symbol && delegate executes multiple commands at the same time.
If you first switch to the 12 folder under C, then execute the DIR command: cd c:/12 && dir
Pause after three seconds to resume program: ping-w > Nul
Pause know the user presses any key and then executes the dir command: Pause && dir
#2, WinExec () mode
Get a list of files in the current directory: WinExec ("cmd.exe/c dir > Result.txt", sw_hide);
Execution result: In the current directory new file Result.txt, the content is the dir command results.
#3, ShellExecute () mode
Open cmd.exe and then create a new folder named ZZZ under drive C: ShellExecute (NULL, "open", "C://windows//system32//cmd.exe", "/C MD c://zzz", "", Sw_show) ;
ShellExecute can run not only exe files, but also files that are already associated.
The first must refer to the Shellapi.pas unit: uses SHELLAPI;
1. Standard usage
ShellExecute function prototype and parameter meanings are as follows:
function ShellExecute (Hwnd:hwnd; Operation, FileName, Parameters,directory:pchar; Showcmd:integer): HINST; stdcall;
HWnd: Used to specify the parent window handle. When an error occurs in the function call procedure, it acts as the parent window of the Windows message window. For example, you can set it to the application main window handle, which is application.handle, or you can set it as the desktop window handle (obtained with the GetDesktopWindow function);
operation: Used to specify the action to be made. Where the "open" operation means that the program specified by the filename parameter is executed, or the file or folder specifiedby the filename parameter is opened, andthe "print" operation means that the file specified by the filename parameter is printed; "Explore" The action represents browsing the folder specified by the filename parameter. When the parameter is set to nil, the default action "open" is executed;
FileName: Used to specify the file name to open, the name of the program file to execute, or the folder name to browse;
Parameters: If the filename parameter is an executable program, this parameter specifies a command-line argument, otherwise this parameter should be nil or pchar (0);
Directory: Used to specify the default directory;
ShowCmd: If the filename parameter is an executable program, this parameter specifies how the program window is initially displayed, otherwise this parameter should be set to 0.
If the ShellExecute function call succeeds, the return value is the instance handle of the executing program. If the return value is less than 32, it indicates an error occurred.
2. Special usage
If the filename parameter is set to the "http:" protocol format, the function opens the default browser and links to the specified URL address. If multiple browsers are installed in the user's machine, the function determines which browser to start based on the settings of the HTTP protocol handler (Protocols Handler) in the Windows 9x/nt registry.
Format one:/HTTP website domain name.
such as: ShellExecute (handle, ' open ',/http; Www.neu.edu.cn ', nil, nil, SW_SHOWNORMAL);
Format two: HTTP//Website name/page file name.
such as: ShellExecute (handle, ' open ',/http; Www.neu.edu.cn/default.htm ', Nil,nil, SW_SHOWNORMAL);
If the filename parameter is set to the "mailto:" protocol format, the function launches the default mail client, such as Microsoft Outlook (also including Microsoft Outlook Express), or Netscape Messanger. If more than one mail client is installed in the user's machine, the function determines which mail client to start based on the settings of the Mailto protocol handler in the Windows 9x/nt registry.
Format one: mailto
such as: ShellExecute (handle, ' open ', ' mailto: ', nil, nil, SW_SHOWNORMAL); Open a new mail window;
Format two: mailto: User account @ Mail server address
such as: ShellExecute (handle, ' open ', ' mailto:[email protected] ', nil, nil, SW_SHOWNORMAL); Opens a new mail window and automatically fills in the recipient's address;
If you specify multiple recipient addresses, the recipient addresses must be separated by semicolons or commas (hereinafter) such as: ShellExecute (This->m_hwnd, "open", "mailto:[email protected]", "", "", Sw_ SHOW); This can activate Outlook Express.
Format three: mailto: User account @ Mail server address? subject= message subject &body= message body
such as: ShellExecute (handle, ' open ', ' mailto:[email protected]? Subject=hello&body=this is a test ', nil, nil, SW_SHOWNORMAL); opens a new mail window and automatically fills in the recipient's address, message subject, and message body. If the message body includes multiple lines of text, you must add a newline escape character%0a between each line of text.
#4, ShellExecute () parameter
The last parameter, which specifies a command for the visibility of the window.
Please use any one of the following constants
Sw_hide hidden window, active state to make a window
sw_minimize minimized window, active state to make a window
Sw_restore displays a window with its original size and position, while making it active
Sw_show displays a window with the current size and position, and makes it active
Sw_showmaximized to maximize the window and activate it
sw_showminimized Minimize the window and activate it
Sw_showminnoactive minimizes a window without changing the active window
Sw_showna displays a window with the current size and position without changing the active window
Sw_shownoactivate displays a window with the nearest size and position without changing the active window
Sw_shownormal is the same as Sw_restore
#5, some common commands for Windows
Winver---------Check the Windows version
Wmimgmt.msc----Open Windows Management Architecture (WMI)
Wupdmgr--------Windows Update
wscript--------Windows Script Host Settings
Write----------WordPad
WINMSD---------System Information
Wiaacmgr-------Scanner and Camera Wizard
Winchat--------XP comes with LAN chat
Mem.exe--------Show Memory usage
Msconfig.exe---System Configuration Utility
Mplayer2-------Easy widnows Media Player
MSPaint--------Drawing Board
MSTSC----------Remote Desktop Connection
Mplayer2-------Media Player
Magnify--------Magnifier Utility
MMC------------Open the console
Mobsync--------Synchronization commands
DxDiag---------Checking DirectX information
DRWTSN32------System Doctor
Devmgmt.msc---Device Manager
Dfrg.msc-------Disk Defragmenter
Diskmgmt.msc---Disk Management utility
DCOMCNFG-------Open System Component Services
DdeShare-------turn on DDE sharing settings
Dvdplay--------DVD Player
net stop Messenger-----Stop messenger Service
net start Messenger----Start Messenger Service
Notepad--------Open Notepad
Nslookup Tool Wizard for-------Network management
ntbackup-------system backup and restore
Narrator-------Screen Narrator
Ntmsmgr.msc----Mobile Storage Manager
Ntmsoprq.msc---Mobile storage administrator * make requests
Netstat-an----(TC) command Check interface
Syncapp--------Create a Briefcase
Sysedit--------System Configuration Editor
Sigverif-------File Signature Validator
SNDREC32-------Recorder
SHRPUBW--------Create a shared folder
Secpol.msc-----Local Security Policy
SYSKEY---------System encryption, once encrypted can not be solved, protect the Windows XP system dual Password
Services.msc---Local Service settings
SNDVOL32-------Volume Control program
Sfc.exe--------System File Checker
Sfc/scannow---Windows File Protection
TSSHUTDN-------60-second Countdown shutdown command
Tourstart------XP profile (roaming XP programs that appear after installation is complete)
Taskmgr--------Task Manager
EVENTVWR-------Event Viewer
Eudcedit-------Character-font procedure
Explorer-------Open Resource Manager
Packager-------Object Wrapping Program
PERFMON.MSC----Computer Performance monitoring Program
ProgMan--------Program Manager
Regedit.exe----Registration Form
Rsop.msc-------Group Policy result set
Regedt32-------Registry Editor
Rononce-p----15-second shutdown
regsvr32/u *.dll----Stop DLL file to run
regsvr32/u zipfldr.dll------Cancel Zip support
Cmd.exe--------cmd command prompt
Chkdsk.exe-----CHKDSK disk Check
Certmgr.msc----Certificate Management Utility
Calc-----------Start Calculator
Charmap--------Start character mapping table
CLICONFG-------SQL SERVER Client Network Utility
CLIPBRD--------Clipboard Viewer
Conf-----------start NetMeeting
Compmgmt.msc---Computer Management
cleanmgr-------good things to finish.
CIADV.MSC------Indexing Service Program
OSK------------Open the On-screen keyboard
ODBCAD32-------ODBC data Source Manager
oobe/msoobe/a----Check if XP is active
Lusrmgr.msc----native Users and Groups
Logoff---------Logoff command
IExpress-------Trojan Bundle tool, System comes with
Nslookup-------IP Address detector
Fsmgmt.msc-----shared Folder Manager
Utilman--------Utility Manager
Gpedit.msc-----Group Policy
Run the command encyclopedia under XP.
$Systemroot $documents and Settingsusername directory
Appwiz.cpl------------Add a Remove program
Control userpasswords2--------User account Settings
cleanmgr-------Waste Finishing
The CMD--------------command prompt can be thought of as an attachment to Windows that ping,convert these features that cannot be used in a graphical environment.
CMD------jview View the Java Virtual Machine version.
Command.com------Call is the system built-in NTVDM, a DOS virtual machine. It is completely a virtual PC-like environment, and the system itself is not very connected. When we run a DOS program at the command prompt, it is actually automatically transferred to the NTVDM virtual machine, which has nothing to do with the CMD itself.
Calc-----------Start Calculator
Chkdsk.exe-----CHKDSK disk Check
Compmgmt.msc---Computer Management
Conf-----------start NetMeeting
Control USERPASSWORDS2-----User account permission settings
Devmgmt.msc---Device Manager
Diskmgmt.msc---Disk Management utility
Dfrg.msc-------Disk Defragmenter
DRWTSN32------System Doctor
Dvdplay--------Start Media Player
DxDiag-----------DirectX Diagnostic Tool
gpedit.msc-------Group Policy Editor
Gpupdate/target:computer/force Force Refresh Group Policy
Eventvwr.exe-----Event Viewer
Explorer-------Open Resource Manager
Logoff---------Logoff command
Lusrmgr.msc----native Users and Groups
Msinfo32---------System Information
Msconfig---------System Configuration Utility
net start (servicename)----start the service
net stop (servicename)-----Stop the Service
Notepad--------Open Notepad
Nusrmgr.cpl-------with Control userpasswords, open the user Account Control Panel
Nslookup-------IP Address detector
oobe/msoobe/a----Check if XP is active
PERFMON.MSC----Computer Performance monitoring Program
ProgMan--------Program Manager
Regedit----------Registry Editor
Regedt32-------Registry Editor
regsvr32/u *.dll----Stop DLL file to run
Route print------View the routing table
Rononce-p----15-second shutdown
Rsop.msc-------Group Policy result set
rundll32.exe rundll32.exe%systemroot%system32shimgvw.dll,imageview_fullscreen----Start a blank Windows Picture and Fax Viewer
Secpol.msc--------Local Security Policy
Services.msc---Local Service settings
Sfc/scannow-----Boot System File Checker
SNDREC32-------Recorder
Taskmgr-----Task Manager (for 2000/xp/2003)
TSSHUTDN-------60-second Countdown shutdown command
Winchat--------XP comes with LAN chat
WINMSD---------System Information
Winver-----Show about Windows window
Windows XP shutdown is controlled by the Shutdown.exe program, which is located in the Windows/system32 folder. If you want Windows 2000 to do the same, you can copy the Shutdown.exe to the system directory.
For example, your computer to shut down at 22:00, you can choose "Start → run", enter "at 22:00 shutdown-s", so that the 22 point of the computer will appear the "System Shutdown" dialog box, the default has a 30 seconds countdown and prompts you to save the work. If you want to shut down by a countdown, you can enter "shutdown.exe-s-T 3600", which means auto power off after 60 minutes, and "3600" for 60 Minutes.
After setting the auto power off, if you want to cancel, you can enter "Shutdown-a" in the run. Also enter "Shutdown-i", you can open the Set Automatic Shutdown dialog box, the automatic shutdown to set.
Shutdown.exe parameters, each with a specific purpose, the execution of each will have a different effect, such as "-S" means to shut down the local computer, "-a" means to cancel the shutdown operation, the following list more parameters, can be used on demand in Shutdown.exe.
-F: Forcibly closing the application
-m//Computer name: Controlling remote computer
-I: Displays the graphical user interface, but must be the first option of shutdown
-L: Log off the current user
-R: Shutdown and restart
-T time: Set shutdown countdown
-C "Message content": Enter the message content in the Shutdown dialog box (cannot exceed 127 characters)
Sometimes, we need to shut down the computer at regular intervals, here is a simple way to implement a timed shutdown under Windows XP.
Specifies that the system automatically shuts down after 22 minutes: Click "Start → run", enter the command "shutdown-s-T 1320" in "open" (note: quotation marks are not entered, there is a space between parameters, 1320 is in seconds), click OK
button.
Specifies that the system automatically shuts down at a certain time (for example, 12:00): Enter a command in open
"At Shutdown-s".
To cancel a timed shutdown: Enter the command "Shutdown-a" in "open".
My usual way is the first kind, simple rough, also quite practical!
Executing DOS commands in a C + + program