Percent Complete Property of IInstallationProgress

0 views
Skip to first unread message

Drew M

unread,
Jul 12, 2005, 10:32:10 PM7/12/05
to
I am wondering about correct usage for the percentcomplete property of the
IInstallationProgress interface for the Windows Update Agent API. For every
update that I have installed so far on a windows 2000 desktop via our WSUS
2.0 server the percent complete property correctly reports the installation
progress as I install updates, however for some reason when I install the
Windows 2000 Sp4 Network Install, the percent complete property never
updates. The installation does complete successfully, but since I don't get
any percent complete data I can't update the progress bar on the form that I
display to users. The CurrentUpdatePercentComplete has the same issue, works
great for just about every other update but not for Sp4. Is this a fluke in
the way that the Sp4 install reports it's progress, or something wrong with
my code. Here is some sample code......thanks for any thoughts!!!

'- Declare Variables ----
Dim UpdateInstaller As IUpdateInstaller =
Session.CreateUpdateInstaller
Dim InstallJob As IInstallationJob
Dim InstallResult As IUpdateInstallationResult
Dim IPCC As New Object
Dim ICC As New Object
Dim IJ As New Object
Dim InstallProgress As IInstallationProgress
Dim UpdatesToInstall As New UpdateCollection
Dim IPCtr, ICtr As Integer

'- Add update passed to the method to the UpdatesToInstall
collection ----
UpdatesToInstall.Add(Update)
'- Assign UpdatesToInstall to the UpdateInstaller updates
collection ----
UpdateInstaller.Updates = UpdatesToInstall
'- Begin the install job ----
InstallJob = UpdateInstaller.BeginInstall(IPCC, ICC, IJ)

'- Loop until the install begins, if install does not begin in
30 seconds throw an exception ----
Do
Threading.Thread.Sleep(100)
IPCtr = IPCtr + 1
If IPCtr >= 300 Then
Throw New Exception("Installation Start Timeout")
End If
InstallProgress = InstallJob.GetProgress()
InstallResult = InstallProgress.GetUpdateResult(0)
Loop Until InstallResult.ResultCode =
OperationResultCode.orcInProgress

'- Loop until the install is no longer inprogress ----
Do
InstallProgress = InstallJob.GetProgress()
InstallResult = InstallProgress.GetUpdateResult(0)
'- increment progressbar to indicate percent complete ----
ProgressBar.Value = InstallProgress.PercentComplete
PercentComplete.Text =
InstallProgress.PercentComplete.ToString
Application.DoEvents()
Threading.Thread.Sleep(100)
'ICtr = ICtr + 1
'- if download not complete in the allotted time, throw
exception ----
'If ICtr >= InstallTimeout Then
' Throw New Exception("Install Complete Timeout")
'End If
Loop Until InstallResult.ResultCode <>
OperationResultCode.orcInProgress

'- Cleanup install job ----
InstallJob.CleanUp()

'- Return true, false or exception based on the results of the
install ----
If InstallResult.ResultCode = OperationResultCode.orcSucceeded
Then
Return True
ElseIf InstallResult.ResultCode = OperationResultCode.orcFailed
Then
Return False
Else
Throw New System.Exception("Unknown Install Result")
End If

Reply all
Reply to author
Forward
0 new messages