Jump to content

Help with com objects


res2cpu
 Share

Recommended Posts

Hi

I'm a beginner when it comes to this stuff.

I'm messing with the windows update agent and im having problems getting info from it.

My code can get the list of updates but i can get the Download URL's from it.

Heres my code so far:

CODE
#RequireAdmin

$UpdateSession = ObjCreate("Microsoft.Update.Session")

$UpdateSearcher = $UpdateSession.CreateUpdateSearcher()

MsgBox(4096, "Test", "Searching for updates..." )

$SearchResult = $UpdateSearcher.Search("IsInstalled=1")

$Updates = $SearchResult.Updates

If $searchResult.Updates.Count = 0 Then

MsgBox(4096, "Test", "None" )

Exit

EndIf

For $I = 0 to $searchResult.Updates.Count - 1

$update = $searchResult.Updates.Item($I)

MsgBox(4096, "Test", $I + 1 & "> " & $update.Title )

Next

$UpdateSearcher = $UpdateSession.CreateUpdateSearcher()

$updatesToDownload = ObjCreate("Microsoft.Update.UpdateColl")

For $I = 0 to $searchResult.Updates.Count - 1

$update = $searchResult.Updates.Item($I)

$updatesToDownload.Add($update)

MsgBox(4096, "Test", "Added: " & $update.Download.Content.DownloadUrl)

Next

MsgBox(4096, "Test", "Done" )

Exit

The link to the windows update agent site with the info is: http://msdn.microsoft.com/en-us/library/aa387099(VS.85).aspx and the link to the item im trying to get working is here: http://msdn.microsoft.com/en-us/library/aa386129(VS.85).aspx

I have googled for hours, thanks for any help you can give.

Link to comment
Share on other sites

It is not clear what your problem is. What is your question?

Dale

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y

Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Link to comment
Share on other sites

Im trying to get the program to give me the url's for the windows updates so i can download them and install them at another time. This can be done (or so it says) using the API of the windows update agent. As soon as i add what i think is needed to get it to give me the download url the program closes itself (even in scite) with no error message.

If i us the following:

CODE
For $I = 0 to $searchResult.Updates.Count - 1

$update = $searchResult.Updates.Item($I)

MsgBox(4096, "Test", $I + 1 & "> " & $update.Title )

MsgBox(4096, "Test", $I + 1 & "> " & $update.Download.Content.DownloadUrl ); <---------- New line

Next

The program closes with no error and does not run to the end.

I think its something to do with the syntax of the "$update.Download.Content.DownloadUrl" but i cant find any examples in other languages.

Hope this makes it clearer what im trying to do.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...