From: nop on 29 Aug 2007 17:46 Hi, I've get an error after calling of IUpdate2::CopyToCache() method in my program. I trying to install windows updates (*.msu) at Windows Vista x86 with .NET program using WUA (as Interop.WUApiLib). My Code: ---------------------------------------------------- using System; using System.Collections.Generic; using System.IO; using System.Diagnostics; using WUApiLib; namespace WUApiLibTest { static class Program { [STAThread] static void Main() { // Update File: C:\Windows6.0-KB123456-x86.msu // Emoty Directory: C:\ExpandedUpdate\ Process expandProcess = new Process(); expandProcess.StartInfo.FileName = "Expand"; expandProcess.StartInfo.WorkingDirectory = @"C:\"; expandProcess.StartInfo.Arguments = @"C:\Windows6.0-KB123456-x86.msu -f:WSUSSCAN.cab C:\ExpandedUpdate\"; expandProcess.Start(); expandProcess.WaitForExit(); UpdateSessionClass updateSession = new UpdateSessionClass(); IUpdateServiceManager updateServiceManager = updateSession.CreateUpdateServiceManager(); IUpdateService updateService = updateServiceManager.AddScanPackageService("Offline Sync Service", @"C:\ExpandedUpdate\WSUSSCAN.cab", 0); IUpdateSearcher updateSearcher = updateSession.CreateUpdateSearcher(); updateSearcher.ServerSelection = ServerSelection.ssOthers; updateSearcher.ServiceID = updateService.ServiceID; ISearchResult searchResult = updateSearcher.Search("Type='Software'"); if (searchResult.Updates.Count > 0) { expandProcess.StartInfo.Arguments = @"C:\Windows6.0-KB123456-x86.msu -f:Windows*.cab C:\ExpandedUpdate\"; expandProcess.Start(); expandProcess.WaitForExit(); StringCollectionClass filesToCopy = new StringCollectionClass(); foreach (string fileName in Directory.GetFiles(@"C:\ExpandedUpdate\", "Windows6.0-*.cab")) filesToCopy.Add(fileName); UpdateCollectionClass updateCollection = new UpdateCollectionClass(); updateCollection.Add(searchResult.Updates[0]); IUpdate2 iUpdate2 = (IUpdate2)searchResult.Updates[0]; // BUGGY LINE iUpdate2.CopyToCache(filesToCopy); // COMException (HRESULT: 0x80240026) // 0x80240026 - WU_E_INVALID_UPDATE_TYPE // ... updateInstaller etc. } } } } ---------------------------------------------------- Help me, please... Best regards, Alexander Kozlenko P.S. Sorry for my bad english.
|
Pages: 1 Prev: WindowsUpdate_800736CC error Next: security update installation failures |