CMD accepts input parameters (for example, shutdown at a specified time)

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.