Jump to content

Featured Replies

Posted

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.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...