wmlau

Member
  • Content count

    5
  • Joined

  • Last visited

Community Reputation

0 Neutral

About wmlau

Profile Information

  • OS
    none specified
  1. Thanks Tripredacus. I got it working now, just switch the order of progrress. sub prog() Dim objWMIService, objFSO, objShell, colFileList dim indic Set indic = document.getElementById("indicator") if actualprogress > maxprogress then window.clearInterval(iTimerID2) exit sub else actualprogress = actualprogress + 1 indic.style.width = actualprogress Document.getElementById("DynamicText").innerHTML = text4 document.body.bgColor="6CA870" End if End sub
  2. I've tried with the Exit Sub. That don't work. Also tried with a sub funtion to stop the timer. All with the same result, the progress bar would not stop at the end of timer or at max count. sub StopTimer window.clearInterval(iTimerID2) end sub
  3. Thank you for the quick reply. We do have something in that nature, however, they want something with a button to click on and inform every step of the way and also a count down clock to give them time to save any works before we force close the dependence applications in a single GUI. I can't think of any better than HTA, this will have message, button, progress bar and using the innerHTML to show the steps take place.
  4. hi, I am new at scripting in HTA. I've created this hta to give user an interface and show the progress of an application during its installation from start to finish. We typically deploy application silently, lately our management wants to show the installation in a single interface. My script is to deploy the applicaion with this hta front end to display the progress while monitor a specified process is running "setup.exe" and show each step of the way. The progress bar is working, however, it does not know when to stop. I tried both clearinterval and cleartimeout window.clearInterval(iTimerID2) window.clearTimeout(iTimerID2) It is not working. Any help or suggestion is appreciated. What I would like the script to do is to stop the progress bar when the maxprogress is reach or when the setup.exe is finished. here is the code: <html> <head> <HTA:APPLICATION ID="porgbar" APPLICATIONNAME="MyApp Installation" BORDER="thin" BORDERSTYLE="normal" CAPTION="yes" MAXIMIZEBUTTON="no" MINIMIZEBUTTON="no" SHOWINTASKBAR="yes" SINGLEINSTANCE="yes" SYSMENU="yes" VERSION="1.0" /> <style type="text/css"> <!-- #barreprog { position:absolute; left: 50%; right: 25%; width:700px; margin-left: -350px; height: 1em; bottom: 15%; padding:2px; background-color:white; border:1px solid black; } #indicator{ width:0px; height: 1em; background-color:C06A45; } //--> <title>MyApp Installation</title> BODY {font-family: Trebuchet MS, Helvetica, Arial; font-size: 14pt; color: black } </style> </head> <body> <h2 style="text-align:center;">MyApp installation process has started</h2> <hr style="width:75%; color: navy;"/> <DIV ALIGN=CENTER> <p><font size="5">Please save your work and close all applications before clicking <b>“Install Now.”</b></font></p> <p><font size="5"><i>This process should take approximately 40 minutes to complete. Please do not attempt to launch any applications during this time.</i></font></p> </DIV> <div id="DynamicText" style="text-align: center; color:red; font-weight: bold; font-size:25px"> <p> </p> </div> <div id="InstallButton" style="visibility: hidden;"> <p style="text-align: center;"><input type="button" id="InstallNow" value="Install Now"></p> </div> <script language="VBScript"> ' Count Down Code ' Declare global variable outside of the Subs Option Explicit Dim strComputer, strProcess Dim iRefreshRt, maxprogress, actualprogress Dim text1, text2, text3, text4 Dim intMinutes, intSeconds Dim iTimerID Dim iTimerID1 Dim iTimerID2 iRefreshRt = 15000 maxprogress = 500 actualprogress = 0 strComputer = "." strProcess = "setup.exe" text1 = "Now processing you request..." text2 = "Now remove previous version..." text3 = "Now removing and installing..." text4 = "Installation complete..." intMinutes = 1 intSeconds = 01 Sub Window_onLoad window.ResizeTo 900, 450 window.MoveTo ((Screen.Width / 2) - (900 / 2)),((Screen.Height / 2) - (450 / 2)) ' Set the minutes and seconds iTimerID1 = window.setInterval("Countdown", 1000, "VBScript") DynamicText.innerHTML = intMinutes & "min:" & Right("00" & intSeconds, 2) & "s" InstallButton.Style.Visibility = "visible" document.body.bgColor="E9F1EA" End Sub Sub Countdown DynamicText.innerHTML = intMinutes & "min:" & Right("00" & intSeconds, 2) & "s" If intSeconds = 0 Then ' Install auotmatically after time expires If intMinutes = 0 Then InstallNow.Click Else intMinutes = intMinutes - 1 intSeconds = 59 DynamicText.innerHTML = intMinutes & "min:" & Right("00" & intSeconds, 2) & "s" End If Else intSeconds = intSeconds - 1 DynamicText.innerHTML = intMinutes & "min:" & Right("00" & intSeconds, 2) & "s" End If End Sub ' On Click the install button Sub InstallNow_onClick() dim oShell, objFSo set oShell = CreateObject("WScript.Shell") oShell.RegWrite "HKCU\Software\MyApp\Time", "now" , "REG_SZ" oShell.RegWrite "HKCU\Software\MyApp\Date", cstr(date) , "REG_SZ" Set oShell = nothing set objFSo = CreateObject("Scripting.FileSystemObject") If objFSo.fileExists("C:\MsgFlag.txt") then objFSo.DeleteFile("C:\MsgFlag.txt") End If Set objFSo = nothing If InstallNow.Value = "Install Now" Then Window.clearTimeout(iTimerID1) InstallNow.disabled = True Document.getElementById("DynamicText").innerHTML = text1 ' DynamicText.innerHTML = "Now processing you request..." InstallNow.Value = "In Progress" Call ProcessStatus iTimerID = window.setInterval("UpdateStatus", iRefreshRt) 'Set timer ONCE document.body.bgColor="C9DECB" End If End Sub Sub UpdateStatus Dim ProcessStat ProcessStat = ProcessStatus End Sub Function ProcessStatus Dim objWMIService, colProcesses, objProcess, objProgram Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") Set colProcesses = objWMIService.ExecQuery _ ("Select * from Win32_Process Where Name = '" & strProcess & "'") If colProcesses.Count > 0 Then ProcessStatus = "Running" document.body.bgColor="B4D1B6" Do Until colProcesses.Count = 0 ' MsgBox strProcess & " is running." Document.getElementById("DynamicText").innerHTML = text3 ' DynamicText.innerHTML = "Now removing and installing..." Call StartProg Exit Do Loop Else window.clearInterval(iTimerID2) InstallNow.Value = "In Progress" document.body.bgColor="C9DECB" ' Document.getElementById("DynamicText").innerHTML = text4 End IF End Function Function iTimer (TimeCheck) iTimer = 60000 * TimeCheck 'Ensure numeric End Function sub StartProg() iTimerID2 = setInterval("prog", 10000, "vbscript") end sub sub prog() Dim objWMIService, objFSO, objShell, colFileList dim indic Set indic = document.getElementById("indicator") actualprogress = actualprogress + 1 indic.style.width = actualprogress if actualprogress > maxprogress then window.clearInterval(iTimerID2) Document.getElementById("DynamicText").innerHTML = text4 document.body.bgColor="6CA870" End if End sub </script> <div id="barreprog"> <div id="indicator"> </div> </div> </head> <div id="Progress"> </div> </body> </html>