If you’re trying to script a restart function for users, you’ll unfortunately find that shutdown.exe does not work for non-Administrators, nor does psshutdown. Shutdown.exe requires privileges for the shutdown process and psshutdown.exe requires privileges to add and start services.
One of many ways around this problem is to create a visual basic script. This also offers the functionality of allowing the user to abort the restart with a simple cancel button, a functionality which shutdown.exe lacks (unless your user runs shutdown.exe -a within the time limit).
Create a text document in Notepad or Notepad++ and paste in the following code. Save the file as restart.vbs. You may have to uncheck ‘hide extensions of known file types’ so that your file doesn’t end up named restart.vbs.txt and behave like a text file.
Const wshOK = 1
Const wshCancel = 2
Const wshvbOKCancel = 1
Set objShell = CreateObject("Wscript.Shell")
intReturn = objShell.Popup("System will restart in 5 seconds.",5, "System Restart", wshvbOKCancel)
If intReturn = wshCancel Then
Wscript.Quit
Else
strComputer = "localhost"
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate,(Shutdown)}!\" & _
strComputer & "rootcimv2")
Set colOperatingSystems = objWMIService.ExecQuery _
("Select * from Win32_OperatingSystem")
For Each objOperatingSystem in colOperatingSystems
objOperatingSystem.Reboot()
Next
End If
When a user clicks on on the script or a shortcut to the script it will launch a simple pop-up window that states: “System will restart in 5 seconds.” with an Ok button and a Cancel button. After 5 seconds the machine will restart. If you hit Ok, the machine will restart immediately. If you hit Cancel, the restart process will stop and the machine will go back to normal operation.