I am new to scripting and batch files in general. My goal is to shutdown a network of 2000 or so computers. I want to ping before shutting down to avoid a delay.
The first batch file (shutdown_list)will have the names of the computers and run the second batch file (shutdown_single)with the ping and shutdown.exe.
The problem I am having is the second batch file will not pick up the computer names from the first.
Any help will be appreciated.
shutdown_list.bat:
shutdown_single ad-dao-bm-03.casd
shutdown_single ad-dao-bm-04.casd
shutdown_single ad-dao-bm-05.casd
shutdown_single.bat:
@echo off
MachineName=%1
ping -n 1 -w 800 %MachineName%if not errorlevel 1 goto MachineOKecho Cannot ping machine %MachineName%. Aborting.goto Fini:MachineOK
shutdown.exe -s -f -m %MachineName% -t 60 -c "Daily shutdown, please save any work and shut down again if restarted."
:Fini
network remote shutdown batch files
Forum rules
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
- mike pittenger
- Posts: 1
- Last visit: Sun Jan 20, 2008 11:43 pm
network remote shutdown batch files
Change MachineName=%1toset MachineName=%1Or forgo adding another variable and simply use %1 instead of %machinename%
- imperialxt
- Posts: 3
- Last visit: Thu Apr 17, 2008 3:17 am
network remote shutdown batch files
hey i'm rather new to this stuff i'm still a studentbut i'm curious if there is a way that i can get my shutdown bat file to prompt for which computer on the network i want to shutdown so it would like pop up and say insert name of computer and i would type "Computer1"any suggestions?
- imperialxt
- Posts: 3
- Last visit: Thu Apr 17, 2008 3:17 am
network remote shutdown batch files
thanks that will come in handy i'm sure. I'm very interested in this type of scripting aka vbs any suggestions as to where a good place to learn it might be ?.
- imperialxt
- Posts: 3
- Last visit: Thu Apr 17, 2008 3:17 am
network remote shutdown batch files
thanks that looks like it will be very good also is there a slight addition i can make to the script that will make it shutdown all computers ? or do i need to list all the computers as above ?
- felimclarke
- Posts: 1
- Last visit: Wed May 26, 2010 11:49 pm
network remote shutdown batch files
Hey,
Sorry to bother you but I am having a few problems with the script/batch file listed above if you could maybe point me in the right direction to getting to working please. I can get it working in on the 1st computer in the list but then it finishes running it doesn't move on to the next PC in the list.
As with mike
Sorry to bother you but I am having a few problems with the script/batch file listed above if you could maybe point me in the right direction to getting to working please. I can get it working in on the 1st computer in the list but then it finishes running it doesn't move on to the next PC in the list.
As with mike
network remote shutdown batch files
Try this:
for /F %i in (servers.txt) do
shutdown.exe -s -f -m %i -t 60 -c "Daily shutdown, please save any work and shut down again if restarted."
All on one line.
If in a batch file use double % signs.
for /F %i in (servers.txt) do
shutdown.exe -s -f -m %i -t 60 -c "Daily shutdown, please save any work and shut down again if restarted."
All on one line.
If in a batch file use double % signs.