|
Answer» Dear All,
I have the server list to shutdown and restart, create the operator menu to select machine to shutdown or restart server. I know that the right must be admin group member. Therefore I want to write the batch script to instruction the operator to shutdown or restart server from the operation menu
The menu have three options, 1 . Restart 2. Shutdown 3 Quit
Press 1 then input the server name , then read the server name GO to shutdown /s /m \\$servername by remote, I have no idea the syntax to read the input server name then go to remote shutdown machine . Can you give me hint for this ?
ThanksECHO off CLS :MENU ECHO. ECHO ....................................... ........ ECHO Select server ECHO ....................................... ........ ECHO. ECHO 1 - Shutdown ECHO 2 - Restart ECHO 3 - Ping test ECHO 4 - Quit ECHO. SET /P M=Type 1, 2, 3 then press ENTER: IF %M%==1 GOTO SHUTDOWN SERVER IF %M%==2 GOTO RESTART SERVER IF %M%==3 GOTO PING SERVER IF %M%==4 GOTO Quit
:SHUTDOWN set /p servername=" Enter the server name " set /p "yesno"=Are you shutdown the server ? [Y/N] IF "%yesno%" == "Y" then GOTO CONFIRM1
:CONFIRM1 shutdown /m \\"%servername%"
:RESTART set /p servername=" Enter the server name " set /p "yesno"=Are you REBOOT the server ? [Y/N] IF "%yesno%" == "Y" then GOTO CONFIRM2
:CONFIRM2 shutdown /r /m \\"%servername%"
:PING set /p servername=" Enter the server name " set /p "%yesno%"=Are you ping the server ? [Y/N] IF "%yesno%" == "Y" then GOTO CONFIRM3
:CONFIRM3 ping "%servername%"
:EXIT
|