Solved

Remote Shutdown with batch file for Windows 7

Posted on 2011-09-21
7
1,193 Views
Last Modified: 2012-05-12
I used to have a few batch files that I could execute that would use PSshutdown to reboot or shut down a load of computers. It worked flawlessly and was simple. Basically, a .bat file with a series of these commands:

psshutdown \\computername -r -f -n 30

It did the trick. However it does not work in Windows 7. I would like an equally simple way of doing this for windows 7 if possible, to be run from a batch or vbscript? I tried using the shutdown command in the same way...I created a .bat script with these entries:

shutdown -r -f -m \\S4-01
shutdown -r -f -m \\S4-02
shutdown -r -f -m \\S4-03
etc...

But it won't work. It says that either the name is not valid or remote shutdown is not supported (Error 53).
Thanks
0
Comment
Question by:Jason210
7 Comments
 
LVL 11

Author Comment

by:Jason210
ID: 36576147
I just tried to connect to the target computers via RDP and I can't. I think are either off, or in some kind of hibernation mode and I can't wake them up. I think this might be the problem.

In the meantime, is that ^^ batch script ok?
0
 
LVL 77

Accepted Solution

by:
arnold earned 100 total points
ID: 36576258
that is a valid option for shutdown.

if the system is no up and accessible, those directives will not be received.  You may have to configure those systems for the magic packet as a wakeup, and you would need  to maintain the MAC addresses since this is the destination for the magic packet (WOL).

Configure the systems not to hibernate/sleep and disconnect/shutdown the network interface.
0
 
LVL 6

Assisted Solution

by:tmwsiy
tmwsiy earned 100 total points
ID: 36576293
shutdown /r /f /m \\S4-01 /t 0

the /t 0 is your problem I think
0
ScreenConnect 6.0 Free Trial

Explore all the enhancements in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

 
LVL 24

Assisted Solution

by:Lionel MM
Lionel MM earned 200 total points
ID: 36580040
Those are valid commands, even in Windows 7
shutdown -r -f -m \\S4-01
if you don't put a time (-t) it defaults to 60 seconds (1 minute)
So it is more than likely an issue of permissions and/or rights
What error do you get when you run this command and how are you running the commands?
0
 
LVL 11

Author Comment

by:Jason210
ID: 36582978
I ran the commands both as batch scripts and also from command line on the Domain controller. I didn't get a persmissions error. I think the problem is the target computers are in hibernation and not responding, because after I tried to reboot them I tried other ways of communication such as RDP service and that didn't respond either.
0
 
LVL 24

Assisted Solution

by:Lionel MM
Lionel MM earned 200 total points
ID: 36583810
If the PCs are in hibernation then the commands will not work until you get them running again. To that end this link may help you to get the PCs out of hibernation:
http://www.experts-exchange.com/OS/Microsoft_Operating_Systems/Windows/Windows_7/Q_26699517.html?sfQueryTermInfo=1+10+30+7+from+hibern+pc+wake+window

Obviously you can change the PC setting for them not to go into hibernation.
Control Panel\All Control Panel Items\Power Options
0
 
LVL 66

Assisted Solution

by:johnb6767
johnb6767 earned 100 total points
ID: 36584691
Try this on a single machine.....

REM the "-i X" specifies Session # at the console.

psexec \\computername -i 1 shutdown -f -r -n 30

This very well could be a Session 0 isolation issue. More conversation on this here....

psshutdown - No message displayed
http://forum.sysinternals.com/psshutdown-no-message-displayed_topic21119.html
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Citrix XenApp, Internet Explorer 11 set to Enterprise Mode and using central hosted sites.xml file.
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question