Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Remote to shutdown server  (Read 93898 times)

0 Members and 1 Guest are viewing this topic.

sun_os

    Topic Starter


    Beginner

    Remote to shutdown server
    « on: April 08, 2021, 10:27:05 AM »
    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 ?

    Thanks

    sun_os

      Topic Starter


      Beginner

      Re: Remote to shutdown server
      « Reply #1 on: April 08, 2021, 09:58:52 PM »
      ECHO 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