Jump to content

Welcome to MSFN Forum
Register now to gain access to all of our features. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more. This message will be removed once you have signed in.
Login to Account Create an Account



Photo

progress bar for application install

- - - - -

  • Please log in to reply
8 replies to this topic

#1
wmlau

wmlau
  • Member
  • 5 posts
  • Joined 05-November 12
  • OS:none specified
  • Country: Country Flag
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>&nbsp;</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>

Edited by Tripredacus, 06 November 2012 - 09:23 AM.



How to remove advertisement from MSFN

#2
Tripredacus

Tripredacus

    K-Mart-ian Legend

  • Super Moderator
  • 9,847 posts
  • Joined 28-April 06
  • OS:Server 2012
  • Country: Country Flag

Donator

With my deployment app, I simply show an HTA during the install process to alert users that the installer is running. That way you don't have to worry about calculating times, etc. Also you need to watch out for installers that spawn msiexec.exe, since that can stay open in the background for 10 minutes.
MSFN RULES | GimageX HTA for PE 3-5 | lol probloms
msfn2_zpsc37c7153.jpg

#3
wmlau

wmlau
  • Member
  • 5 posts
  • Joined 05-November 12
  • OS:none specified
  • Country: Country Flag
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
Tripredacus

Tripredacus

    K-Mart-ian Legend

  • Super Moderator
  • 9,847 posts
  • Joined 28-April 06
  • OS:Server 2012
  • Country: Country Flag

Donator

I am looking at my HTA (see signature) which does not have a working progress bar... BUT it does go away after its work is done. I'm no master of VBScript, but I notice a difference between it and yours. Your progress routine doesn't have any exit command. For example:

Sub objWIM_Progress(Percent,TimeRemaining)
On Error Resume Next
objShell.Popup Percent, 1, "Title", -1
If Percent = 100 Then
progress.innerHTML = "<table border='0'><tr><td>Percents completed: </td><td>100 % </tr><tr><td>Time remaining: </td><td>0 min 0 sec</td></tr></table>"
Exit Sub
Else
Call ProgressHelper(Percent,TimeRemaining)
End If

See that Exit Sub part in there. :unsure:
MSFN RULES | GimageX HTA for PE 3-5 | lol probloms
msfn2_zpsc37c7153.jpg

#5
wmlau

wmlau
  • Member
  • 5 posts
  • Joined 05-November 12
  • OS:none specified
  • Country: Country Flag
Thanks Tripredacus.

I'll give that shot.

#6
wmlau

wmlau
  • Member
  • 5 posts
  • Joined 05-November 12
  • OS:none specified
  • Country: Country Flag
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

#7
wmlau

wmlau
  • Member
  • 5 posts
  • Joined 05-November 12
  • OS:none specified
  • Country: Country Flag
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

#8
vtlepshev

vtlepshev
  • Member
  • 1 posts
  • Joined 31-July 13
  • OS:Windows 7 x86
  • Country: Country Flag

Hey wmlau,

 

I was looking for an application like yours for a quite some time. this is a very helpful and usefull application.

One thing I cannot understand, what in the script I need change to let the script know that I am installing oovoo, basically, how the script knows about ooVooSetup.msi?

 

Thanks,

 



#9
Tripredacus

Tripredacus

    K-Mart-ian Legend

  • Super Moderator
  • 9,847 posts
  • Joined 28-April 06
  • OS:Server 2012
  • Country: Country Flag

Donator

That's a totally different thing than tracking Imagex. For installing an MSI file you need to look at msiexec.exe but you'll notice that process stays active for up to 10 minutes after completing the installation of the MSI file.


MSFN RULES | GimageX HTA for PE 3-5 | lol probloms
msfn2_zpsc37c7153.jpg




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users