|
| |||||||||
| Tags: api, problem, windows update agent |
![]() |
| | Thread Tools | Search this Thread |
|
#1
| |||
| |||
| Using WUA (Windows Update Agent) API from C# fails when attempting to install hot fixes
Any help is much appreciated. I posted this problem on MSDN a few days ago, but so far, nothing but review and no response I am writing an application to automate the installation of specific vendor approved MS hot fixes on select servers. The application is written in C# and uses the WUA API via COM which works well, both with selectively querying Windows 2003 servers or XP desktops for available hot fixes and downloading user selected hot fixes. When my application attempts to install the hot fixes by calling the IUpdateInstaller.Install() method, the application receives an immediate response of a null value. The code excerpt from my test app is below which omits the logic associated with querying the hot fixes and is executed after the user has selected the desired hot fixes from the application's GUI: using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Runtime.InteropServices; using WUApiInterop; public partial class Form1 : Form { private UpdateSession updateSession; private ISearchResult updateSeachResult; private void cmdDownloadHotfix_Click(object sender, EventArgs e) { try { IUpdateInstaller updateInstaller; Console.WriteLine("Creating UpdateCollectionClass to store updates..."); UpdateCollectionClass updatesToInstall = new UpdateCollectionClass(); Console.WriteLine("Creating UpdateDownloader to download updates..."); UpdateDownloader downloader = updateSession.CreateUpdateDownloader(); downloader.ClientApplicationID = CLIENT_NAME; for (int i = 0; i < updateSeachResult.Updates.Count; ++i) { //Limit download to User GUI selected updates if (lstViewMSUpdate.Items[i].Checked == true) { IUpdate update = updateSeachResult.Updates[i]; updatesToInstall.Add(update); //add to Update Collection Console.WriteLine("Update: " + update.Title + " added to download list"); } } if (MessageBox.Show("Download & Install Updates?", "Hotfix Installation Confirmation", MessageBoxButtons.YesNoCancel) == DialogResult.Yes) { Console.WriteLine("Adding selected updates to downloader updatesToInstall collection..."); downloader.Updates = updatesToInstall; Console.WriteLine("Downloading updates..."); downloader.Download(); for (int i = 0; i < downloader.Updates.Count; i++) { Console.WriteLine("Updates successfully downloaded {0}.", downloader.Updates[i].Title); } Console.WriteLine("Creating UpdateInstasller..."); Type itype = Type.GetTypeFromProgID("Microsoft.Update.Installer"); updateInstaller = (UpdateInstaller)Activator.CreateInstance(itype); updateInstaller.Updates = updatesToInstall; updateInstaller.ClientApplicationID = CLIENT_NAME; //updateInstaller.AllowSourcePrompts = true; Console.WriteLine("Creating UpdateInstallationResult..."); updateInstaller.IsForced = true; if (updateInstaller.IsBusy == false) { IInstallationResult installationResult = updateInstaller.Install(); //IInstallationResult installationResult = updateInstaller.RunWizard("Nortel MS Hotfix Update Utility"); for (int i = 0; i < downloader.Updates.Count; i++) { Console.WriteLine("Update: {0},Result: {1}.", downloader.Updates[i].Title,installationResult.GetUpdateResult(i).ResultCode); //Console.WriteLine(downloader.Updates[i].Title + ": " + // installationResult.GetUpdateResult(i).ResultCode.ToString()); //Console.WriteLine(downloader.Updates[i].Title + ": " + // installationResult.GetUpdateResult(i).ToString()); } } else Console.WriteLine("Installation aborted because Windows update already in progress!"); } else updatesToInstall.Clear(); System.Windows.Forms.Application.DoEvents(); } catch (COMException ce) { MessageBox.Show("Caught COM error in download/install updates procedure: " + ce.ErrorCode.ToString() + " " + ce.Data.ToString(), "Error", MessageBoxButtons.OK); } } } The Windows.Update.log file entries (with enhanced debugging activated!) below confirm the successful hot fix download and attempt to install. The failure unfortunately is ambiguous and I cannot find a description of the error nor identify any cause for the problem. I have tried this application on multiple machines using local system admin and domain administrative user with no success. Lastly, the version of Windows Update Agent is the latest available. COMAPI ------------- 2009-08-26 17:31:17:784 1840 f54 COMAPI -- START -- COMAPI: Search [ClientId = STI Nortel MS Hotfix Update Ulility] 2009-08-26 17:31:17:800 1840 f54 COMAPI --------- 2009-08-26 17:31:17:816 1232 3ec Agent WU client succeeds CClientCallRecorder::BeginFindUpdatesEx from STI Nortel MS Hotfix Update Ulility with call id {F6DF7AAA-9AF8-4D10-98A7-2EFFAFC41C49} 2009-08-26 17:31:17:816 1232 a14 Agent WU client executing call {F6DF7AAA-9AF8-4D10-98A7-2EFFAFC41C49} of type Search Call 2009-08-26 17:31:17:816 1232 a14 Agent ************* 2009-08-26 17:31:17:816 1232 a14 Agent ** START ** Agent: Finding updates [CallerId = STI Nortel MS Hotfix Update Ulility] 2009-08-26 17:31:17:816 1232 a14 Agent ********* 2009-08-26 17:31:17:816 1232 a14 Agent * Online = Yes; Ignore download priority = No 2009-08-26 17:31:17:816 1232 a14 Agent * Criteria = "Type='Software' and IsInstalled=0" 2009-08-26 17:31:17:816 1840 f54 COMAPI <<-- SUBMITTED -- COMAPI: Search [ClientId = STI Nortel MS Hotfix Update Ulility] 2009-08-26 17:31:17:816 1232 a14 Agent * ServiceID = {9482F4B4-E343-43B6-B170-9A65BC822C77} 2009-08-26 17:31:17:816 1232 a14 Agent * Search Scope = {Machine} 2009-08-26 17:31:18:097 2680 854 Misc =========== Logging initialized (build: 7.2.6001.788, tz: -0600) =========== 2009-08-26 17:31:18:097 2680 854 Misc = Process: C:\WINDOWS\system32\wuauclt.exe 2009-08-26 17:31:18:097 2680 854 Misc = Module: C:\WINDOWS\system32\wuaueng.dll ---- items deleted for brevity DnldMgr ************* 2009-08-26 17:32:03:722 1232 a14 DnldMgr ** START ** DnldMgr: Downloading updates [CallerId = STI Nortel MS Hotfix Update Ulility] 2009-08-26 17:32:03:722 1232 a14 DnldMgr ********* 2009-08-26 17:32:03:722 1232 a14 DnldMgr * Call ID = {4C78FC49-A304-446B-B872-D9F33E2DF825} 2009-08-26 17:32:03:722 1232 a14 DnldMgr * Priority = 3, Interactive = 1, Owner is system = 0, Explicit proxy = 1, Proxy session id = -1, ServiceId = {9482F4B4-E343-43B6-B170-9A65BC822C77} 2009-08-26 17:32:03:722 1232 a14 DnldMgr * Updates to download = 1 2009-08-26 17:32:03:722 1232 a14 Agent Dumping out update 1 of 1 2009-08-26 17:32:03:722 1232 a14 Agent * Title = Update for Root Certificates [May 2009] (KB931125) 2009-08-26 17:32:03:722 1232 a14 Agent * UpdateId = {1BAC6A90-E250-4F1E-B254-5D076EFB2966}.100 2009-08-26 17:32:03:722 1232 a14 Agent * Bundles 1 updates: 2009-08-26 17:32:03:722 1232 a14 Agent * {58E3391D-DDA3-47EB-88AC-275F64F33A02}.100 2009-08-26 17:32:03:722 1232 a14 DnldMgr *********** DnldMgr: New download job [UpdateId = {58E3391D-DDA3-47EB-88AC-275F64F33A02}.100] *********** 2009-08-26 17:32:03:722 1232 a14 DnldMgr * All files for update were already downloaded and are valid. 2009-08-26 17:32:03:722 1232 a14 Agent WU client persisted 8 download calls 2009-08-26 17:32:03:737 1232 a14 Agent WU client persisted 8 download calls 2009-08-26 17:32:03:737 1232 e70 Agent WU client calls back to download call {4C78FC49-A304-446B-B872-D9F33E2DF825} with code Call complete and error 0 2009-08-26 17:32:03:737 1232 a14 Agent ********* 2009-08-26 17:32:03:737 1232 a14 Agent ** END ** Agent: Downloading updates [CallerId = STI Nortel MS Hotfix Update Ulility] 2009-08-26 17:32:03:737 1232 a14 Agent ************* 2009-08-26 17:32:03:737 1840 8c4 COMAPI >>-- RESUMED -- COMAPI: Download [ClientId = STI Nortel MS Hotfix Update Ulility] 2009-08-26 17:32:03:737 1840 8c4 COMAPI - Download call complete (succeeded = 1, succeeded with errors = 0, failed = 0, unaccounted = 0) 2009-08-26 17:32:03:737 1840 8c4 COMAPI --------- 2009-08-26 17:32:03:737 1840 8c4 COMAPI -- END -- COMAPI: Download [ClientId = STI Nortel MS Hotfix Update Ulility] 2009-08-26 17:32:03:737 1840 8c4 COMAPI ------------- 2009-08-26 17:32:03:753 1232 300 Agent WU client internal API failed CClientCallRecorder::DisconnectCall with error 0x8024000c 2009-08-26 17:32:03:753 1840 e54 COMAPI ISusInternal::DisconnectCall failed, hr=8024000C 2009-08-26 17:32:05:222 3468 a68 COMAPI ------------- 2009-08-26 17:32:05:222 3468 a68 COMAPI -- START -- COMAPI: Install [ClientId = STI Nortel MS Hotfix Update Ulility] 2009-08-26 17:32:05:222 3468 a68 COMAPI --------- 2009-08-26 17:32:05:222 3468 a68 COMAPI - Allow source prompts: Yes; Forced: No; Force quiet: No 2009-08-26 17:32:05:237 3468 a68 COMAPI - Updates in request: 1 2009-08-26 17:32:05:237 3468 a68 COMAPI - WARNING: Exit code = 0x80004002 2009-08-26 17:32:05:237 3468 a68 COMAPI --------- 2009-08-26 17:32:05:237 3468 a68 COMAPI -- END -- COMAPI: Install [ClientId = <NULL>] 2009-08-26 17:32:05:237 3468 a68 COMAPI ------------- 2009-08-26 17:32:05:237 3468 a68 COMAPI FATAL: Unable to perform synchronous installation successfully. (hr=80004002) Any direction or suggestions are much appreciated! I have searched every knowledge base I could find with no success towards resolving this issue. Thanks! |
|
#2
| |||
| |||
| Re: Using WUA (Windows Update Agent) API from C# fails when attempting to install hot fixes
stvcti wrote: :: Any help is much appreciated. I posted this problem on MSDN a few :: days ago, but so far, nothing but review and no response :: :: I am writing an application to automate the installation of specific :: vendor approved MS hot fixes on select servers. -- Suggest you wait and be patient for a response regarding your posting at MSDN. We are trying to deal with update problems here. TaurArian [MVP] 2005-2010 - Update Services http://taurarian.mvps.org ====================================== Disclaimer: The information has been posted "as is" with no warranties or guarantees and doesn't give any rights. |
|
#3
| |||
| |||
| Re: Using WUA (Windows Update Agent) API from C# fails when attemptingto install hot fixes
stvcti wrote: > Any help is much appreciated. I posted this problem on MSDN a few days > ago, but so far, nothing but review and no response Is the application running in administrative context? Harry. > > I am writing an application to automate the installation of specific > vendor approved MS hot fixes on select servers. The application is > written in C# and uses the WUA API via COM which works well, both with > selectively querying Windows 2003 servers or XP desktops for available > hot fixes and downloading user selected hot fixes. When my application > attempts to install the hot fixes by calling the > IUpdateInstaller.Install() method, the application receives an immediate > response of a null value. The code excerpt from my test app is below > which omits the logic associated with querying the hot fixes and is > executed after the user has selected the desired hot fixes from the > application's GUI: > > using System.Collections.Generic; > using System.ComponentModel; > using System.Data; > using System.Drawing; > using System.Linq; > using System.Text; > using System.Windows.Forms; > using System.Runtime.InteropServices; > using WUApiInterop; > > public partial class Form1 : Form > { > private UpdateSession updateSession; > private ISearchResult updateSeachResult; > > private void cmdDownloadHotfix_Click(object sender, EventArgs > e) > { > try > { > IUpdateInstaller updateInstaller; > > Console.WriteLine("Creating UpdateCollectionClass to > store updates..."); > UpdateCollectionClass updatesToInstall = new > UpdateCollectionClass(); > Console.WriteLine("Creating UpdateDownloader to > download updates..."); > UpdateDownloader downloader = > updateSession.CreateUpdateDownloader(); > downloader.ClientApplicationID = CLIENT_NAME; > for (int i = 0; i < updateSeachResult.Updates.Count; > ++i) > { > //Limit download to User GUI selected updates > if (lstViewMSUpdate.Items[i].Checked == true) > { > IUpdate update = updateSeachResult.Updates[i]; > updatesToInstall.Add(update); //add to Update > Collection > Console.WriteLine("Update: " + update.Title + " > added to download list"); > } > > } > > if (MessageBox.Show("Download & Install Updates?", > "Hotfix Installation Confirmation", MessageBoxButtons.YesNoCancel) > == DialogResult.Yes) > { > Console.WriteLine("Adding selected updates to > downloader updatesToInstall collection..."); > downloader.Updates = updatesToInstall; > Console.WriteLine("Downloading updates..."); > downloader.Download(); > > for (int i = 0; i < downloader.Updates.Count; i++) > { > Console.WriteLine("Updates successfully > downloaded {0}.", downloader.Updates[i].Title); > } > > Console.WriteLine("Creating UpdateInstasller..."); > Type itype = > Type.GetTypeFromProgID("Microsoft.Update.Installer"); > > updateInstaller = > (UpdateInstaller)Activator.CreateInstance(itype); > updateInstaller.Updates = updatesToInstall; > updateInstaller.ClientApplicationID = CLIENT_NAME; > > //updateInstaller.AllowSourcePrompts = true; > Console.WriteLine("Creating > UpdateInstallationResult..."); > updateInstaller.IsForced = true; > > if (updateInstaller.IsBusy == false) > { > IInstallationResult installationResult = > updateInstaller.Install(); > //IInstallationResult installationResult = > updateInstaller.RunWizard("Nortel MS Hotfix Update Utility"); > > for (int i = 0; i < downloader.Updates.Count; > i++) > { > Console.WriteLine("Update: {0},Result: > {1}.", > downloader.Updates[i].Title,installationResult.GetUpdateResult(i).ResultCode); > > //Console.WriteLine(downloader.Updates[i].Title + ": " + > // > installationResult.GetUpdateResult(i).ResultCode.ToString()); > > //Console.WriteLine(downloader.Updates[i].Title + ": " + > // > installationResult.GetUpdateResult(i).ToString()); > } > } > else > Console.WriteLine("Installation aborted because > Windows update already in progress!"); > } > else > updatesToInstall.Clear(); > > System.Windows.Forms.Application.DoEvents(); > } > > catch (COMException ce) > { > MessageBox.Show("Caught COM error in download/install > updates procedure: " + ce.ErrorCode.ToString() + " " + > ce.Data.ToString(), "Error", MessageBoxButtons.OK); > } > } > } > > The Windows.Update.log file entries (with enhanced debugging > activated!) below confirm the successful hot fix download and attempt to > install. The failure unfortunately is ambiguous and I cannot find a > description of the error nor identify any cause for the problem. I have > tried this application on multiple machines using local system admin and > domain administrative user with no success. Lastly, the version of > Windows Update Agent is the latest available. > > COMAPI ------------- > 2009-08-26 17:31:17:784 1840 f54 COMAPI -- START -- > COMAPI: Search [ClientId = STI Nortel MS Hotfix Update Ulility] > 2009-08-26 17:31:17:800 1840 f54 COMAPI --------- > 2009-08-26 17:31:17:816 1232 3ec Agent WU client > succeeds CClientCallRecorder::BeginFindUpdatesEx from STI Nortel MS > Hotfix Update Ulility with call id > {F6DF7AAA-9AF8-4D10-98A7-2EFFAFC41C49} > 2009-08-26 17:31:17:816 1232 a14 Agent WU client > executing call {F6DF7AAA-9AF8-4D10-98A7-2EFFAFC41C49} of type Search > Call > 2009-08-26 17:31:17:816 1232 a14 Agent ************* > 2009-08-26 17:31:17:816 1232 a14 Agent ** START ** > Agent: Finding updates [CallerId = STI Nortel MS Hotfix Update Ulility] > 2009-08-26 17:31:17:816 1232 a14 Agent ********* > 2009-08-26 17:31:17:816 1232 a14 Agent * Online = Yes; > Ignore download priority = No > 2009-08-26 17:31:17:816 1232 a14 Agent * Criteria = > "Type='Software' and IsInstalled=0" > 2009-08-26 17:31:17:816 1840 f54 COMAPI <<-- SUBMITTED > -- COMAPI: Search [ClientId = STI Nortel MS Hotfix Update Ulility] > 2009-08-26 17:31:17:816 1232 a14 Agent * ServiceID = > {9482F4B4-E343-43B6-B170-9A65BC822C77} > 2009-08-26 17:31:17:816 1232 a14 Agent * Search Scope > = {Machine} > 2009-08-26 17:31:18:097 2680 854 Misc =========== > Logging initialized (build: 7.2.6001.788, tz: -0600) =========== > 2009-08-26 17:31:18:097 2680 854 Misc = Process: > C:\WINDOWS\system32\wuauclt.exe > 2009-08-26 17:31:18:097 2680 854 Misc = Module: > C:\WINDOWS\system32\wuaueng.dll > > ---- items deleted for brevity > DnldMgr ************* > 2009-08-26 17:32:03:722 1232 a14 DnldMgr ** START ** > DnldMgr: Downloading updates [CallerId = STI Nortel MS Hotfix Update > Ulility] > 2009-08-26 17:32:03:722 1232 a14 DnldMgr ********* > 2009-08-26 17:32:03:722 1232 a14 DnldMgr * Call ID = > {4C78FC49-A304-446B-B872-D9F33E2DF825} > 2009-08-26 17:32:03:722 1232 a14 DnldMgr * Priority = > 3, Interactive = 1, Owner is system = 0, Explicit proxy = 1, Proxy > session id = -1, ServiceId = {9482F4B4-E343-43B6-B170-9A65BC822C77} > 2009-08-26 17:32:03:722 1232 a14 DnldMgr * Updates to > download = 1 > 2009-08-26 17:32:03:722 1232 a14 Agent Dumping out > update 1 of 1 > 2009-08-26 17:32:03:722 1232 a14 Agent * Title = > Update for Root Certificates [May 2009] (KB931125) > 2009-08-26 17:32:03:722 1232 a14 Agent * UpdateId = > {1BAC6A90-E250-4F1E-B254-5D076EFB2966}.100 > 2009-08-26 17:32:03:722 1232 a14 Agent * Bundles 1 > updates: > 2009-08-26 17:32:03:722 1232 a14 Agent * > {58E3391D-DDA3-47EB-88AC-275F64F33A02}.100 > 2009-08-26 17:32:03:722 1232 a14 DnldMgr *********** > DnldMgr: New download job [UpdateId = > {58E3391D-DDA3-47EB-88AC-275F64F33A02}.100] *********** > 2009-08-26 17:32:03:722 1232 a14 DnldMgr * All files > for update were already downloaded and are valid. > 2009-08-26 17:32:03:722 1232 a14 Agent WU client > persisted 8 download calls > 2009-08-26 17:32:03:737 1232 a14 Agent WU client > persisted 8 download calls > 2009-08-26 17:32:03:737 1232 e70 Agent WU client calls > back to download call {4C78FC49-A304-446B-B872-D9F33E2DF825} with code > Call complete and error 0 > 2009-08-26 17:32:03:737 1232 a14 Agent ********* > 2009-08-26 17:32:03:737 1232 a14 Agent ** END ** > Agent: Downloading updates [CallerId = STI Nortel MS Hotfix Update > Ulility] > 2009-08-26 17:32:03:737 1232 a14 Agent ************* > 2009-08-26 17:32:03:737 1840 8c4 COMAPI >>-- RESUMED > -- COMAPI: Download [ClientId = STI Nortel MS Hotfix Update Ulility] > 2009-08-26 17:32:03:737 1840 8c4 COMAPI - Download > call complete (succeeded = 1, succeeded with errors = 0, failed = 0, > unaccounted = 0) > 2009-08-26 17:32:03:737 1840 8c4 COMAPI --------- > 2009-08-26 17:32:03:737 1840 8c4 COMAPI -- END -- > COMAPI: Download [ClientId = STI Nortel MS Hotfix Update Ulility] > 2009-08-26 17:32:03:737 1840 8c4 COMAPI ------------- > 2009-08-26 17:32:03:753 1232 300 Agent WU client > internal API failed CClientCallRecorder::DisconnectCall with error > 0x8024000c > 2009-08-26 17:32:03:753 1840 e54 COMAPI > ISusInternal::DisconnectCall failed, hr=8024000C > 2009-08-26 17:32:05:222 3468 a68 COMAPI ------------- > 2009-08-26 17:32:05:222 3468 a68 COMAPI -- START -- > COMAPI: Install [ClientId = STI Nortel MS Hotfix Update Ulility] > 2009-08-26 17:32:05:222 3468 a68 COMAPI --------- > 2009-08-26 17:32:05:222 3468 a68 COMAPI - Allow source > prompts: Yes; Forced: No; Force quiet: No > 2009-08-26 17:32:05:237 3468 a68 COMAPI - Updates in > request: 1 > 2009-08-26 17:32:05:237 3468 a68 COMAPI - WARNING: > Exit code = 0x80004002 > 2009-08-26 17:32:05:237 3468 a68 COMAPI --------- > 2009-08-26 17:32:05:237 3468 a68 COMAPI -- END -- > COMAPI: Install [ClientId = <NULL>] > 2009-08-26 17:32:05:237 3468 a68 COMAPI ------------- > 2009-08-26 17:32:05:237 3468 a68 COMAPI FATAL: Unable to > perform synchronous installation successfully. (hr=80004002) > > Any direction or suggestions are much appreciated! I have searched > every knowledge base I could find with no success towards resolving this > issue. > > Thanks! > > |
![]() |
|
| Thread Tools | Search this Thread |
| |
Similar Threads for: "Using WUA (Windows Update Agent) API from C# fails when attempting to install hot fixes" | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Windows update is failing while attempting to install SQL Server SP3 (KB955706) | Myshaa | Operating Systems | 4 | 04-04-2011 01:32 AM |
| Windows Update Error Code 2 attempting to install Security Update for .NET Framework 4 (KB2160841) | Dalapathi | Windows Update | 6 | 26-02-2011 10:50 AM |
| Vista SP1 Fails to Install From Windows Update | Eric | Vista Setup and Install | 2 | 04-06-2010 12:01 AM |
| Update for Windows Vista (KB938371) install fails | Timothy G. | Windows Update | 6 | 26-03-2010 01:15 AM |
| Windows update Agent 7.2.6001.788 fails with error 0x800736b2 | fgpsmith | Windows Update | 5 | 22-12-2008 03:54 AM |