Solved Shutdown In Batch job - Stop Reboot of My PC

November 30, 2011 at 06:32:41
Specs: Windows XP
I reboot PCs using shutdown.exe and a .txt file.

I use the "for /f" command.
The list of PCs to reboot is in a.txt file.

I run the .cmd file from my PC.

The .cmd file reboots all the PCs that are listed in the .txt file.

Now the problem - the .cmd file reboots my PC as well, even though it is not listed in the .txt file - (I'd like to stop this happening).

Can someone please look at the file, (pasted below) & tell me how to stop the .cmd file rebooting my PC ie. the machine where the ,cmd file is processed.

Rem Reboot.cmd
@echo off

for /f %%i in (RebootPCs.txt) do call :ACTIONS %%i

:ACTIONS

shutdown.exe -r -f -m \\%1
---- oOo ----
Thanks in advance for your help.
kind Regards
George Kennedy - NIHE.


See More: Shutdown In Batch job - Stop Reboot of My PC

Report •


#1
November 30, 2011 at 07:10:22
✔ Best Answer
Rem Reboot.cmd
@echo off
for /f %%i in (RebootPCs.txt) do call :ACTIONS %%i
GOTO :EOF

:ACTIONS
shutdown.exe -r -f -m \\%1
GOTO :EOF

or better

Rem Reboot.cmd
@echo off
for /f %%i in (RebootPCs.txt) do shutdown.exe -r -f -m \\%%i

The above has nothing to do with DOS (that is no more accesible in XP) but Ntbatch. Better you suffix a batch .bat since .cmd is a OS/2 legacy.


Report •

#2
November 30, 2011 at 07:32:29
Thanks IVO

I've tested your second suggestion.

Absolutely brilliant !!! Exactly what I was looking for.

I'm going to save this forum in my Favs....

Thanks again for your excellent advice.

Kind Regards
George Kennedy
NIHE Belfast


Report •

Related Solutions


Ask Question