Batch script

Man of Honour
Joined
17 Nov 2003
Posts
36,747
Location
Southampton, UK
I need a batch script that can input the contents a file for a variable.

Computers.txt
Computer1
Computer2
Computer3

Loop
Code:
psshutdown -k -f -c -t 200 %variable% -m "Press cancel if you are still working"

I just need the syntax to input the variables and iterate.

Thanks

Burnsy
 
Try this:

FOR /f %%a in (Computers.txt) DO psshutdown -k -f -c -t 200 %%a -m "Press cancel if you are still working"

Don't forget the \\ on the computer names either in the file or in the batch script.
 
Last edited:
I do it with two batch files. The main reason I do this is I have different batch files for different areas at work. Makes it easy to adjust PSShutdown, and it also means I can use the same batch files to initialise other scripts (I use PSExec a lot).

Off .bat

psshutdown -k -f -c -t 200 \\%1 -m "Press cancel if you are still working"

areaname.bat

For %%A In(list computer names) DO Call off %%A
 
Back
Top Bottom