Reboot server through command prompt

Have a 2003 Server that gives trouble everyday and needs to be rebooted.  When attempting to RDP the message about it be unavailable appears.  I can ping the server and I can connect to it through my PC Computer Management, but when I attempt go to the advanced tab and select to shutdown and then restart, I get an error message & the machine will not reboot.  I then have to get up and go to the server room and push the power button.  There are times noone is available at the office to do this when others work on say weekends or late nights and since I can ping the server, I'm assuming I can use command line switches to reboot.

I've seen so many variations, I don't know which one is what I need.  All I want to do is RESTART the server, not shut it down.

I've seen these:
shutdown -r -f -t 30 -m \\ServerName
shutdown /r /m \\ServerName
psshutdown \\<PCname> -f -r


I'm thinking it's something closer to this shutdown /r /m \\ServerName but have no idea what the /m switch means.
mdmcq5Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

KaliKoderCommented:
Hello mdmcq5,

The following article might be of help (I know you might have been through the same as well)

http://support.microsoft.com/default.aspx?scid=kb;en-us;317371&sd=tech

Although above is about Windows 2000, same is true for Windows 2003.

I believe in your case, the command would be:
shutdown \\yourservername /r /y /c

This would shutdown your server, close all open applications, and answer yes to the prompts if any.

You can schedule the shutdown using the AT command (as described in the article) or you can also put this command in a bat file and run that bat file using the built in task scheduler in Windows 2003.

Thanks and Good Luck!
0
mdmcq5Author Commented:
ok, i'll give it a shot the next time it happens and let you know if it works. thanks.
0
Rob WilliamsCommented:
I have had problems with the reboot feature of the Windows ShutDown command in the past. Shutting down worked fine. If you find the same, Sysinternals, who make many server management tools, have a free shutdown utility that works very well called PSShutDown. It is run from a command line, can be run on the local machine or used to control remote machines. Has many numerous options and works very well:
http://www.sysinternals.com/Utilities/PsShutdown.html
0
Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

mdmcq5Author Commented:
I'll take a look!
Don't get all the command switches though..
0
Rob WilliamsCommented:
>>"Don't get all the command switches though.."
They are not as bad as they look. Just choose the ones you want and put them in order. You don't have to use any of them. A typical example would be:

psshutdown.exe @CompList.txt -r -f -c -t 30 -m "You computer will shutdown in 5 minutes. You may cancel if necessary"

@CompList.txt = If you wish to shut down a group of computers use this and insert in the CompList.txt file a series of computers you want to shut down
-r = reboot
-c = display a message box allowing the user to cancel
-t 30 = perform shut down in 30 seconds
-m "Your message" = the message you want to display in the message box

You can simply use:
   psshutdown.exe  YourComputerName  -r
or  
   psshutdown.exe -r  
if it is the machine on which the command is run.



0
mdmcq5Author Commented:
Guys,

I've tried both of your suggestions and here is what I get:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
KaliKoder -> not accepting your suggestion -> shutdown \\yourservername /r /y /c
                   here's the cmd output:
                    C:\Documents and Settings\user>shutdown //citrix /r /y /c
                    Usage: shutdown [-i | -l | -s | -r | -a] [-f] [-m \\computername] [-t xx] [-c "comment"]        [-dp:xx:yy]

        No args                 Display this message (same as -?)
        -i                      Display GUI interface, must be the first option
        -l                      Log off (cannot be used with -m option)
        -s                      Shutdown the computer
        -r                      Shutdown and restart the computer
        -a                      Abort a system shutdown
        -m \\computername       Remote computer to shutdown/restart/abort
        -t xx                   Set timeout for shutdown to xx seconds
        -c "comment"            Shutdown comment (maximum of 127 characters)
        -f                      Forces running applications to close without warning
        -d [u][p]:xx:yy         The reason code for the shutdown
                                u is the user code
                                p is a planned shutdown code
                                xx is the major reason code (positive integer less than 256)
                                yy is the minor reason code (positive integer less than 65536)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
RobWill:
tried this ->  psshutdown.exe  YourComputerName  -r
and got this output:
C:\Documents and Settings\user>psshutdown.exe Citrix -r

PsShutdown v2.50 - Shutdown, logoff and power manage local and remote systems
Copyright (C) 1999-2005 Mark Russinovich
Sysinternals - www.sysinternals.com

usage:
psshutdown -s|-r|-h|-d|-k|-a|-l|-o [-f] [-c] [-t [nn|h:m]] [-v nn] [-e [u|p]:xx:
yy] [-m "message"] [-u Username [-p password]] [-n s] [\\computer[,computer[,...
]|@file]
   -a          Abort a shutdown (only possible while countdown is in progress)
   -c          Allow the shutdown to be aborted by the interactive user
   -d          Suspend the computer
   -e          Shutdown reason code (available on Windows XP and higher).
               Specify 'u' for unplanned and 'p' for planned
               shutdown reason codes.
               xx is the major reason code (must be less than 256)
               yy is the minor reason code (must be less than 65536)
   -f          Forces running applications to close
   -h          Hibernate the computer
   -k          Poweroff the computer (reboot if poweroff is not supported)
   -l          Lock the computer
   -m          Message to display to logged on users
   -n          Specifies timeout in seconds connecting to remote computers
   -o          Logoff the console user
   -p          Specifies optional password for user name. If you omit this
               you will be prompted to enter a hidden password.
   -r          Reboot after shutdown
   -s          Shutdown without poweroff
   -t          Specifies countdown in seconds until shutdown (default is 20) or
               the time of shutdown (in 24 hour notation)
   -u          Specifies optional user name for login to remote
               computer.
   -v          Display message for the specified number of seconds before the
               shutdown. If you omit this parameter the shutdown notification
               dialog displays and specifying a value of 0 omits the dialog.
   computer    Shutdown the computer or computers specified
   @file       Shutdown the computers listed in the file specified


Reasons defined on this computer (U = unplanned, P = planned):
Type   Major   Minor   Title
  U      0       0     Other (Unplanned)
  P      0       0     Other (Planned)
  U      1       1     Hardware: Maintenance (Unplanned)
  P      1       1     Hardware: Maintenance (Planned)
  U      1       2     Hardware: Installation (Unplanned)
  P      1       2     Hardware: Installation (Planned)
  U      2       3     Operating System: Upgrade (Unplanned)
  P      2       3     Operating System: Upgrade (Planned)
  U      2       4     Operating System: Reconfiguration (Unplanned)
  P      2       4     Operating System: Reconfiguration (Planned)
  U      4       1     Application: Maintenance (Unplanned)
  P      4       1     Application: Maintenance (Planned)
  U      4       5     Application: Unresponsive
  U      4       6     Application: Unstable

When it reaches back to the C:\ prompt I attempt to enter Type/Major/Minor/Title, but nothing is accepting.  I've attempting just entering the Type, but no go.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

any ideas?
0
KaliKoderCommented:
you are using the wrong slashes ?

C:\Documents and Settings\user>shutdown //citrix /r /y /

should be:

C:\Documents and Settings\user>shutdown \\citrix /r /y /

Good Luck!
0
Rob WilliamsCommented:
Agreed wrong syntax. What is the 'Y' ?
Anyway try:
psshutdown.exe   \\YourComputerName   -r
need the  '\\' and switches are '-' rather than '/' as in DOS
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mdmcq5Author Commented:
KaliKoder, you're right, I did use the wrong switch; odd I missed that one.

As for those switches RobWill ->
/r: Use this switch to restart the computer instead of fully shutting it down.
/y: Use this switch to force a "yes" answer to all queries from the computer.

Now, RobWill:
your suggestion on using \\ the page you posted from sysinternals states:
computer
    Perform the command on the remote computer or computers specified. If you omit the computer name the command runs on the local system, and if you specify a wildcard (\\*), the command runs on all computers in the current domain.

I definitely don't want that!
0
mdmcq5Author Commented:
KaliKoder:
retried your syntax and still had output, must need some additional switches added? And I also noticed you left off the /c this time..??:
C:\Documents and Settings\user>shutdown \\citrix /r/y/c
Usage: shutdown [-i | -l | -s | -r | -a] [-f] [-m \\computername] [-t xx] [-c "comment"] [-d up:xx:yy]

        No args                 Display this message (same as -?)
        -i                      Display GUI interface, must be the first option
        -l                      Log off (cannot be used with -m option)
        -s                      Shutdown the computer
        -r                      Shutdown and restart the computer
        -a                      Abort a system shutdown
        -m \\computername       Remote computer to shutdown/restart/abort
        -t xx                   Set timeout for shutdown to xx seconds
        -c "comment"            Shutdown comment (maximum of 127 characters)
        -f                      Forces running applications to close without warning
        -d [u][p]:xx:yy         The reason code for the shutdown
                                u is the user code
                                p is a planned shutdown code
                                xx is the major reason code (positive integer less than 256)
                                yy is the minor reason code (positive integer less than 65536)
0
Rob WilliamsCommented:
-r  is right but I don't see -y  as an option. That is a switch/option with DOS.

It's the * that is the wildcard not the \\
So I would recommend using the \\Computername
Using neither would indicate the local machine.
The Other option is @List.txt
Where  List.txt is a text file that lists the computers you want to shut down. In that list the \\ is not required.
0
mdmcq5Author Commented:
RobWill:

I'll try your syntax shortly; someone logged in right now...
0
Rob WilliamsCommented:
OK, let us know how you make out.
Keep in mind Windows' Shudown and Sysinternal's  PSShutdown use different switches and syntax. I didn't notice before you were using 'Y' with the Windows version, sorry.
0
mdmcq5Author Commented:
RobWill:

I tried this and it worked:
psshutdown.exe   \\YourComputerName   -r

Now, I just have to wait for a day when it has become unavailable and unable to RDP.  Once that happens and I use your syntax and it works, you get the points!
0
Rob WilliamsCommented:
Why are you unable to RDP ? If due to someone else not logging off and the session is locked, are you aware you can log onto the console session to "boot" someone off. To do so in the Start / Run box enter:
 mstsc  /console
This will start the Remote Desktop connection in the same fashion, but log into the console session rather than the remoter user session. Effectively the same thing, but different access.
0
mdmcq5Author Commented:
There are times w/two particular Servers: Internal and External Citrix, become unresponsive: they can be pinged, but an attempt to RDP results in an error message stating it's not enabled.  So, we get up and walk to the server room and hit the power button to turn either of them off b/c it's the only way (so far) we've been able to get them to shutdown and reboot.

I already use the "mstsc /v:servername /console" switch for all the servers I RDP into, but like I said above, it won't let me access.

So, I wanted to find another solution to rebooting either one if this problem occurs again; which it will in a few days or so.  Then I'd like to try your switch above to see if it will allow me to reboot it from the command prompt; since it is pingable, just not RDP'ible, for some reason.  And I can connect to it using my Computer Management, but the shutdown/reboot option under advanced -> Startup & Recovery settings -> fails.  It won't let me reboot that way either.

Half the time, users have problems getting into these servers when all the IT ppl have left for the day, so there have been occassions when we have to drive all the way out to the office just to reboot the damn things.  If we can RDP into our workstations from home and use your suggested switch to reboot and resolve the problem, then we have a solution to a very very very bothersome problem w/in our department.
0
Rob WilliamsCommented:
Ah, of that makes sense. "Been there done that". Just wasn't sure if you were aware of console session option. Depending on what services have locked up, PSShutDown or Shutdown may not work in that situation. Often it is RPC, and then I don't think either will work. Well worth a try though.

>>"Once that happens and I use your syntax and it works, you get the points!"
Question wasn't whether it would shut down you machine, but rather getting syntax to work. That has been verified to function properly.  :-)

You might want to actually find the service/app that is causing the problem, though if the machine is locked up at the time that wouldn't be easy. Sysinternals has several other free tools you might want to have a look at for that purpose, such as PMon, PSList,  PSService:
http://www.sysinternals.com/ProcessesAndThreadsUtilities.html
--Rob
0
mdmcq5Author Commented:
You're right about the switch you provided working, I give you that.

As for finding the service/app that is causing all the problems w/these servers, all the Event Logs have printer management errors.  Which of the programs you listed will be the most beneficial? Haven't looked at the page yet.
0
Rob WilliamsCommented:
I personally haven't used them often, but I would say PMon would be your best bet. I just tried running it and it wouldn't run on this system for some reason. I have used RegMon and I would assume much like it, PMon would generate a lot of activity. RegMon includes the ability to filter out as many unrelated service as you want, making it easier to monitor. You would want to look at the status every couple of hours, so you could see what is happening before the server locks up.
0
mdmcq5Author Commented:
Yep, it is an RPC problem....
0
Rob WilliamsCommented:
Then PSShudown or ShutDown, may not work. Still, give it a try, nothing to loose.
0
mdmcq5Author Commented:
I've installed RegMon and it definitely lists alot of activity.  I also found someplace here on EE, that under Network Settings -> Advanced Settings -> Adapters and Bindings, under the connections box is a list of network connections; both disabled and enabled.  The suggestion online here was to put the connection which is used for the server to the top of the list.  The disabled connection was the one on top, so I moved the enabled connection to the top of the list and there haven't been any problems...yet!  So, perhaps that was something that needed to be changed.  May or may not make much of a difference but it's worth a test.

As for your PSShutdown switch, RobWill, it definitely works, when a connection to the server is available.  Still waiting for the server to freeze up so I can try the switch then and see if it works, if it does, you seriously rock.

Until the next question.......
Thanks!
0
mdmcq5Author Commented:
Points being awarded to RobWill since he resolved first.  

Never heard back from you KaliKoder concerning your switch syntax not being accepted or recognized, and you never suggested or posted anything more.

Thanks to both of you for your input!
0
Rob WilliamsCommented:
mdmcq5 , I don't know that the connection priorities would cause you lockup but good idea to change.

Thanks, and good luck,
--Rob
0
mdmcq5Author Commented:
had the citrix error today, and although I could ping it, couldn't RDP, so I used psshutdown.  It stated it would reboot in 20, but it never did.  Wouldn't have been awesome if it would have actually worked.  I could still get to it through my computer management.  Very odd server.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows Server 2003

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.