Set WSHShell = WScript.CreateObject("WScript.Shell")
Set oFS = CreateObject("Scripting.FileSystemObject...
strWarning = "Due to network maintenance, this computer must be restarted. You have 5 minutes to save your work from the start of this countdown. Sorry for any inconvenience caused. "
strDelay = 300 'Delay given in seconds; change this value to your preference, or set it to 0 to give no delay at all
'Open a text file of computer names
'with one computer name per line
Set oTS = oFS.OpenTextFile("C:\computers.txt")
'go through the text file
Do Until oTS.AtEndOfStream
'get the next computer name
'store it in variable strCompname
strCompname = oTS.ReadLine
WshShell.Run "C:\Windows\System32\shutdown.exe -m \\" & strCompname & " -r -c " & Chr(34) & strWarning & Chr(34) & " -t " & strDelay 'Replace the "-r" switch with "-s" to make the computers shutdown instead
Loop
'close the text file
oTS.Close
for /F "delims=" %%a in ('net view^|find "\\"') do shutdown -r -t 300 -f -m %%a
I'm aware of the shutdown /i command with will give me a GUI interface, but that uses more time then me programming a script to run that will cause all computers on the network to restart themselves. The command I have is
get-content .\computer_names.txt | foreach-object {shutdown /r /t 300 /f}
But each time it runs it only restarts the computer I'm using which isn't on the list. What should be added to make this command work?