Advertisement
Guest User

WSUS Offline Update Code Suggestions

a guest
Jul 5th, 2015
392
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 13.48 KB | None | 0 0
  1. #include <Array.au3>
  2.  
  3.  
  4. #Region Required For All The Code Below, Must Appear Before Line 62
  5. Global Const $aMainArray[26][5] = [ [ 25   , 'Windows'      , 'Office'           , 'Deutsch'        , 'English'      ] , _
  6.                                                 ['glb' , 'w60|w60 x64|w61|w61 x64|w62|w62 x64|w63|w63 x64'                       ] , _
  7.                                                 ['enu' , 'w2k3|w2k3 x64', 'o2k7|o2k10|o2k13' , 'Englisch'       , 'English'      ] , _
  8.                                                 ['fra' , 'w2k3|w2k3 x64', 'o2k7|o2k10|o2k13' , 'Französisch'    , 'French'       ] , _
  9.                                                 ['esn' , 'w2k3|w2k3 x64', 'o2k7|o2k10|o2k13' , 'Spanisch'       , 'Spanish'      ] , _
  10.                                                 ['jpn' , 'w2k3|w2k3 x64', 'o2k7|o2k10|o2k13' , 'Japanisch'      , 'Japanese'     ] , _
  11.                                                 ['kor' , 'w2k3|w2k3 x64', 'o2k7|o2k10|o2k13' , 'Koreanisch'     , 'Korean'       ] , _
  12.                                                 ['rus' , 'w2k3|w2k3 x64', 'o2k7|o2k10|o2k13' , 'Russisch'       , 'Russian'      ] , _
  13.                                                 ['ptg' , 'w2k3'         , 'o2k7|o2k10|o2k13' , 'Portugiesisch'  , 'Portuguese'   ] , _
  14.                                                 ['ptb' , 'w2k3|w2k3 x64', 'o2k7|o2k10|o2k13' , 'Brasilianisch'  , 'Brazilian'    ] , _
  15.                                                 ['deu' , 'w2k3|w2k3 x64', 'o2k7|o2k10|o2k13' , 'Deutsch'        , 'German'       ] , _
  16.                                                 ['nld' , 'w2k3'         , 'o2k7|o2k10|o2k13' , 'Niederländisch' , 'Dutch'        ] , _
  17.                                                 ['ita' , 'w2k3'         , 'o2k7|o2k10|o2k13' , 'Italienisch'    , 'Italian'      ] , _
  18.                                                 ['chs' , 'w2k3'         , 'o2k7|o2k10|o2k13' , 'Chin. (simpl.)' , 'Chinese (s.)' ] , _
  19.                                                 ['cht' , 'w2k3'         , 'o2k7|o2k10|o2k13' , 'Chin. (trad.)'  , 'Chinese (tr.)'] , _
  20.                                                 ['plk' , 'w2k3'         , 'o2k7|o2k10|o2k13' , 'Polnisch'       , 'Polish'       ] , _
  21.                                                 ['hun' , 'w2k3'         , 'o2k7|o2k10|o2k13' , 'Ungarisch'      , 'Hungarian'    ] , _
  22.                                                 ['csy' , 'w2k3'         , 'o2k7|o2k10|o2k13' , 'Tschechisch'    , 'Czech'        ] , _
  23.                                                 ['sve' , 'w2k3'         , 'o2k7|o2k10|o2k13' , 'Schwedisch'     , 'Swedish'      ] , _
  24.                                                 ['trk' , 'w2k3'         , 'o2k7|o2k10|o2k13' , 'Türkisch'       , 'Turkish'      ] , _
  25.                                                 ['ell' , 'w2k3'         , 'o2k7|o2k10|o2k13' , 'Griechisch'     , 'Greek'        ] , _
  26.                                                 ['ara' , 'w2k3'         , 'o2k7|o2k10|o2k13' , 'Arabisch'       , 'Arabic'       ] , _
  27.                                                 ['heb' , 'w2k3'         , 'o2k7|o2k10|o2k13' , 'Hebräisch'      , 'Hebrew'       ] , _
  28.                                                 ['dan' , 'w2k3'         , 'o2k7|o2k10|o2k13' , 'Dänisch'        , 'Danish'       ] , _
  29.                                                 ['nor' , 'w2k3'         , 'o2k7|o2k10|o2k13' , 'Norwegisch'     , 'Norwegian'    ] , _
  30.                                                 ['fin' , 'w2k3'         , 'o2k7|o2k10|o2k13' , 'Finnisch'       , 'Finnish'      ] ]
  31.  
  32. ; Not Really Needed, Just for Testing
  33. ;_ArrayDisplay( $aMainArray , 'Test aMainArray:' )
  34. #EndRegion
  35.  
  36.  
  37.  
  38.  
  39. #Region Replaces Current Lines 62-86
  40. ; Create Language Tokens ex. $lang_token_glb
  41. For $ii = 1 To $aMainArray[0][0]
  42.     If $aMainArray[$ii][0] <> '' Then
  43.         Assign( 'lang_token_' & $aMainArray[$ii][0] , $aMainArray[$ii][0] , 2 )
  44.     EndIf
  45. Next
  46.  
  47. ; Not Really Needed, Just for Testing
  48. ;Dim $aLangTokens[1][3] = [['Name:' , 'Declared:' , 'Value:']]
  49. ;For $ii = 1 To $aMainArray[0][0]
  50. ;   If $aMainArray[$ii][0] <> '' Then
  51. ;       $sCurrentVar = 'lang_token_' & $aMainArray[$ii][0]
  52. ;       ReDim $aLangTokens[UBound( $aLangTokens ) + 1][3]
  53. ;       $aLangTokens[UBound( $aLangTokens ) - 1][0] = $sCurrentVar
  54. ;       $aLangTokens[UBound( $aLangTokens ) - 1][1] = IsDeclared( $sCurrentVar )
  55. ;       $aLangTokens[UBound( $aLangTokens ) - 1][2] = Eval( $sCurrentVar )
  56. ;   EndIf
  57. ;Next
  58. ;_ArrayDisplay( $aLangTokens , 'Test Language Tokens:' )
  59. ;MsgBox( 0 , 'Test Language Tokens:' , '$lang_token_glb=' & $lang_token_glb )
  60. #EndRegion
  61.  
  62.  
  63.  
  64.  
  65. #Region Replaces Current Lines 127-154
  66. ; Create Windows Vars ex. $w60_x64_glb
  67. _CreateEmptyVars( 1 )
  68.  
  69. ; Create Office Vars ex. $o2k13_enu
  70. _CreateEmptyVars( 2 )
  71.  
  72. Func _CreateEmptyVars( $iValue )
  73.     For $ii = 1 To $aMainArray[0][0]
  74.         If $aMainArray[$ii][$iValue] <> '' Then
  75.             $aSplit = StringSplit( $aMainArray[$ii][$iValue] , '|' )
  76.             For $jj = 1 To $aSplit[0]
  77.                 Assign( StringReplace( $aSplit[$jj] & ' ' & $aMainArray[$ii][0] , ' ' , '_' ) , '' , 2 )
  78.             Next
  79.         EndIf
  80.     Next
  81. EndFunc
  82.  
  83. ; Not Really Needed, Just for Testing
  84. ;_TestEmptyVars( 1 , 'Test Windows Vars:' )
  85. ;_TestEmptyVars( 2 , 'Test Office Vars:'  )
  86. ;MsgBox( 0 , 'Test Windows Vars:' , '$w60_x64_glb="' & $w60_x64_glb & '"' )
  87. ;MsgBox( 0 , 'Test Office Vars:' , '$o2k13_enu="' & $o2k13_enu & '"' )
  88. ;
  89. ;Func _TestEmptyVars( $iValue , $sTitle )
  90. ;   Local $aEmptyVars[1][3] = [['Name:' , 'Declared:' , 'Value:']]
  91. ;   For $ii = 1 To $aMainArray[0][0]
  92. ;       If $aMainArray[$ii][$iValue] <> '' Then
  93. ;           $aSplit = StringSplit( $aMainArray[$ii][$iValue] , '|' )
  94. ;           For $jj = 1 To $aSplit[0]
  95. ;               $sCurrentVar = StringReplace( $aSplit[$jj] & ' ' & $aMainArray[$ii][0] , ' ' , '_' )
  96. ;               ReDim $aEmptyVars[UBound( $aEmptyVars ) + 1][3]
  97. ;               $aEmptyVars[UBound( $aEmptyVars ) - 1][0] = $sCurrentVar
  98. ;               $aEmptyVars[UBound( $aEmptyVars ) - 1][1] = IsDeclared( $sCurrentVar )
  99. ;               $aEmptyVars[UBound( $aEmptyVars ) - 1][2] = Eval( $sCurrentVar )
  100. ;           Next
  101. ;       EndIf
  102. ;   Next
  103. ;   _ArrayDisplay( $aEmptyVars , $sTitle )
  104. ;EndFunc
  105. #EndRegion
  106.  
  107.  
  108.  
  109.  
  110. #Region Replaces Current Lines 221-370
  111. Func LanguageCaption( $token , $german )
  112.     Local $iFind = _ArraySearch( $aMainArray , $token , 1 , 0 , 0 , 0 , 1 , 0 )
  113.     If $iFind = -1 Then
  114.         Return ''
  115.     Else
  116.         If $german Then
  117.             Return $aMainArray[$iFind][3]
  118.         Else
  119.             Return $aMainArray[$iFind][4]
  120.         EndIf
  121.     EndIf
  122. EndFunc
  123.  
  124. ; Not Really Needed, Just for Testing
  125. ;MsgBox( 0 , 'Test Function Language Caption:' , LanguageCaption( 'ell' , True  ))
  126. ;MsgBox( 0 , 'Test Function Language Caption:' , LanguageCaption( 'ell' , False ))
  127. #EndRegion
  128.  
  129.  
  130.  
  131.  
  132. #Region Replaces Current Lines 384-409
  133. Func IsLangOfficeChecked()
  134.     For $ii = 1 To $aMainArray[0][0]
  135.         If $aMainArray[$ii][2] <> '' Then
  136.             $aSplit = StringSplit( $aMainArray[$ii][2] , '|' )
  137.             For $jj = 1 To $aSplit[0]
  138.                 $sCurrentVar = StringReplace( $aSplit[$jj] & ' ' & $aMainArray[$ii][0] , ' ' , '_' )
  139.                 If IsCheckBoxChecked( Eval( $sCurrentVar )) Then
  140.                     Return IsCheckBoxChecked( Eval( $sCurrentVar ))
  141.                 EndIf
  142.             Next
  143.         EndIf
  144.     Next
  145. EndFunc
  146. #EndRegion
  147.  
  148.  
  149.  
  150.  
  151. #Region Replaces Current Lines 411-527
  152. Func SwitchDownloadTargets( $state )
  153.     $sExempt = 'ell|ara|heb|dan|nor|fin'
  154.     ; Windows
  155.     For $ii = 1 To $aMainArray[0][0]
  156.         If StringInStr( $sExempt , $aMainArray[$ii][0] ) > 0 Then ContinueLoop
  157.         If $aMainArray[$ii][1] <> '' Then
  158.             $aSplit = StringSplit( $aMainArray[$ii][1] , '|' )
  159.             For $jj = 1 To $aSplit[0]
  160.                 $sCurrentVar = StringReplace( $aSplit[$jj] & ' ' & $aMainArray[$ii][0] , ' ' , '_' )
  161.                 GUICtrlSetState( Eval( $sCurrentVar ) , $state )
  162.             Next
  163.         EndIf
  164.     Next
  165.  
  166.     ; Office
  167.     For $ii = 1 To $aMainArray[0][0]
  168.         If $aMainArray[$ii][2] <> '' Then
  169.             $aSplit = StringSplit( $aMainArray[$ii][2] , '|' )
  170.             For $jj = 1 To $aSplit[0]
  171.                 $sCurrentVar = StringReplace( $aSplit[$jj] & ' ' & $aMainArray[$ii][0] , ' ' , '_' )
  172.                 GUICtrlSetState( Eval( $sCurrentVar ) , $state )
  173.             Next
  174.         EndIf
  175.     Next
  176.     Return 0
  177. EndFunc
  178. #EndRegion
  179.  
  180.  
  181.  
  182.  
  183. #Region Replaces Current Lines 956-1106
  184. Func SaveSettings()
  185.     ; Windows
  186.     _SaveSettingsWindowsAndOffice( 1 )
  187.  
  188.     ; Office
  189.     _SaveSettingsWindowsAndOffice( 2 )
  190.  
  191.     ; Image creation
  192.     IniWrite( $inifilename , $ini_section_iso , $iso_token_cd      , CheckBoxStateToString( $cdiso   ))
  193.     IniWrite( $inifilename , $ini_section_iso , $iso_token_dvd     , CheckBoxStateToString( $dvdiso  ))
  194.     IniWrite( $inifilename , $ini_section_usb , $usb_token_copy    , CheckBoxStateToString( $usbcopy ))
  195.     IniWrite( $inifilename , $ini_section_usb , $usb_token_path    , GUICtrlRead( $usbpath ))
  196.     IniWrite( $inifilename , $ini_section_usb , $usb_token_cleanup , CheckBoxStateToString( $usbclean))
  197.  
  198.     ; Miscellaneous
  199.     IniWrite( $inifilename , $ini_section_opts , $opts_token_verify        , CheckBoxStateToString( $verifydownloads ))
  200.     IniWrite( $inifilename , $ini_section_opts , $opts_token_includesp     , CheckBoxStateToString( $includesp ))
  201.     IniWrite( $inifilename , $ini_section_opts , $opts_token_includedotnet , CheckBoxStateToString( $dotnet ))
  202.     IniWrite( $inifilename , $ini_section_opts , $opts_token_wle           , CheckBoxStateToString( $wle    ))
  203.     IniWrite( $inifilename , $ini_section_opts , $opts_token_msse          , CheckBoxStateToString( $msse   ))
  204.     IniWrite( $inifilename , $ini_section_opts , $opts_token_wddefs        , CheckBoxStateToString( $wddefs ))
  205.     IniWrite( $inifilename , $ini_section_misc , $misc_token_proxy         , $proxy )
  206.     IniWrite( $inifilename , $ini_section_misc , $misc_token_wsus          , $wsus  )
  207.  
  208.     Return 0
  209. EndFunc
  210.  
  211. Func _SaveSettingsWindowsAndOffice( $iValue )
  212.     For $ii = 1 To $aMainArray[0][0]
  213.         If $aMainArray[$ii][$iValue] <> '' Then
  214.             $aSplit = StringSplit( $aMainArray[$ii][$iValue] , '|' )
  215.             For $jj = 1 To $aSplit[0]
  216.                 $sCurrentSec = StringReplace( 'ini section '     & $aSplit[$jj]        , ' ' , '_' )
  217.                 $sCurrentKey = StringReplace( 'lang token '      & $aMainArray[$ii][0] , ' ' , '_' )
  218.                 $sCurrentVal = StringReplace( $aSplit[$jj] & ' ' & $aMainArray[$ii][0] , ' ' , '_' )
  219.                 IniWrite(  $inifilename _
  220.                             , Eval( $sCurrentSec ) _
  221.                             , Eval( $sCurrentKey ) _
  222.                             , CheckBoxStateToString( Eval( $sCurrentVal )))
  223.             Next
  224.         EndIf
  225.     Next
  226. EndFunc
  227. #EndRegion
  228.  
  229.  
  230.  
  231.  
  232. #Region Replaces Current Lines 2733-3316
  233.         $sExempt = 'ell|ara|heb|dan|nor|fin'
  234.         ; Windows
  235.         For $ii = 1 To $aMainArray[0][0]
  236.             If $aMainArray[$ii][1] <> '' Then
  237.                 $aSplit = StringSplit( $aMainArray[$ii][1] , '|' )
  238.                 For $jj = 1 To $aSplit[0]
  239.                     If StringInStr( $aSplit[$jj] , 'w2k3' ) > 0 Then
  240.                         If StringInStr( $sExempt , $aMainArray[$ii][0] ) > 0 Then ContinueLoop
  241.                     EndIf
  242.                     $sCurrentVar1 = StringReplace( $aSplit[$jj] & ' ' & $aMainArray[$ii][0] , ' ' , '_' )
  243.                     $sCurrentVar2 = StringReplace( $aSplit[$jj] , ' ' , '-' ) & ' ' & $aMainArray[$ii][0]
  244.                     If IsCheckBoxChecked( Eval( $sCurrentVar1 )) Then
  245.                         If RunScripts( $sCurrentVar2 , IsCheckBoxChecked( $imageonly ) , DetermineDownloadSwitches( $includesp , $dotnet , $wle , $msse , $wddefs , $verifydownloads , AuthProxy( $proxy , $proxypwd ) , $wsus ) , IsCheckBoxChecked( $cdiso ) , DetermineISOSwitches( $includesp , $dotnet , $wle , $msse , $wddefs , $usbclean ) , IsCheckBoxChecked( $usbcopy ) , GUICtrlRead( $usbpath )) <> 0 Then
  246.                             ContinueLoop 3
  247.                         EndIf
  248.                     EndIf
  249.                 Next
  250.             EndIf
  251.         Next
  252.  
  253.         ; Office Global
  254.         If IsLangOfficeChecked() Then
  255.             If RunScripts( 'ofc glb' , IsCheckBoxChecked( $imageonly ) , DetermineDownloadSwitches( $includesp , $dotnet , $wle , $msse , $wddefs , $verifydownloads , AuthProxy( $proxy , $proxypwd ) , $wsus) , False , DetermineISOSwitches( $includesp , $dotnet , $wle , $msse , $wddefs , $usbclean ) , False , GUICtrlRead( $usbpath )) <> 0 Then
  256.                 ContinueLoop
  257.             EndIf
  258.         EndIf
  259.  
  260.         ; Office
  261.         For $ii = 1 To $aMainArray[0][0]
  262.             If $aMainArray[$ii][2] <> '' Then
  263.                 $aSplit = StringSplit( $aMainArray[$ii][2] , '|' )
  264.                 For $jj = 1 To $aSplit[0]
  265.                     $sCurrentVar = StringReplace( $aSplit[$jj] & ' ' & $aMainArray[$ii][0] , ' ' , '_' )
  266.                     If IsCheckBoxChecked( Eval( $sCurrentVar )) Then
  267.                         If RunScripts( $aSplit[$jj] & ' ' & $aMainArray[$ii][0] , IsCheckBoxChecked( $imageonly ) , DetermineDownloadSwitches( $includesp , $dotnet , $wle , $msse , $wddefs , $verifydownloads , AuthProxy( $proxy , $proxypwd ) , $wsus) , False , DetermineISOSwitches( $includesp , $dotnet , $wle , $msse , $wddefs , $usbclean ) , False , GUICtrlRead( $usbpath )) <> 0 Then
  268.                             ContinueLoop 3
  269.                         EndIf
  270.                     EndIf
  271.                 Next
  272.             EndIf
  273.         Next
  274. #EndRegion
  275.  
  276.  
  277.  
  278.  
  279. #Region Replaces Current Lines 3318-3438
  280.         ; Office Language Specific
  281.         For $ii = 1 To $aMainArray[0][0]
  282.             If $aMainArray[$ii][2] <> '' Then
  283.                 $aSplit = StringSplit( $aMainArray[$ii][2] , '|' )
  284.                 For $jj = 1 To $aSplit[0]
  285.                     $sCurrentVal = StringReplace( $aSplit[$jj] & ' ' & $aMainArray[$ii][0] , ' ' , '_' )
  286.                     If IsCheckBoxChecked( Eval( $sCurrentVal )) Then
  287.                         If RunScripts( 'ofc ' & $aMainArray[$ii][0] , True , DetermineDownloadSwitches( $includesp , $dotnet , $wle , $msse , $wddefs , $verifydownloads , AuthProxy( $proxy , $proxypwd ) , $wsus) , IsCheckBoxChecked( $cdiso ) , DetermineISOSwitches( $includesp , $dotnet , $wle , $msse , $wddefs , $usbclean ) , IsCheckBoxChecked( $usbcopy ) , GUICtrlRead( $usbpath )) <> 0 Then
  288.                             ContinueLoop 3
  289.                         EndIf
  290.                     EndIf
  291.                 Next
  292.             EndIf
  293.         Next
  294. #EndRegion
  295.  
  296.  
  297.  
  298.  
  299. #Region Replaces Current Lines 3440-3562
  300.         ; Create cross-platform DVD ISO images
  301.         If IsCheckBoxChecked( $dvdiso ) Then
  302.             ; Windows Server 2003
  303.             For $ii = 1 To $aMainArray[0][0]
  304.                 If StringInStr( $aMainArray[$ii][1] , 'w2k3' ) = 0 Then ContinueLoop
  305.                 If IsCheckBoxChecked( Eval( 'w2k3_' & $aMainArray[$ii][0] )) Then
  306.                     If RunISOCreationScript( Eval( 'lang_token_' & $aMainArray[$ii][0] ) , DetermineISOSwitches( $includesp , $dotnet , $wle , $msse , $wddefs , $usbclean )) <> 0 Then
  307.                         ContinueLoop 2
  308.                     EndIf
  309.                 EndIf
  310.             Next
  311.             ; Office
  312.             For $ii = 1 To $aMainArray[0][0]
  313.                 If $aMainArray[$ii][2] <> '' Then
  314.                     $aSplit = StringSplit( $aMainArray[$ii][2] , '|' )
  315.                     For $jj = 1 To $aSplit[0]
  316.                         $sCurrentVal = StringReplace( $aSplit[$jj] & ' ' & $aMainArray[$ii][0] , ' ' , '_' )
  317.                         If IsCheckBoxChecked( Eval( $sCurrentVal )) Then
  318.                             If RunISOCreationScript( Eval( 'lang_token_' & $aMainArray[$ii][0] ) , DetermineISOSwitches( $includesp , $dotnet , $wle , $msse , $wddefs , $usbclean )) <> 0 Then
  319.                                 ContinueLoop 3
  320.                             EndIf
  321.                         EndIf
  322.                     Next
  323.                 EndIf
  324.             Next
  325.         EndIf
  326. #EndRegion
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement