# Solved: Shutdown DOS batch script



## jp1203 (Jul 21, 2005)

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 

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"


----------



## dez_666 (May 30, 2007)

Can you put the contents of your batch script in CODE tags please? Maybe i can help you out. :up:


----------



## jp1203 (Jul 21, 2005)

Changed it slightly with some echo tags, that's all. Still obviously no go.


```
@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.
```


----------



## dez_666 (May 30, 2007)

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.


----------



## jp1203 (Jul 21, 2005)

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


----------



## dez_666 (May 30, 2007)

: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?


----------



## jp1203 (Jul 21, 2005)

So long as it isn't too bulky, probably.


----------



## dez_666 (May 30, 2007)

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.


----------



## jp1203 (Jul 21, 2005)

Cool, I'll have to try that Poweroff thing. I like to play 

Thanks Very Much


----------



## dez_666 (May 30, 2007)

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


----------



## jp1203 (Jul 21, 2005)

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


----------



## jp1203 (Jul 21, 2005)

I like the looks of diskmon, as I run this box as a small server. I'll have to play with that.


----------



## dez_666 (May 30, 2007)

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 >_>'


----------



## jp1203 (Jul 21, 2005)

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


----------

