Solved

Remote Shutdown with batch file for Windows 7

Posted on 2011-09-21
7
1,191 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 76

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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 24

Assisted Solution

by:lionelmm
lionelmm 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:lionelmm
lionelmm 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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
This is an explanation of a simple data model to help parse a JSON feed
In this video, we discuss why the need for additional vertical screen space has become more important in recent years, namely, due to the transition in the marketplace of 4x3 computer screens to 16x9 and 16x10 screens (so-called widescreen format). …
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…

757 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now