Hi,
I found this vbscript on Symantec Connect. It prompts the user to restart after a installation. Can this be tweaked so that it will continually prompt the user every 5 minutes to restart until they do so?
Dim WSHShell, fso, prodir, strKeyPath
Dim path, i, dpath
Dim strComputer
Dim strDirectory, sScriptDir
'CHANGE THE APPLICATION NAME HERE
Dim sTitle: sTitle = "My Application"
Dim sLogHeader : sLogHeader = sTitle & VbCrLf
strComputer = "."
Set objShell = CreateObject("WScript.Shell")
Set fso = CreateObject("Scripting.FileSystemObject")
'GET CURRENT/SOURCE FOLDER PATH
sScriptDir = fso.GetParentFolderName(WScript.ScriptFullName)
If Right(sScriptDir,1) <> "\" Then sScriptDir = sScriptDir & "\"
'CHNAGE THE NAME OF THE EXECUTABLE HERE Ex: 7-zip.msi
If fso.FileExists(sScriptDir & "Setup.msi") Then
'SPECIFY COMMANDLINE PARAMETERS HERE Ex: /quiet /norestart
path = Chr(34) & sScriptDir & "Setup.msi" & Chr(34) & " /QB!"
i = 0
i = objShell.Run(path, 1 ,True)
If (i = 0) Or (i = 3010) Then
'WRITE THE RESULT TO EVENT LOG
objShell.LogEvent vbLogSuccess, sLogHeader & "Installation completed successfully." & VbCrLf & _
"Exit code: " & i
'DISPLAY MESSAGE TO THE USER WITH TIMEOUT OF 60 MINUTES
'YOU CAN CHANGE THE TIMEOUT ACCORDING TO YOUR REQUIREMENT HERE [60 mins = 3600 secs]
objShell.Popup sTitle & " installation completed successfully!" & VbCrLf & _
"You must reboot your computer as soon as possible." & VbCrLf & _
3600, sTitle, vbExclamation+vbOKOnly+vbSystemModal
'SHUTDOWN MESSAGE BOX WITH 60 SECONDS TIMEOUT [IF THE USER IS NOT RESPONDING TO THE ABOVE MESSAGE]
'YOU CAN CHANGE THE TIMEOUT ACCORDING TO YOUR REQUIREMENT HERE [60]
strShutdown = "shutdown -s -t 60 -f -m \\" & strComputer
objShell.Run strShutdown
Set objShell = Nothing
Set fso = Nothing
WScript.Quit(i)
Else
objShell.LogEvent vbLogError, sLogHeader & _
"Installation returned failure code: " & i
WScript.Quit(i)
End If
Else
'UNABLE TO FIND THE SOURCE FILE
WScript.Quit (1)
End If
Thanks guys.
I found this vbscript on Symantec Connect. It prompts the user to restart after a installation. Can this be tweaked so that it will continually prompt the user every 5 minutes to restart until they do so?
Dim WSHShell, fso, prodir, strKeyPath
Dim path, i, dpath
Dim strComputer
Dim strDirectory, sScriptDir
'CHANGE THE APPLICATION NAME HERE
Dim sTitle: sTitle = "My Application"
Dim sLogHeader : sLogHeader = sTitle & VbCrLf
strComputer = "."
Set objShell = CreateObject("WScript.Shell")
Set fso = CreateObject("Scripting.FileSystemObject")
'GET CURRENT/SOURCE FOLDER PATH
sScriptDir = fso.GetParentFolderName(WScript.ScriptFullName)
If Right(sScriptDir,1) <> "\" Then sScriptDir = sScriptDir & "\"
'CHNAGE THE NAME OF THE EXECUTABLE HERE Ex: 7-zip.msi
If fso.FileExists(sScriptDir & "Setup.msi") Then
'SPECIFY COMMANDLINE PARAMETERS HERE Ex: /quiet /norestart
path = Chr(34) & sScriptDir & "Setup.msi" & Chr(34) & " /QB!"
i = 0
i = objShell.Run(path, 1 ,True)
If (i = 0) Or (i = 3010) Then
'WRITE THE RESULT TO EVENT LOG
objShell.LogEvent vbLogSuccess, sLogHeader & "Installation completed successfully." & VbCrLf & _
"Exit code: " & i
'DISPLAY MESSAGE TO THE USER WITH TIMEOUT OF 60 MINUTES
'YOU CAN CHANGE THE TIMEOUT ACCORDING TO YOUR REQUIREMENT HERE [60 mins = 3600 secs]
objShell.Popup sTitle & " installation completed successfully!" & VbCrLf & _
"You must reboot your computer as soon as possible." & VbCrLf & _
3600, sTitle, vbExclamation+vbOKOnly+vbSystemModal
'SHUTDOWN MESSAGE BOX WITH 60 SECONDS TIMEOUT [IF THE USER IS NOT RESPONDING TO THE ABOVE MESSAGE]
'YOU CAN CHANGE THE TIMEOUT ACCORDING TO YOUR REQUIREMENT HERE [60]
strShutdown = "shutdown -s -t 60 -f -m \\" & strComputer
objShell.Run strShutdown
Set objShell = Nothing
Set fso = Nothing
WScript.Quit(i)
Else
objShell.LogEvent vbLogError, sLogHeader & _
"Installation returned failure code: " & i
WScript.Quit(i)
End If
Else
'UNABLE TO FIND THE SOURCE FILE
WScript.Quit (1)
End If
Thanks guys.