Introduction
illustrate
This article introduces the usage of batch processing for Windows.
Usage overview
Batch writing method for Windows: Create a suffixed .bat file, and then write the command to this file.
Batch-related commands
Order |
effect |
Example |
call |
Call the script (wait for the script execution to end) |
call // Call the execution script (the script will be executed only after the original script is executed) |
cls |
Clear the screen |
|
color |
Set the current cmd window background color and foreground color (foreground color is the color of the font) |
color // Restore to default settings color 02 // Set the background color to black and the font to green |
date |
Show or set the current date |
date /t // Show the current date date // Set the new current date (format: YYYY/MM/DD), and directly pressing the car will mean abandoning the setting |
echo |
Show content |
echo hehe //Output on the console echo hehe > //Write hehe (create if it does not exist, and overwrite if it exists) |
exit |
Exit the current cmd window instance |
exit 0 // Exit the current cmd window instance, set the exit code to 0 (0 means success, non-0 means failure) exit /B 1 // Exit the current bat script and set the ERRORLEVEL system variable to 1 |
hostname |
Show the current machine name |
|
label |
Display the current partition's volume label, and prompt for new volume label |
label c:system Set the volume label of the c disk to system |
pause |
Pause the batch process and display: Press any key to continue... |
|
Print with the set printer |
print // Use the set printer to print text files |
|
prompt |
Modify the command prompt |
prompt orz: // Modify the command prompt to orz: |
start |
Start a new window and run a program or command. The next command is executed without waiting for the execution of this command to end. |
start "D:\" start /B "D:\" //Start, but do not close this window start explorer f:\ // Call Explorer to open the F disk strat iexplore "" // Start ie and open start // Start execution (after starting the script, the original script continues to be executed and will not wait for the script to be executed) |
time |
Display or set the current time |
time /t // Show the current time time xxx // Set the new current time (format: hh:mm:ss), and directly enter the car to indicate that the setting is abandoned |
title |
Modify the title bar text of the current cmd window |
title mytitle |
ver |
Display the version number of the current Windows system |
|
vol |
Display the volume label of the current partition |
|
winver |
The pop-up box displays the current Windows system information |
|
Usage of batch processing
Separation
Each command is split with a carriage return instead of a semicolon.
Don't close the window after executing the command
Method 1. Use @cmd /k
cd /d D:\dev\ @cmd /k
Method 2. Use /B parameters
start /B
Method 3: Use pause
start pause
Note: It is not recommended to use pause because it can only stop and cannot continuously obtain the output of the program.
This is the end of this article about the usage of Windows command batch processing. For more related Windows command batch processing content, please search for my previous articles or continue browsing the related articles below. I hope everyone will support me in the future!