Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need Help with loop until done 1

Status
Not open for further replies.

netjess

MIS
Feb 20, 2009
25
US
I am trying to check the state of an installation and loop a pop-up until the install check shows finished.
It currently runs without error but it only pops up once and then I can see in task manager that wscript is still running but I do not get any other pop-ups.
I have tried moving my "do" statement up in the script but then it errors.
I do not know how to make it loop the whole thing and launch the HTA window over again until it detects Office 2007.
I suspect it is just looping the "sleep"???
Here is what I have.
-----------------------------------------------------------
Set wshShell = WScript.CreateObject("WScript.Shell")
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
Set colSoftware = objWMIService.ExecQuery ("Select * from Win32_Product")
For Each objSoftware in colSoftware
If objSoftware.Caption = "Microsoft Office Enterprise 2007" Then
OfficeInstalled = True
End If
Next
If OfficeInstalled <> True Then
Set objShell = CreateObject("Wscript.Shell")
objShell.Run "warn.hta"

Do until OfficeInstalled = True
WScript.Sleep 60

Loop
End If
-----------------------------------------------------------
HTA Code:
<html>
<HTA:APPLICATION
SysMenu="no"
>

<script language = "VBScript">
Sub Window_OnLoad
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * From Win32_DesktopMonitor")
For Each objItem in colItems
intHorizontal = objItem.ScreenWidth
intVertical = objItem.ScreenHeight
Next
intLeft = (intHorizontal - 400) / 2
intTop = (intVertical - 250) / 2
window.resizeTo 400,250
window.moveTo intLeft, intTop
idTimer = window.setTimeout("PausedSection", 8000, "VBScript")
End Sub
Sub PausedSection
window.close
End Sub
</script>
<head>
<title>Office 2007</title>
</head>

<body><center>
<p>Please wait while Office 2007 is installed.<br>
<p>Your computer may reboot.</p>
</center></body>
</html>

-----------------------------------------------------------
 
What about this ?
Code:
Set wshShell = WScript.CreateObject("WScript.Shell")
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
Do
  Set colSoftware = objWMIService.ExecQuery ("Select * from Win32_Product")
  For Each objSoftware in colSoftware
    If objSoftware.Caption = "Microsoft Office Enterprise 2007" Then
      OfficeInstalled = True
      Exit For
    End If
  Next
  If OfficeInstalled <> True Then
    wshShell.Run "warn.hta"
    WScript.Sleep 60
  End If
Loop Until OfficeInstalled = True

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thanks, this seems to work. I still need to test it with the Office install to see if it detects it. I only had to modilfy the sleep time to 10000. that way my HTA lasted 8 seconds and the sleep lasts 10 seconds.

Thanks again.
 
Just to let you know. This worked out great. It looped until the install was finished. But did not loop on restart after O2K7 was installed.

Many thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top