Sign in to follow this  
Followers 0
neogia

Problems with WUA COM object

5 posts in this topic

Ok, so I got a working version of Windows Update using the WUA COM object. This works flawlessly, however there is no way of determining download or install progress the way I have it implemented. Here is what I would like to change:

$downloader = $updateSession.CreateUpdateDownloader ()
$downloader.Updates = $updatesToDownload
$downloader.Download ()
;Display results and Install

And I would like to change it to this:

$downloader = $updateSession.CreateUpdateDownloader ()
$downloader.Updates = $updatesToDownload
$downloadJob = $downloader.BeginDownload ()
$downloadProgress = $downloadJob.GetProgress ()
;While loop constantly checking $downloadProgress to update progress bar

This is how the downloader is to be implemented, except for one thing, I got an error in $downloader.BeginDownload (). Initially, it just crashed the script, but I wanted to see what was going on, so I implemented a COM error handler, and retrieved the hex error code: 8002000E After a quick google search of simply "8002000E", I found it meant "Incorrect number of arguments".

So I went back to trusty MSDN, and searched around to find that BeginDownload () requires 3 arguments, an IDownloadProgressChangedCallback, an IDownloadCompletedCallback, and whatever an AsyncState Property of IDownloadJob is, it needs one of those too.

So my plea is this: To whomever knows their way around COM objects, how on earth do I create, or otherwise retrieve the arguments which BeginDownload () requires? I'm stuck.

I've even searched the registry for an object Microsoft.Update.DownloadCallback, but it only contains the downloader.

Note: in order to utilize the WUA object, you have to download it here

Any help is as always much appreciated. Fellow programmer in learning.


[u]My UDFs[/u]Coroutine Multithreading UDF LibraryStringRegExp GuideRandom EncryptorArrayToDisplayString"The Brain, expecting disaster, fails to find the obvious solution." -- neogia

Share this post


Link to post
Share on other sites



Ok, I just realized something further. BeginDownload () doesn't require arguments that are specifically IDownloadProgressChangedCallback or IDownloadCompletedCallback or AsyncState, it requires two IUnkown*'s and a VARIANT, as follows:

HRESULT BeginDownload(
  IUnknown* onprogressChanged,
  IUnknown* onCompleted,
  VARIANT state,
  IDownloadJob** retval
);

Or maybe since VARIANT isn't VARIANT*, it might just require two objects of type IUnkown? I don't know, but I'll keep searching...


[u]My UDFs[/u]Coroutine Multithreading UDF LibraryStringRegExp GuideRandom EncryptorArrayToDisplayString"The Brain, expecting disaster, fails to find the obvious solution." -- neogia

Share this post


Link to post
Share on other sites

Wait a second, I've been looking all day, and from everything I'm reading, it looks like you can't create an object of type IUnknown... Is that true? If that's the case, then I'm stuck. I haven't found a single example or implementation reference for the IUpdateDownloader object. Except for the one on MSDN, and I can't figure out what they want me to pass into the call to BeginDownload(). I'm desperate here... :o


[u]My UDFs[/u]Coroutine Multithreading UDF LibraryStringRegExp GuideRandom EncryptorArrayToDisplayString"The Brain, expecting disaster, fails to find the obvious solution." -- neogia

Share this post


Link to post
Share on other sites

Wait a second, I've been looking all day, and from everything I'm reading, it looks like you can't create an object of type IUnknown... Is that true? If that's the case, then I'm stuck. I haven't found a single example or implementation reference for the IUpdateDownloader object. Except for the one on MSDN, and I can't figure out what they want me to pass into the call to BeginDownload(). I'm desperate here... :o

Hello neogia,

Programming Windows Update (or Software Update Services) is very complicated.

One thing you must be aware of is the fact that Microsoft made two API's: One for C++/VB/.NET applications, and another for scripting hosts (VBscript,Cscript).

In your examples you are trying to access the C++ API from within a script. That won't work.

I can't give you a full solution, but you can find many Windows Update related example scripts at:

http://www.microsoft.com/technet/scriptcen...nt/default.mspx

Those are VBscript examples, but it should not be too difficult to convert them to AutoIt. I remember someone wrote a VBScript-to-AutoIt converter (can't currently find the post).

You can find more information about the Windows Update Agent API at:

http://msdn.microsoft.com/library/en-us/wu...rtal_client.asp

But keep in mind to use the scripting-interface, not the C++ interfaces.

Regards,

-Sven

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0