Skip to content
View in the app

A better way to browse. Learn more.

MSFN

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Offline Windows Update Using WUA in C# Error

Featured Replies

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.

Create an account or sign in to comment

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.