I have a system I inherited that used a simple psexec script and a list of servers to automatically shut down the servers in the list should a temperature threshold be reached or the UPS only has a few minutes of battery remaining. This was executed by AVTech Device Manager. It is no longer working (and likely has not since I have been here). If I execute the script manually from an administrative command prompt (Windows Server 2012 r2) I get this error
The filename, directory name, or volume label syntax is incorrect.
The script in question looks like this
c:\avtech\psexec @c:\avtech\scripts\serverlist.txt c:\windows\system32\shutdown.exe -s -f -t 0 >"c:\avtech\log\shutdownlog.txt 2>&1
and the serverlist.txt file is currently a file with just one entry
server.domain.local
If I substitute the actual server name for the serverlist.txt file it works fine
C:\Windows\system32>C:\AVTECH\psexec \\server.domain.local c:\windows\system32\shutdown.exe -s -f -t 0 >c:\shutdownLog.txt 2>&1
So it all works just fine if I don't have psexec grab from that list of servers. And, yes, the path to the list of servers is correct.
No doubt there is a simple and obvious error here somewhere but my experience with this kind of thing is pretty weak, any ideas?
Best Answer
Instead of fiddling around with psexec for this, why not just call shutdown.exe directly with the
/m
switch?You can even keep your list of servers in the same file by using a for command. See the for documentation if you want to use a non-default (space and tab) delimiter: