Windows Vista Tips

Windows Vista Tips > Newsgroups > Windows Update > Offline Windows Update Using WUA in C# Error

Reply
Thread Tools Display Modes

Offline Windows Update Using WUA in C# Error

 
 
nop
Guest
Posts: n/a

 
      08-29-2007
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("Offlin e 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.
 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Windows Mail Showing Offline Error winston5998 Windows Vista Mail 9 12-30-2008 10:19 PM
Re: Offline windows update Torgeir Bakken \(MVP\) Windows Update 0 09-02-2004 03:20 PM
Windows update OFFLINE??? ad Windows Update 1 09-05-2003 12:48 PM
Re: * * * WINDOWS UPDATE OFFLINE * * * Lucy [MS] Windows Update 2 08-20-2003 05:11 PM
* * * WINDOWS UPDATE OFFLINE * * * Windows Update 1 08-18-2003 01:22 PM



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59