supersonic Posted January 15, 2009 Share Posted January 15, 2009 Hi everybody,I'm trying to write my own Windows Update script.Therefore I need to determine which updates are needed.I'm trying to convert a VBS script:expandcollapse popupOption Explicit Dim wshShell, objUpdateService, objUpdateSearcher, objSearchResult, objUpdate, objIDFile Dim strTempFolder, strTextFileName, strArgument Set wshShell = WScript.CreateObject("WScript.Shell") strTempFolder = wshShell.ExpandEnvironmentStrings("%TEMP%") strTextFileName = strTempFolder & "\MissingUpdateIds.txt" If WScript.Arguments.Count = 0 Then strArgument = "" Else strArgument = WScript.Arguments(0) End If Set objUpdateService = CreateObject("Microsoft.Update.ServiceManager").AddScanPackageService("Offline Sync Service", strTempFolder & "\wsusscn2.cab") Set objUpdateSearcher = CreateObject("Microsoft.Update.Session").CreateUpdateSearcher() objUpdateSearcher.ServerSelection = 3 ' ssOthers objUpdateSearcher.ServiceID = objUpdateService.ServiceID If LCase(strArgument) = "/all" Then Set objSearchResult = objUpdateSearcher.Search("Type='Software'") Else Set objSearchResult = objUpdateSearcher.Search("Type='Software' and IsInstalled=0") End If If objSearchResult.Updates.Count > 0 Then Set objIDFile = CreateObject("Scripting.FileSystemObject").CreateTextFile(strTextFileName, True) For Each objUpdate In objSearchResult.Updates objIDFile.WriteLine(objUpdate.KBArticleIDs.Item(0)) Next objIDFile.Close End If WScript.Quit(0)oÝ÷ Ù8Z·lÂ"¯yÊyÛ(}ªÚºÚ"µÍÛØ[ ÌÍÛÔÙXÙSX[YÙHØÜX]J ][ÝÓZXÜÜÛÙ]KÙXÙSX[YÙ][ÝÊBÌÍÛÔÙXÙSX[YÙYØØ[XÚØYÙTÙXÙJ ][ÝÓÙ[HÞ[ÈÙXÙI][ÝË[ [È ][ÝÉÌLÝÜÝÜØÛØX][ÝÊBÛØ[ ÌÍÛÔÙÜÚ[ÛHØÜX]J ][ÝÓZXÜÜÛÙ]KÙÜÚ[Û][ÝÊBÌÍÛÔÙÜÚ[ÛÜX]U]TÙXÚ BÌÍÛÔÙÜÚ[ÛÙÙ[XÝ[Û ][ÝÜÜÓÝÏLÉ][ÝÊBÌÍÛÔÙÜÚ[ÛÙXÙRQH ÌÍÛÔÙXÙSX[YÙÙXÙRQ BÛØ[ ÌÍÛÔÙXÚÝ[H ÌÍÛÔÙÜÚ[ÛÙXÚ ][ÝÕOIÌÎNÔÛÙØIÌÎNÉ][ÝÊFor running this the scripts you need the file "wsusscn2.cab" whichcan be download at: http://download.windowsupdate.com/microsof...an/wsusscn2.cabCan somebody help me?Greets! Link to comment Share on other sites More sharing options...
supersonic Posted January 15, 2009 Author Share Posted January 15, 2009 I always getting an error in line "$oSession.ServerSelection("ssOthers=3")": The requested action with this object has failed. Hi everybody, I'm trying to write my own Windows Update script. Therefore I need to determine which updates are needed. I'm trying to convert a VBS script: expandcollapse popupOption Explicit Dim wshShell, objUpdateService, objUpdateSearcher, objSearchResult, objUpdate, objIDFile Dim strTempFolder, strTextFileName, strArgument Set wshShell = WScript.CreateObject("WScript.Shell") strTempFolder = wshShell.ExpandEnvironmentStrings("%TEMP%") strTextFileName = strTempFolder & "\MissingUpdateIds.txt" If WScript.Arguments.Count = 0 Then strArgument = "" Else strArgument = WScript.Arguments(0) End If Set objUpdateService = CreateObject("Microsoft.Update.ServiceManager").AddScanPackageService("Offline Sync Service", strTempFolder & "\wsusscn2.cab") Set objUpdateSearcher = CreateObject("Microsoft.Update.Session").CreateUpdateSearcher() objUpdateSearcher.ServerSelection = 3 ' ssOthers objUpdateSearcher.ServiceID = objUpdateService.ServiceID If LCase(strArgument) = "/all" Then Set objSearchResult = objUpdateSearcher.Search("Type='Software'") Else Set objSearchResult = objUpdateSearcher.Search("Type='Software' and IsInstalled=0") End If If objSearchResult.Updates.Count > 0 Then Set objIDFile = CreateObject("Scripting.FileSystemObject").CreateTextFile(strTextFileName, True) For Each objUpdate In objSearchResult.Updates objIDFile.WriteLine(objUpdate.KBArticleIDs.Item(0)) Next objIDFile.Close End If WScript.Quit(0)oÝ÷ Ù8Z·lÂ"¯yÊyÛ(}ªÚºÚ"µÍÛØ[ ÌÍÛÔÙXÙSX[YÙHØÜX]J ][ÝÓZXÜÜÛÙ]KÙXÙSX[YÙ][ÝÊBÌÍÛÔÙXÙSX[YÙYØØ[XÚØYÙTÙXÙJ ][ÝÓÙ[HÞ[ÈÙXÙI][ÝË[ [È ][ÝÉÌLÝÜÝÜØÛØX][ÝÊBÛØ[ ÌÍÛÔÙÜÚ[ÛHØÜX]J ][ÝÓZXÜÜÛÙ]KÙÜÚ[Û][ÝÊBÌÍÛÔÙÜÚ[ÛÜX]U]TÙXÚ BÌÍÛÔÙÜÚ[ÛÙÙ[XÝ[Û ][ÝÜÜÓÝÏLÉ][ÝÊBÌÍÛÔÙÜÚ[ÛÙXÙRQH ÌÍÛÔÙXÙSX[YÙÙXÙRQ BÛØ[ ÌÍÛÔÙXÚÝ[H ÌÍÛÔÙÜÚ[ÛÙXÚ ][ÝÕOIÌÎNÔÛÙØIÌÎNÉ][ÝÊ For running this the scripts you need the file "wsusscn2.cab" which can be download at: http://download.windowsupdate.com/microsof...an/wsusscn2.cab Can somebody help me? Greets! Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now