Tech Support Guy banner
Status
Not open for further replies.

Solved: Shutdown DOS batch script

1 reading
8.2K views 13 replies 2 participants last post by  jp1203  
#1 ·
I have absolutely no idea where to put this, so I just picked a place. If anyone thinks there's a better spot for it, have it moved there please :D

My intentions: to make a DOS batch script that will shut down four machines, then to set it as a scheduled task running at, say, 1 AM

The Problem:
I type something in DOS:

shutdown -s -m \\computername -c "This machine will shut down in two minutes To cancel click the abort shutdown icon on your desktop" -t 120 -f

It works, the remote machine displays a warning and a countdown timer. I have an icon on their desktop that is a batch script with contents:

shutdown -a

to abort the shutdown if someone is on the machine at 1 AM.


If I copy the same script (the shut down one) into notepad save and run the batch file, it goes into this endless loop and does nothing. Anyone know why?

I've attached a screenshot of the running batch script in its endless loop"
 

Attachments

#2 ·
Can you put the contents of your batch script in CODE tags please? Maybe i can help you out. :up:
 
Save
#3 ·
Changed it slightly with some echo tags, that's all. Still obviously no go.

Code:
@echo off
echo Starting Shutdown Process...
echo Shutting Down Stergis2
shutdown -s -m \\computername -c "This machine will shut down in two minutes To cancel click the abort shutdown icon on your desktop" -t 120 -f
echo Script Complete.
 

Attachments

#4 ·
Ok let me ask this- Are you sure shutdown.exe is on your PC? and the remote pc? cos iytmay need it, and there might be a setting on the remote computer that allows it to be shut down remotely.
 
Save
#5 ·
I imagine so, because if I just open cmd and type this it works fine and the other machine shows a message for two minutes and shuts down. It's just the script that won't work for some weird reason:

shutdown -s -m \\computername -c "This machine will shut down in two minutes To cancel click the abort shutdown icon on your desktop" -t 120 -f
 
#6 ·
:3 I have a neato idea. but first lemme ask you. would you be willing to use something other than shutdown.exe to shutdown other pc's?
 
Save
#8 ·
two things.

PsShutdown from Sysinternals - Now owned by microsoft..

http://www.microsoft.com/technet/sysinternals/Utilities/PsShutdown.mspx

doesnt require anything installed on the client.

but if you're a little adventurous, check this out.

http://users.pandora.be/jbosman/applications.html

you dont 'need' to install it on the remote pc, but if you dont you cant do any of the fancy things like standby and hibernate..or turning a monitor off.. xD
but pwroff can do things by a scheduling them, and things can be done by command line, as well as remotely by command line. i wouldnt recommend it if you're looking for an easy solution, but its a fun program.
 
Save
#10 ·
you ought to check out the sysinternals suite in my sig. very useful tools in der. :)
But dont get carried away, you can fry your PC with some of that stuff.
but yea, tell me how poweroff goes, i love that thing xD
 
Save
#11 ·
I use newsid from Sysinternals for mass imaging stuff so the SID and puter name are different for every box. Haven't really played with the rest of the stuff too much, I'll have to do that when I have some time to kill. I had a guy working with me who decided that NewSID locked up (it just hit a massive file to change) and rebooted the machine manually. Had to reimage it again.

I scheduled poweroff to shut down a box at 1 AM with a 120 second warning, and started it as a service so we'll see what happens. I'll let you know.

Thanks again
 
#13 ·
When you make a scheduled task in pwroff, dont forget to 'Save Setting To Service'. :up:
And diskmon is for monitoring when your hard drive is read/written to. i find regmon more useful than that >_>'
 
Save
#14 ·
Apparently the service ran, when I unlocked this this morning I had a poweroff message that the client accepted the task and that machine is off.

Thanks
 
Status
Not open for further replies.
You have insufficient privileges to reply here.