/build/static/layout/Breadcrumb_cap_w.png

Script to Remotely restart the computer

Hi Guys,

In our environment reboot is a major concerns on workstations resulting in non compliance. We need a script which will remotely reboot the workstation but we need to ensure that enduser after 5 log off and login or in hibernate mode once comes on on the 6 time even enduser tries to log off give a message to close all apllication and forcefully restart the machine.

Regards

Jai


0 Comments   [ + ] Show comments

Answers (4)

Answer Summary:
Posted by: aaronbaird1 12 years ago
White Belt
2

i use autohotkey to compile a exe, and then push it via psexec or a logon script.

MsgBox, 4144, Message From Administrator, Your Computer needs to restart. Please Press OK to restart now.
Shutdown, 6



The "4144" makes it so that the user can only press ok and it stays on top.  "Shutdown,6" restarts the computer without interuptions.
Then use psexec like so to push it to the user (assuming your admin on a domain)...

psexec.exe \\ComputerName -s -i -f -c C:\reboot.exe

where C:\reboot.exe is where you compiled your autohotkey script.

Posted by: sivhead 12 years ago
White Belt
0

You can download a pshutdown from microsoft (sysinternals).

http://technet.microsoft.com/en-us/sysinternals/bb897541.aspx

Posted by: sivhead 12 years ago
White Belt
0

If its a script you wanted then you can use the following

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

Don't be a Stranger!

Sign up today to participate, stay informed, earn points and establish a reputation for yourself!

Sign up! or login

Share

 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ