For large organizations, occasionally you’ll need to perform a remote restart of all of the PC’s on your network. This could be for a variety of reasons — updates, database crashes and/or security updates. To easily perform this, you can use VBScript to restart remote computers quickly and efficiently.
I stumbled upon this really cool script posting on SpiceWorks detailing how to use VBScript to restart remote computers on your network.
This VBScript that resets remote computes is nice because it gives the user a 5 minute warning. Per the script author, you just list the computers in a .txt files and can restart or shutdown the computers based on the commands you give:
This script reads a text file populated with computer names and performs the remote shutdown command on them. In the script as-is, the computers will restart after 5 minutes (300 seconds), and display a warning to any users currently logged on to save their work before their computer automatically restarts. Of course, the delay and message can be changed, and if you want the script to instead shutdown, replace the “-r” switch with “-s”. Create a text file with one computer name on each line and change the “C:\computers.txt” part of the script to match the path and filename of the text file. — Sam “skrysiak” Krysiak
VBScript to Restart Computers — Please Review Code Carefully Before Use
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
'close the text file
Thanks a lot to Sam Krysiak for helping out the community with some great code on using VBScript to restart remote computers.
Looking for File Storage and Management?
With SmartFile, you improve file governance, management and access for the files exchanged and stored by your organization — no matter where they’re located. Get a quote and learn more!
SmartFile rose above the competition with an amazingly intuitive web interface, simplicity of workflow, and ability to create custom branded front-end. SmartFile was deployed and customized quickly, user training ended up being unnecessary.”