In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/03 Report--
In help documents in windows cmd and other introductions on the Internet, strings are generally replaced with the command "set". Or activate environment variables, but it is rare to use "set" and "if" to write an optional functional script. Here I will simply write a bat script with these two commands.
The @ rem This is an easy script to shutdwon and reboot with "set" command@echo script is used to implement the shutdown and restart options @ echo 1, shutdown @ echo 2, restart @ echo 3, cancel the above operations @ pause@echo offset / P var= Please enter your choice: if% var% = = 1 shutdown-s-t 5-c "It will shutdown after 5 seconds" if% var% = = 2 shutdown-r-t 5-c "It will reboot after 5 seconds" if% var% = 3 shutdown-a
Here are a few key commands that are useful in this script.
Set sets a variable for var, and "/ p" is the switch that receives the string we entered.
Note: when referencing a variable, pay attention to adding "%" on the left and right sides of the variable.
There are three uses of if
IF [NOT] ERRORLEVEL number commandIF [NOT] string1==string2 commandIF [NOT] EXIST filename command
The second use we use here, the string equivalent, is that in our bat, variables are almost equivalent to "strings". Our% var% variable is the string we entered, and when the string we enter is equal to 1, execute our subsequent command. In our case, this is the "shutdown" command.
The running effect of the script:
Here, in order to have a time buffer, I change the time to 30s, and if you want to terminate the script, run the script again. This is just to focus on the option usage of the set command.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.