For ease of operation, many programmers often write repetitive work into a batch.
However, how do I accept input parameters in batch processing? See the following example:
@ Echo offset/P time = enter the shutdown time: shutdown-S-F-T % time %
This is a batch processing of Timed Shutdown. It accepts a time parameter. You can enter how long it will take to shut down.
See the following line by line:
@ Echo off, DOS will execute commands in the file in sequence, and automatically output the executed commands in DOS. If we do not want to display the executed commands, you can use echo off to disable automatic output.
However, echo off is also a command and will be displayed. If we do not want to display echo off, add @ before echo off @. In general, the purpose of this command is to close the output of the command.
@ Set/P time = enter the shutdown time:, set/P varname = "string", which defines a variable. The value of the variable is input by the user, followed by a string, is the prompt displayed in the Command window.
% Time %, get the variable value
The running effect is as follows:
CMD accepts input parameters (for example, shutdown at a specified time)