I have a Script that will restart a Windows computer in Safe Mode.
This vbscript calls a BAT file that prompts a UAC elevation, and restarts the computer in safe mode.
Any suggestions on how to optimize this script? And can this work in Windows 8?
[code]Dim oShell, retCode
Set oShell = WScript.CreateObject("WScript.Shell")
Set objShell = CreateObject("Wscript.Shell")
retCode = oShell.Popup("Do you want to restart your computer in Safe Mode", 0, "Restart In SafeMode", 4 + 48)
Select Case retCode
case 6, -1
objShell.Run "elevaterestart.bat"
case 7
WScript.quit(1) 'No was chosen
End Select
Update: I updated the script, as suggested and added an Operation Canceled
popup if a user selects no
Dim oShell, retCode, MsgBox
Set oShell = WScript.CreateObject("WScript.Shell")
Set objShell = CreateObject("Wscript.Shell")
retCode = oShell.popup("Do you want to restart your computer in Safe Mode", 0, "Restart In Safe Mode", 4 + 48 + 256)
If retCode = 6 Or retCode = -1 Then
objShell.Run "elevaterestart.bat"
Else
oShell.popup "Operation Canceled", 0, "Restart In Safe Mode", 0 + 64 + 0
End If`