Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'd like to know if it is possible to shut down a Windows Server 2003 box, without have to log into the machine via remote desktop.

The server is on my network, I know the IP address and host name, as well the Administrator password.

I want to shutdown by simply double clicking a shortcut or executing a script.

How do I do this?

share|improve this question

4 Answers 4

up vote 16 down vote accepted

Remote shutdown...

  • Using your domain account credentials (if your user account has local admin rights on the target machine):
    shutdown /s /f /t 30 /m \\SERVER-NAME
  • Using the remote machine's local administrator account (psexec will prompt you for the password):
    psexec \\SERVER-NAME -e -h -u SERVER-NAME\administrator shutdown /s /f /t 30
  • Using a different domain account:
    psexec \\SERVER-NAME -e -h -u DOMAIN-NAME\username shutdown /s /f /t 30

Shutdown parameters explained...

  • /s = shutdown (substitute /r if you want to reboot)
  • /f = force (don't let running programs or active user sessions interfere with the reboot)
  • /t 30 = give logged in users a 30-second warning (substitute any integer, 0 is an acceptable value)
  • /m \\SERVER-NAME = specify name of remote machine to reboot

PsExec parameters explained...

  • -e = do not load user profile (user profile is unnecessary for shutdown command)
  • -h = run task with elevated privileges (only makes a difference on Vista/Win7/Server2008)
  • -u SERVER-NAME\administrator = log in as local administrator on SERVER-NAME
  • shutdown /s /f /t 30 = i

Batch file example, using local admin account... (paste into Notepad as rsla.bat)

  • @echo off
    REM rsla.bat - remote shutdown as local administrator
    REM This script is freeware authored by Miles Erickson, 7/2010.
    REM Requires PsExec.exe to be available in %PATH% (c:\windows\system32 is one option)
    REM Cannot be used to restart a domain controller (domain controllers do not have local admin accounts)
    IF (%1)==() GOTO instructions
    IF (%1)==(/?) GOTO instructions
    psexec \\%1 -e -h -u %1\administrator shutdown /s /f /t 30
    GOTO end
    :instructions
    ECHO Usage: rsla SERVER-NAME    (you will be prompted for a password)
    :end
    

Links...

share|improve this answer
    
very thorough. I am modding this up as well. Also check out this guy's page of batch files using different utilities. He is very thorough as well. This guy's page is a resource managing Winboxen should bookmark. I run into every time I need something useful, complicated, or both. –  ajstein Jul 21 '10 at 23:32

Powershell:

$cred = get-credential Domain\AdminAccount
(gwmi -co %Computername% Win32_OperatingSystem -cr $cred).Shutdown()
share|improve this answer

Local account:

cmd /k wmic /node:"targetcomputerhostname" /user:"AdministratororWhatever" os where primary=true call reboot

AD account with local admin privileges:

cmd /k wmic /node:"targetcomputerhostname" /user:"DomainAccountWithAdminPrivs@fqdn" os where primary=true call reboot

This is easily portable as a batch file. Keep in mind you will need the proper remote exceptioins. If psshutdown works, this ought to work as well without installing any external software (not to dis SysInternals tools, the one thing Windows I swear by).

share|improve this answer
    
Hmmm... You do like WMIC! ;) –  joeqwerty Jul 21 '10 at 16:59
    
In some cases, WMIC is very valuable. In this case - not so much. –  MDMarra Jul 21 '10 at 20:47
    
Extremely ugly, unintuitive and hard to remember. Doesn't really have a lot going for it, does it? –  John Gardeniers Jul 21 '10 at 21:44
    
Say what you want, but is a) pre-installed on XP and b) allows me to avoid using UAC and/or runas when one of my domain accounts is different from the logon session on my computer. Judging by the fact that I got 0 votes, I guess beauty is more important than pragmatism for some. If I had my guess, judging by parameters available, shutdown and things like PsShutdown use the same API calls as WMIC to accomplish it anyway. But hey, I digress. –  ajstein Jul 21 '10 at 23:30
    
+1. One man's trash is another man's treasure. Your method gets the job done, which was the point of the question "How can I do this". –  joeqwerty Jul 22 '10 at 0:56

If you didn't need to specify credentials, you could use the SHUTDOWN command. If you do need to specify credentials (your login doesn't have permissions, or the computer isn't on the domain), you can use the PSSHUTDOWN utility to do this.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.