network remote shutdown batch files

Batch, ASP, JScript, Kixtart, etc.
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.
This topic is 13 years and 10 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
mike pittenger
Posts: 1
Last visit: Sun Jan 20, 2008 11:43 pm

network remote shutdown batch files

Post by mike pittenger »

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
User avatar
jhicks
Posts: 1789
Last visit: Mon Oct 19, 2015 9:21 am

network remote shutdown batch files

Post by jhicks »

Change MachineName=%1toset MachineName=%1Or forgo adding another variable and simply use %1 instead of %machinename%
User avatar
imperialxt
Posts: 3
Last visit: Thu Apr 17, 2008 3:17 am

network remote shutdown batch files

Post by imperialxt »

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?
User avatar
imperialxt
Posts: 3
Last visit: Thu Apr 17, 2008 3:17 am

network remote shutdown batch files

Post by imperialxt »

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 ?.
User avatar
imperialxt
Posts: 3
Last visit: Thu Apr 17, 2008 3:17 am

network remote shutdown batch files

Post by imperialxt »

thanks that looks like it will be very good :Palso 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 ?
User avatar
felimclarke
Posts: 1
Last visit: Wed May 26, 2010 11:49 pm

network remote shutdown batch files

Post by felimclarke »

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
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

network remote shutdown batch files

Post by jvierra »

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.

This topic is 13 years and 10 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked