Set oShell = CreateObject("wscript.Shell")
nMinutes = 5
nSeconds = 0
sTitle = "Encryption Software"
Msg = "The " & sTitle & " installation has been completed successfully!" & vbCrLf & _
"Your laptop needs to be restarted so it can be encrypted. You should be able to go about your work as " & vbCrLf & _
"Your laptop will encrypt in the background. Would you like to restart now to begin the process?" & vbCrLf & _
"This message will continuously pop up every 5 minutes until a restart has taken place"
sMessage = "<font color=red size=3><b>"&Msg&"</b></font>"
' Open a chromeless window with message
with HTABox("lightBlue",250, 450, 400,100)
.document.title = sTitle & " Notification"
.msg.innerHTML = sMessage
do until .done.value or (nMinutes + nSeconds < 1)
.msg.innerHTML = sMessage & "<br>" & nMinutes & ":" & Right("0"&nSeconds, 2) _
& " remaining<br>"
wsh.sleep 1000 ' milliseconds
nSeconds = nSeconds - 1
if nSeconds < 0 then
if nMinutes > 0 then
nMinutes = nMinutes - 1
nSeconds = 59
end if
end if
loop
.done.value = true
.close
end with
'*********************************************** process goes here ...***********************************************************"
Do
varRestart = oShell.Popup ("The " & sTitle & " installation has been completed successfully!" & vbCrLf & _
"Your laptop needs to be restarted so it can be encrypted. You should be able to go about your work as " & vbCrLf & _
"Your laptop will encrypt in the background. Would you like to restart now to begin the process?" & vbCrLf & _
"This message will continuously pop up every 5 minutes until a restart has taken place",20, sTitle, vbExclamation+vbYesNo)
if varRestart = VbYes Then
'Msgbox " Restart Now ! ",48," Restart Now !"
Call Restart()
exit do
else
wscript.Sleep 300000 ' Sleep for 5 minutes
end if
Loop
'********************************************** script ends here ***************************************************************
Function HTABox(sBgColor, h, w, l, t)
Dim IE, HTA, sCmd, nRnd
randomize : nRnd = Int(1000000 * rnd)
sCmd = "mshta.exe ""javascript:{new " _
& "ActiveXObject(""InternetExplorer.Application"")" _
& ".PutProperty('" & nRnd & "',window);" _
& "window.resizeTo(" & w & "," & h & ");" _
& "window.moveTo(" & l & "," & t & ")}"""
Set WshShell = WScript.CreateObject("WScript.Shell")
with CreateObject("WScript.Shell")
.Run sCmd, 1, False
do until .AppActivate("javascript:{new ") : WSH.sleep 10 : loop
end with 'WSHShell
For Each IE In CreateObject("Shell.Application").windows
If IsObject(IE.GetProperty(nRnd)) Then
set HTABox = IE.GetProperty(nRnd)
IE.Quit
HTABox.document.title = "HTABox"
HTABox.document.write _
"<HTA:Application contextMenu=no border=thin " _
& "minimizebutton=no maximizebutton=no sysmenu=no />" _
& "<body scroll=no style='background-color:" _
& sBgColor & ";font:normal 10pt Arial;" _
& "border-Style:inset;border-Width:3px'" _
& "onbeforeunload='vbscript:if not done.value then " _
& "window.event.cancelBubble=true:" _
& "window.event.returnValue=false:" _
& "done.value=true:end if'>" _
& "<input type=hidden id=done value=false>" _
& "<center><span id=msg> </span><br>" _
& "<input type=button id=btn1 value=' Restart ' "_
& "onclick=done.value=true><center></body>"
HTABox.btn1.focus
Exit Function
End If
Next
MsgBox "HTA window not found."
wsh.quit
End Function
Sub Restart()
Attente = "60" ' wait for 1 min
Avertissement = "Your laptop needs to be restarted so it can be encrypted"
Command = "Cmd /c shutdown.exe -r -c " & dblquote(Avertissement) & " -t " & Attente & ""
Execution = oShell.Run(Command,0,True)
End Sub
Function dblquote(strIn)
dblquote = Chr(34) & strIn & Chr(34)
End Function