Sign in to follow this  
Followers 0
supersonic

Need help to convert C# into AU3

1 post in this topic

Hi,

I'm currently working on a script managing Windows updates (search, download, install).

That's what I have so far (just demo code); in order to run the script you'll have to download

the file "wsusscn2.cab" at http://download.windowsupdate.com/microsof...an/wsusscn2.cab

and place it into @ScriptDir.

#include <Array.au3>

Global $test = _search(@ScriptDir, "Type='Software' and IsInstalled=0")

_ArrayDisplay($test)

Func _search($sPath = @ScriptDir, $sScope = "Type='Software'")
    Local $i
    Local $sCounter         = 0
    Local $sDummy
    Local $sResult
    Local $sSession         = ObjCreate("Microsoft.Update.Session")
    Local $sSearcher        = $sSession.CreateUpdateSearcher()
    Local $sServiceManager  = ObjCreate("Microsoft.Update.ServiceManager")
    Local $sService         = $sServiceManager.AddScanPackageService("Offline Sync Service", $sPath & "\wsusscn2.cab")
    ; <...>
    $sSearcher.ServerSelection  = 3 ; 0 = ssDefault, 1 = ssManagedServer, 2 = ssWindowsUpdate, 3 = ssOthers.
    $sSearcher.ServiceID        = $sService.ServiceID
    $sResult                    = $sSearcher.Search($sScope)
    ; <...>
    Local $sArray[$sResult.Updates.Count][2]
    ; <...>
    Local $colUpdates = $sResult.Updates
    For $x = 1 To $colUpdates.Count - 1
        $objIdentity = $colUpdates.Item($x).Identity
        ConsoleWrite("RevisionNumber: " & $objIdentity.RevisionNumber & @CRLF)
        ConsoleWrite("UpdateID: " & $objIdentity.UpdateID & @CRLF)
    Next
    ; <...> 
    If $sResult.Updates.Count > 0 Then
        For $i In $sResult.Updates
            $sDummy = $sResult.Updates.Item($sCounter)
            $sArray[$sCounter][0] = $sDummy.Title
            $sArray[$sCounter][1] = "KB" & $i.KBArticleIDs.Item(0)
            $sCounter = $sCounter + 1
        Next
    Else
        ; <...>
    EndIf
    ; <...>
    Return $sArray
EndFuncoÝ÷ Ù: zÛayÚ0ZuDK²ÞiÈn¥Ö­xèºwl¢gr^ëH«ÞnrG(÷«¶)àÚ'*0òÄ!!zZwÜw«{l¶¡×ºÚ"µÍ]TÙÜÚ[ÛÛÜÈ]TÙÜÚ[ÛH]È]TÙÜÚ[ÛÛÜÊ
NÂU]TÙXÚ]TÙXÚB]TÙÜÚ[ÛÜX]U]TÙXÚ
NÂTÙXÚÝ[ÙXÚÝ[H]TÙXÚÙXÚ
^ÞK^
NÂÜ
[HHÈH  ÈÙXÚÝ[]ËÛÝ[ÈJÊÊBÂÝ[ÈÐÈHÝ[Ë[NÂU]H]HHÙXÚÝ[]ÖÚWNÂ]PÛÛXÝ[ÛÛÛH]K[Y]ÎÂÜ
[]HHÈ]H    ÈÛÛÛÝ[È]JÊÊBÂU]QÝÛØYÛÛ[ÛÛ[HÛÛÚ]WKÝÛØYÛÛ[ÖÌNÂÜXXÚ
Ý[ÈÈ[]KÐXÛRQÊBÂÐÈHÈ
È  ][ÝË  ][ÝÎÂBÝ[È]HHÝ[ËÜX]
    ][ÝÞÌMÍ_I][ÝË]K]JNÂÝ[ÈHÛÛ[ÝÛØY    ÌÌÎÏH[ÈÛÛ[ÝÛØY][ÝÓÈT   ][ÝÎÂÝ[ÈÜ^Ý[ÈHÝ[ËÜX]
    ][ÝÒÐÌH]NÌ_HÌI][ÝËÐË]K
NÂÝÞK][ËY
Ü^Ý[ÊNÂB

Greets,

supersonic.

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