dseaver
IS-IT--Management
- Jul 13, 2006
- 467
I created a script to load call a process to restore a backup, wait until that backup is done, then reset the computer. I wanted to put a counter on the screen that's shown while the backup is restore (using HTA), but I am having difficulty, here is what I have so far
The problem is that it does not wait 10 seconds before it queries again, it just does it continuously. Any help is greatly appreciated
Code:
<html>
<HTA:APPLICATION ID="oMyApp"
APPLICATIONNAME="Restore"
BORDER="none"
CAPTION="no"
SHOWINTASKBAR="no"
SINGLEINSTANCE="yes"
SYSMENU="yes"
WINDOWSTATE="maximize">
<script language = "VBScript">
Sub Restore_onclick
MsgBox "Are you sure you want to restore the environment? The C:\ Drive will be restored, and data not stored on the D:\ Drive will be lost", VBOKCancel + vbDefaultButton2 + vbExclamation, "Test"
Dim MyObj
Set MyObj=CreateObject("WScript.Shell")
'MyObj.Run """E:\program files\acronis\trueimageworkstation\trueimagecmd.exe"" /filerestore /filename:""E:\Backup.tib"""
DataArea.InnerHTML = "Do not close any windows or use this station. It will reboot as soon as the C: Drive is restored"
idTimer = window.setTimeout("CheckForRestore", 5000, "VBScript")
End Sub
Sub CheckForRestore
Dim myDateString
myDateString = Time()
Dim i
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\cimv2")
Set colProcess = objWMIService.ExecQuery _
("Select Name from Win32_Process Where Name = 'trueimagecmd.exe'")
For Each objProcess in colProcess
i = 1
Next
if i = 0 Then
Call Cancel_onclick()
end if
Do While i = 1
idTimer2 = window.setTimeout("Pause", 10000, "VBScript")
i = 0
Set colProcess2 = objWMIService.ExecQuery _
("Select Name from Win32_Process Where Name = 'trueimagecmd.exe'")
For Each objProcess2 in colProcess2
i = 1
Next
if i = 0 Then
Call Cancel_onclick()
end if
MsgBox DateDiff("n", myDateString, Time) & ":" & DateDiff("s", myDateString, Time)
Loop
End Sub
Sub Pause
End Sub
Sub Cancel_onclick
'Set WSHShell = WScript.CreateObject("WScript.Shell")
'WshShell.Run "C:\WINDOWS\system32\shutdown.exe -r -t 0"
self.Close
End Sub
</script>
<body onLoad="window.focus()" onBlur="window.focus()">
<p>
<font size='36' color='red'>
<br>
<br>
<br>
<br>
<center>
<span id = "DataArea">
Message with buttons
<INPUT TYPE="BUTTON" NAME="Restore" VALUE="Restore Environment">
<INPUT TYPE="BUTTON" NAME="Cancel" VALUE="Cancel">
</span>
<br>
<span id = "CounterArea"></span>
</center>
</font>
</p>
</body>
</html>
The problem is that it does not wait 10 seconds before it queries again, it just does it continuously. Any help is greatly appreciated