Здравствуйте, не нашел, в какой форум написать, поэтому написал сюда. Если ошибся — направьте пожалуйста. На русском форуме TechNet послали сюда, на английских MSDN и TechNet а также
www.gotdotnet.ru все молчат...
Проблема заключается в следующем — пытаюсь программно (C# .NET 2.0) обновить систему (Windows Vista x86 EN) с помощью WUA Type Library 2.0 (через Interop.WUApiLib) из файлов вида Windows6.0-KB******-x86.msu, при вызове метода CopyToCache возникает ошибка COMException (HRESULT: 0x80240026) 0x80240026 = WU_E_INVALID_UPDATE_TYPE. Собственно, сам код:
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
// Empy 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.
}
}
}
}
Буду раз любой помощи или подсказкам, в какую сторону "копать". Заранее благодарен.
С уважением, Александр Козленко.