

InterviewSolution
Saved Bookmarks
1. |
Solve : Remote to shutdown server? |
Answer» <html><body><p>Dear All,<br/><br/>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<br/><br/>The menu have three options, 1 . Restart <a href="https://interviewquestions.tuteehub.com/tag/2-236987" style="font-weight:bold;" target="_blank" title="Click to know more about 2">2</a>. Shutdown 3 Quit<br/><br/>Press 1 then input the server name , then read the server name <a href="https://interviewquestions.tuteehub.com/tag/go-468886" style="font-weight:bold;" target="_blank" title="Click to know more about GO">GO</a> 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 ?<br/><br/>ThanksECHO off<br/>CLS<br/>:MENU<br/>ECHO.<br/>ECHO ....................................... ........<br/>ECHO Select server <br/>ECHO ....................................... ........<br/>ECHO.<br/>ECHO 1 - Shutdown <br/>ECHO 2 - Restart <br/>ECHO 3 - Ping test <br/>ECHO <a href="https://interviewquestions.tuteehub.com/tag/4-238406" style="font-weight:bold;" target="_blank" title="Click to know more about 4">4</a> - Quit<br/>ECHO.<br/><a href="https://interviewquestions.tuteehub.com/tag/set-11758" style="font-weight:bold;" target="_blank" title="Click to know more about SET">SET</a> /P M=Type 1, 2, 3 then press ENTER:<br/>IF %M%==1 GOTO SHUTDOWN SERVER <br/>IF %M%==2 GOTO RESTART SERVER<br/>IF %M%==3 GOTO PING SERVER<br/>IF %M%==4 GOTO Quit <br/><br/>:SHUTDOWN<br/>set /p servername=" Enter the server name "<br/>set /p "yesno"=Are you shutdown the server ? [Y/N]<br/>IF "%yesno%" == "Y" then GOTO CONFIRM1<br/><br/>:CONFIRM1<br/>shutdown /m \\"%servername%" <br/><br/>:RESTART<br/>set /p servername=" Enter the server name "<br/>set /p "yesno"=Are you <a href="https://interviewquestions.tuteehub.com/tag/reboot-1179238" style="font-weight:bold;" target="_blank" title="Click to know more about REBOOT">REBOOT</a> the server ? [Y/N]<br/>IF "%yesno%" == "Y" then GOTO CONFIRM2<br/><br/>:CONFIRM2<br/>shutdown /r /m \\"%servername%"<br/><br/>:PING<br/>set /p servername=" Enter the server name "<br/>set /p "%yesno%"=Are you ping the server ? [Y/N]<br/>IF "%yesno%" == "Y" then GOTO CONFIRM3 <br/><br/>:CONFIRM3<br/>ping "%servername%"<br/><br/><br/>:EXIT</p></body></html> | |