Controlling a Progress Bar on a custom UI - Advanced Installer Community

We’re moving our forums to a new platform.

You can still browse and search existing topics, but you can no longer create new topics or post replies.

For questions, technical issues, or feature requests, please don’t hesitate to contact our support team at support@advancedinstaller.com.

Thank you for your understanding!

SamuelB
Posts: 4
Joined: Mon Oct 22, 2007 3:32 am

Controlling a Progress Bar on a custom UI

Hello,

I have advanced installer enterprise and am looking for a way to control a progress bar from within a vb script.

My current script takes some time to complete - (executed under a deferred custom action) and so I would like to update a progress bar while it is executed.

Thanks for any help,

Sam
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Hi,

There is an example for this type of custom action in the MSDN library, please take a look:
http://msdn2.microsoft.com/en-us/library/aa367525.aspx

You can modify this example to work for your project.

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
SamuelB
Posts: 4
Joined: Mon Oct 22, 2007 3:32 am

Hello again,

for anybody who is interested, here is the vbscript translation:
----------------------------------

const msiMessageTypeActionStart = &H08000000
const msiMessageTypeProgress = &H0A000000
const msiMessageTypeActionData = &H09000000

const iTickIncrement = 10000
const iNumberItems = 10

Dim iTotalTicks


dim oActionRec, oProgressRec, oActionData


Sub TestProgressBar

iTotalTicks = iTickIncrement * iNumberItems

if session.mode(16) then


set oProgressRec = session.Installer.createRecord(3)
oProgressRec.IntegerData(1) = 0
oProgressRec.IntegerData(2) = iTotalTicks
oProgressRec.IntegerData(3) = 0
session.message msiMessageTypeProgress, oProgressRec


' Installer is executing the installation script. Set up a
' record specifying appropriate templates and text for
' messages that will inform the user about what the custom
' action is doing. Tell the installer to use this template and
' text in progress messages.
set oActionRec = session.Installer.createRecord(3)
oActionRec.StringData(1) = "TestProgressBar" 'Action name
oActionRec.StringData(2) = "Incrementing the Progress Bar..." 'Description
oActionRec.StringData(3) = "Incrementing tick [1] of [2]" 'template for action data messages
session.message msiMessageTypeActionStart, oActionRec

' Tell the installer to use explicit progress messages.
oProgressRec.IntegerData(1) = 1 'reset
oProgressRec.IntegerData(2) = 1 'total ticks + 1
oProgressRec.IntegerData(3) = 0 'right to left
session.message msiMessageTypeProgress,oProgressRec

' Tell the installer to increment for each ActionData message
oProgressRec.IntegerData(1) = 2 'action info
oProgressRec.IntegerData(2) = iTickIncrement 'increment 1 tick per
oProgressRec.IntegerData(3) = 0 'increment 1 bar per tick
' session.message msiMessageTypeProgress,oProgressRec


' The following loop sets up the record needed by the action
' messages and tells the installer to send a message to update
' the progress bar.
' set oActionRec = session.Installer.createRecord(3)
oActionRec.IntegerData(2) = iTotalTicks

dim x

for x = 0 to iTotalTicks step iTickIncrement
MsgBox cstr(x)
oActionRec.IntegerData(1) = x

session.message msiMessageTypeActionData, oActionRec
session.message msiMessageTypeProgress, oProgressRec
next

MsgBox "Leaving TestProgressBar"

else

' Installer is generating the installation script of the custom action.
' Tell the installer to increase the value of the final total
' length of the progress bar by the total number of ticks in
' the custom action.

set oProgressRec = session.Installer.createRecord(2)
oProgressRec.IntegerData(1) = 3
oProgressRec.IntegerData(2) = iTotalTicks

session.message msiMessageTypeProgress, oProgressRec
end if

End Sub

-----------------------


other useful information can be found at:
http://msdn2.microsoft.com/en-us/library/aa367525.aspx
http://msdn2.microsoft.com/en-us/library/aa371614.aspx
http://msdn2.microsoft.com/en-us/library/aa370354.aspx


Note this example will reset and then increment the progress bar for the loop. I could not figure out:

A) how to extend the progress bar with additional ticks

i.e.:

set oProgressRec = session.Installer.createRecord(2)
oProgressRec.IntegerData(1) = 3
oProgressRec.IntegerData(2) = iTotalTicks
session.message msiMessageTypeProgress, oProgressRec

does not seem to make a difference

B) assign this control to a different progress bar object

Regards,
Sam
SamuelB
Posts: 4
Joined: Mon Oct 22, 2007 3:32 am

Hello,

Any ideas on how to assign this code to a different progress bar object?

Regards,
Sam.
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Hi,

I'm not sure how exactly this can be done.

Note that a progress bar subscribes to the SetProgress ControlEvent, but it can also subscribe to a ControlEvent named after the action being monitored.

You can try to edit the MSI with Orca and subscribe the second progress bar to a ControlEvent with the same name as your custom action.

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”