Neejay Posted February 6, 2014 Share Posted February 6, 2014 (edited) I have functions that run MS patches and any software updates I include. I've setup the manual way of creating a progressbar: Snippet: ... ProgressOn("W7 Patch Installation", "Completion:", "0 percent completed.", "", "", 16) _PatchMSU("11-024-KB2491683") ProgressSet(1, "1% completed") _PatchMSU("11-024-KB2506212") ProgressSet(2, "2% completed") _PatchMSU("11-030-KB2509553") ProgressSet(3, "3% completed") ;<-- this is the code for other patches and software until 100 "ProgressSet(100, "Done!", "Complete")" ProgressOff() ... Now, this works...but when I started deleting and adding patches, it's too tedious to manually have to do "ProgressSet(x, "x% completed")" after counting and dividing EACH function (i.e. I removed about 5 patches, but added 43 more). I was trying to research away to maybe place a marker by each function (like a +1 to be automatically included in the progressset) OR something that says "for each function, do a ProgressSet+1" and then automatically calculate what each function's percentage is, regardless of how many I put in my script. Hopefully that makes sense... Edited February 6, 2014 by Neejay Link to comment Share on other sites More sharing options...
Valuater Posted February 6, 2014 Share Posted February 6, 2014 Maybe this idea... Global $Count = 43 Global $Process = 100 / $Count For $x = 1 To $Count MsgBox(0, "Progress", "Progress = " & Int(Round($x * $Process, 2)) & "%", 3) Next Link to comment Share on other sites More sharing options...
BrewManNH Posted February 6, 2014 Share Posted February 6, 2014 (edited) To get the percentage you would take the current item and divide it by the total number of items to process and multiply by 100. For example, you have 20 items to process, and you're on the 3rd one done, you would do something like this. $iNumberOfItems = 20 $iCurrentItem = 3 $iPercentage = Int(($iCurrentItem/$iNumberOfItems) * 100) This will give you a value of $iPercentage of 15%. The easiest way to keep track of the items to process, and your current progress in doing it, is to put everything into an array and use a For/Next loop to loop through the array items. Using the current loop count of the For loop you can get your percentage easily. $iNumberOfItems = 3 ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $iPercentage = ' & $iPercentage & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console Global $aItems[3] = ["11-024-KB2491683", "11-024-KB2506212", "11-030-KB2509553"] ProgressOn("W7 Patch Installation", "Completion:", "0 percent completed.", "", "", 16) For $iCurrentItem = 0 To $iNumberOfItems _PatchMSU($aItems[$iCurrentItem]) $iPercentage = Int(($iCurrentItem / $iNumberOfItems) * 100) ProgressSet($iPercentage, "1% completed") Next "ProgressSet(100, " Done!", " Complete")" ProgressOff() Instead of hardcoding your items in the script, you could create a text file with a single patch name per line, using FileReadToArray and Ubound you can create the array from the file. Edited February 6, 2014 by BrewManNH Neejay 1 If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
Neejay Posted February 7, 2014 Author Share Posted February 7, 2014 (edited) Thanks a lot for your replies. BrewManNH: I'm still trying to learn arrays, thanks. I use the .MSU patch files, and also the .EXE patches (Office patches). How could I incorporate it into what you wrote? Create a $aItems2 and be sure to include it into the $iNumberOfItems? _PatchMSU("13-063-KB2859537-x86") _PatchMSU("13-065-KB2868623-x86") _PatchEXE("13-068-kb2794707-O2010") _PatchMSU("13-069-KB2870699-x86") _PatchEXE("13-074-kb2687423-O2010") Edited February 7, 2014 by Neejay Link to comment Share on other sites More sharing options...
BrewManNH Posted February 7, 2014 Share Posted February 7, 2014 Without seeing what is inside your 2 functions I'd be unable to tell you what would be the best way. You could probably combine your exe and msu functions into one function. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
Neejay Posted February 7, 2014 Author Share Posted February 7, 2014 Without seeing what is inside your 2 functions I'd be unable to tell you what would be the best way. You could probably combine your exe and msu functions into one function. Understood...I'll work on combining them. Here's what they are currently: Func _PatchMSU($KB_Name) $KB_Number = StringTrimLeft($KB_Name, 7) _ArraySearch($aHotFixList, $KB_Number) If @error <> 0 Then $inst = Run(@ComSpec & " /c " & $Patches & $KB_Name & ".msu /quiet /norestart", "", @SW_HIDE) While ProcessExists($inst) TrayTip("Installing " & "MS" & StringLeft($KB_Name, 6), "Please be patient.", 5) Sleep(250) WEnd TrayTip("x", "", 0) _FileWriteLog($Timelog, "Installed MS" & $KB_Name) EndIf EndFunc ;==>_PatchMSU Func _PatchEXE($KB_Name) $KB_Number = StringTrimLeft($KB_Name, 7) _ArraySearch($aHotFixList, $KB_Number) If @error <> 0 Then $inst = Run(@ComSpec & " /c " & $Patches & $KB_Name & ".exe /passive /norestart", "", @SW_HIDE) While ProcessExists($inst) TrayTip("Installing " & "MS" & StringLeft($KB_Name, 6), "Please be patient.", 5) Sleep(250) WEnd TrayTip("x", "", 0) _FileWriteLog($Timelog, "Installed MS" & $KB_Name) EndIf EndFunc ;==>_PatchEXE Link to comment Share on other sites More sharing options...
BrewManNH Posted February 7, 2014 Share Posted February 7, 2014 Would it be possible to post the whole script? There are a lot of variables that aren't defined that would be helpful to know their contents. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
Neejay Posted February 7, 2014 Author Share Posted February 7, 2014 Would it be possible to post the whole script? There are a lot of variables that aren't defined that would be helpful to know their contents. Yep. I was in the middle of modifying the patch list to conform to your example code, so the syntax for that section non existant: expandcollapse popup#region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Outfile=..\x86_TEST.exe #AutoIt3Wrapper_Res_requestedExecutionLevel=asInvoker #endregion ;**** Directives created by AutoIt3Wrapper_GUI **** ;------------------------------------------------- ;- 1/3/14 ; * Finalized DT, WMDC checks ; * Re-organized "Installed Versions ;- 2/4/14 ; * Updated MS patches ;------------------------------------------------- #include <file.au3> #include <array.au3> #include <Misc.au3> #include <ProgressConstants.au3> #include <GUIConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <ButtonConstants.au3> #include <StaticConstants.au3> #include <GuiComboBox.au3> Global $aHotFixList, $ProgAdd, $ProgressBar Dim $Timelog = "c:\temp\patchinst\time.log" Dim $StartTime = @HOUR & ":" & @MIN Dim $Patches = @ScriptDir & "\Patches\W7\" ; Path must have the trailing \ Dim $Dept = StringTrimRight(StringTrimLeft(@ComputerName, 5), 5) Dim $PuttyUpdater = IniRead(@ScriptDir & "\PatchInst.ini", "PuttyUpdater", "Inst", "Not Found") Dim $PatchInstallLog = @ScriptDir & "\Logs\W7_PatchInstall.log" Dim $PSVersion = FileGetVersion("C:\Program Files\Pointsec\Pointsec for PC\P95tray.exe") Dim $WMPVer = StringLeft(FileGetVersion("c:\Program Files\Windows Media Player\wmplayer.exe"), 2) Dim $SapInstallLog = @ScriptDir & "\Apps\SAP\SAP_Upgrade.log" Dim $PCName = @ComputerName ;Dim $Progress1 = GUICtrlCreateProgress(8, 416, 614, 17) DirCreate("C:\Temp\PatchInst") If Not FileExists("C:\Temp\PatchInst\time.log") Then _FileCreate("c:\temp\patchinst\time.log") EndIf _FileWriteLog($Timelog, "Start time") DirCreate("C:\Admin_Software") FileSetAttrib("C:\Admin_Software", "+SH") DirCreate("C:\Admin_Software\WMDC") DirCreate("C:\Admin_Software\Citrix") Run(@ComSpec & " /c powercfg -h off", "", @SW_HIDE) RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Communicator", "TourPlayed", "REG_DWORD", "1") RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Communicator", "AutoRunWhenLogonToWindows", "REG_DWORD", "0") RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Communicator", "AutoOpenMainWindowWhenStartup", "REG_DWORD", "0") $aHotFixList = _GetHotFixes() _Office() ;ProgressOn("W7 Patch Installation", "Completion:", "0 percent completed.", "", "", 16) $iNumberOfItems = 3 ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $iPercentage = ' & $iPercentage & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console Global $aItems[3] = ["11-024-KB2491683", _ "11-024-KB2506212", _ "11-030-KB2509553"] 11-024-KB2491683", _ 11-024-KB2506212 11-030-KB2509553 11-037-KB2544893 11-043-KB2536276 11-048-KB2536275 11-053-KB2532531 11-071-KB2570947 11-092-KB2619339 12-004-KB2631813 12-013-KB2654428 12-020-KB2667402 12-024-KB2653956 12-036-KB2685939 12-037-KB2699988 12-041-KB2709162 12-043-KB2719985 12-045-KB2698365 12-046-KB2596744 12-048-KB2691442 12-049-KB2655992 12-052-KB2722913 12-053-KB2723135 12-054-KB2705219 12-054-KB2712808 12-055-KB2731847 12-007-KB2607664 12-068-KB2724197 12-069-KB2743555 12-072-KB2727528 12-074-KB2729451 12-075-KB2761226 13-008-KB2799329 13-027-KB2807986 13-029-KB2813347 13-032-KB2772930 13-036-KB2840149 13-050-KB2839894 13-054-KB2834886 13-054-KB2835364 13-056-KB2845187 13-057-KB2803821 13-059-KB2862772 13-062-KB2849470-x86 13-063-KB2859537-x86 13-065-KB2868623-x86 _PatchEXE("13-068-kb2794707-O2010") 13-069-KB2870699-x86 _PatchEXE("13-074-kb2687423-O2010") 13-076-KB2876315-x86 13-077-KB2872339-x86 13-080-KB2879017-x86 13-081-KB2847311-x86 13-081-KB2855844-x86 13-081-KB2862330-x86 13-081-KB2862335-x86 13-081-KB2864202-x86 13-081-KB2868038-x86 13-081-KB2876284-x86 13-081-KB2883150-x86 13-081-KB2884256-x86 13-083-KB2864058-x86 _PatchEXE("13-085-kb2826023-O2010") _PatchEXE("13-085-kb2826033-O2010") _PatchEXE("13-085-kb2826035-O2010") 13-088-KB2888505-x86 13-089-KB2876331-x86 13-090-KB2900986-x86 _PatchEXE("13-091-kb2553284-O2010") _PatchEXE("13-091-kb2760781-O2010") _PatchEXE("13-094-kb2837597-O2010") 13-095-KB2868626-x86 _PatchEXE("13-096-kb2817670-O2010") 13-097-KB2898785-x86 13-098-KB2893294-x86 13-099-KB2892074-x86 13-101-KB2887069-x86 _PatchEXE("13-106-kb2850016-O2010") _PatchEXE("14-001-kb2863901-O2010") _PatchEXE("14-001-kb2863902-O2010") 14-003-KB2913602-x86 ProgressOn("W7 Patch Installation", "Completion:", "0 percent completed.", "", "", 16) For $iCurrentItem = 0 To $iNumberOfItems _PatchMSU($aItems[$iCurrentItem]) $iPercentage = Int(($iCurrentItem / $iNumberOfItems) * 100) ProgressSet($iPercentage, "1% completed") Next "ProgressSet(100, " Done!", " Complete")" ProgressOff() If Not NetInstalled("KB2737019") Then _PatchEXE("12-074-KB2737019") ;.NET EndIf ProgressSet(61, "61% completed.") If Not NetInstalled("KB2789642") Then _PatchEXE("13-015-KB2789642") ;.NET EndIf ProgressSet(62, "62% completed.") If Not NetInstalled("KB2804576") Then _PatchEXE("13-040-KB2804576") ;.NET EndIf ProgressSet(63, "63% completed.") If Not NetInstalled("KB2835393") Then _PatchEXE("13-052-KB2835393") ;.NET EndIf ProgressSet(64, "64% completed.") If Not NetInstalled("KB2840628") Then _PatchEXE("13-052-KB2840628") ;.NET EndIf ProgressSet(60, "60% completed.") If Not NetInstalled("KB2858302") Then _PatchEXE("13-082-KB2858302-x86") ;.NET EndIf FileCopy(@ScriptDir & "\Apps\WMDC\drvupdate-x86.exe", "C:\Admin_Software\WMDC") FileCopy(@ScriptDir & "\Apps\Citrix\Receiver.msi", "C:\Admin_Software\Citrix") _InstQWS() _QWSSP() ProgressSet(65, "65% completed") _Entrust() _Entrust_instructions() ProgressSet(70, "70% completed") _SuperDAT() _InstSilverlight() ProgressSet(75, "75% completed") _epoupdate() ProgressSet(80, "80% completed") _CiscoUpdate() _CiscoDelete() ProgressSet(85, "85% completed") _sccm() _sapupgrade() ProgressSet(90, "90% completed") If $Dept = "ENCNS" Then _Putty() _PuttyUpdater() ProgressSet(95, "95% completed") _HyperTerm() ElseIf $Dept = "ENMWS" Then _WMDC() ProgressSet(95, "95% completed") EndIf $sSerial = _BiosGetSerialNumber() _FileWriteLog($PatchInstallLog, @ComputerName & " " & $sSerial) ProgressSet(100, "Done!", "Complete") _GetSoftwareVersions() _FileWriteLog($Timelog, "*******************************************") _FileWriteLog($Timelog, "************* Script Complete *************") _FileWriteLog($Timelog, "*******************************************") $Reboot = MsgBox(262193, "The System Needs To Restart", "The computer must restart to apply security updates." & @CRLF & "Select OK to reboot now or Cancel to reboot later.") If $Reboot = 1 Then Shutdown(6) ProgressOff() #region Functions #region Patch Func _PatchMSU($KB_Name) $KB_Number = StringTrimLeft($KB_Name, 7) _ArraySearch($aHotFixList, $KB_Number) If @error <> 0 Then $inst = Run(@ComSpec & " /c " & $Patches & $KB_Name & ".msu /quiet /norestart", "", @SW_HIDE) While ProcessExists($inst) TrayTip("Installing " & "MS" & StringLeft($KB_Name, 6), "Please be patient.", 5) Sleep(250) WEnd TrayTip("x", "", 0) _FileWriteLog($Timelog, "Installed MS" & $KB_Name) EndIf EndFunc ;==>_PatchMSU Func _PatchEXE($KB_Name) $KB_Number = StringTrimLeft($KB_Name, 7) _ArraySearch($aHotFixList, $KB_Number) If @error <> 0 Then $inst = Run(@ComSpec & " /c " & $Patches & $KB_Name & ".exe /passive /norestart", "", @SW_HIDE) While ProcessExists($inst) TrayTip("Installing " & "MS" & StringLeft($KB_Name, 6), "Please be patient.", 5) Sleep(250) WEnd TrayTip("x", "", 0) _FileWriteLog($Timelog, "Installed MS" & $KB_Name) EndIf EndFunc ;==>_PatchEXE Func _GetHotFixes() Local $oColItems, $oWMIService, $sOutput $oWMIService = ObjGet("winmgmts:\\" & @ComputerName & "\root\CIMV2") $oColItems = $oWMIService.ExecQuery("Select HotFixID From Win32_QuickFixEngineering", "WQL", 0x30) For $oItem In $oColItems $sOutput &= $oItem.HotFixID & ";" Next Return StringSplit(StringTrimRight($sOutput, 1), ";") EndFunc ;==>_GetHotFixes ;Useage: ;If AppInstalled({B43357AA-3A6D-4D94-B56E-43C44D09E548}) Then MsgBox(16, "Test", "It is installed") Func NetInstalled($GUID) $Uninstall = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{3C3901C5-3455-3E0A-A214-0B093A5070A6}." & $GUID, "DisplayVersion") If @error Then Return False Else Return True EndIf EndFunc ;==>NetInstalled #endregion Patch #region Microsoft Func _Office() $office_check = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Office14.PROPLUS", "DisplayVersion") If _VersionCompare($office_check, "14.0.7015.1000") = -1 Then $office_update = Run(@ComSpec & " /c " & @ScriptDir & "\Patches\W7\office2010sp2-kb2687455.exe /passive", "", @SW_HIDE) While ProcessExists($office_update) TrayTip("Installing SP2 for Office 2010", "Please be patient. " & $office_update, 5) Sleep(250) WEnd TrayTip("x", "", 0) _FileWriteLog($Timelog, "Installed SP2 for OFfice 2010") EndIf EndFunc #endregion Microsoft Func _InstQWS() If Not FileExists(@ProgramFilesDir & "\QWS3270 Plus\qws3270p.exe") Then AdlibRegister("_WinTitle") $QWS = Run(@ComSpec & " /c " & @ScriptDir & "\Apps\QWS\qws3270Plus4.7.msi /passive", "", @SW_HIDE) While ProcessExists($QWS) ;ProgressSet(10, "Installing QWS...") TrayTip("Installing QWS", "Please be patient. " & $QWS, 5) Sleep(250) WEnd TrayTip("x", "", 0) _FileWriteLog($Timelog, "Installed QWS 4.7.2") AdlibUnRegister() EndIf EndFunc ;==>_InstQWS Func _QWSSP() $QWSVer = FileGetVersion(@ProgramFilesDir & "\QWS3270 Plus\qws3270p.exe") If _VersionCompare($QWSVer, "4.7.2.1") = -1 Then $QWSSP = Run(@ComSpec & " /c " & @ScriptDir & "\Apps\QWS\Upgrade472.exe /s", "", @SW_HIDE) While ProcessExists($QWSSP) ;ProgressSet(10, "Installing QWS Upgrade...") TrayTip("Installing QWS SP", "Please be patient. " & $QWSSP, 5) Sleep(250) WEnd EndIf EndFunc ;==>_QWSSP Func _Entrust() If Not FileExists(@ProgramFilesDir & "\Entrust\IdentityGuard Soft Token\SoftToken.exe") Then AdlibRegister("_WinTitle") $Entrust = Run(@ComSpec & " /c " & @ScriptDir & "\Apps\Entrust\IGSoftToken_Win.msi /passive", "", @SW_HIDE) While ProcessExists($Entrust) ;ProgressSet(15, "Installing Entrust Soft Token...") TrayTip("Installing Entrust Soft Token", "Please be patient. " & $Entrust, 5) Sleep(250) WEnd TrayTip("x", "", 0) _FileWriteLog($Timelog, "Installed Endtrust Soft Token") AdlibUnRegister() EndIf EndFunc ;==>_Entrust Func _Entrust_instructions() DirCopy(@ScriptDir & "\Apps\Entrust\Recreating Entrust Soft Token\", "C:\users\Default\Desktop\Recreating Entrust Soft Token\", 1) EndFunc ;==>_Entrust_instructions Func _SuperDAT() $Search = FileFindFirstFile(@ScriptDir & "\Apps\McAfee\SuperDAT\*.*") $SDAT_Name = FileFindNextFile($Search) $SuperDAT = Run(@ComSpec & " /c " & @ScriptDir & "\Apps\McAfee\SuperDAT\" & $SDAT_Name & " /LOGFILE C:\temp\patchinst\" & $SDAT_Name & ".log /silent", "", @SW_HIDE) While ProcessExists($SuperDAT) ;ProgressSet(20, "Installing SuperDAT...") TrayTip("Installing McAfee DAT file", "Please be patient", 5) Sleep(250) WEnd TrayTip("x", "", 0) FileClose($Search) EndFunc ;==>_SuperDAT Func _InstSilverlight() $SilverlightVer = FileGetVersion("C:\Program Files\Microsoft Silverlight\sllauncher.exe", "ProductVersion") If Not FileExists("C:\Program Files\Microsoft Silverlight\sllauncher.exe") Then $Silverlight = Run(@ComSpec & " /c " & @ScriptDir & "\Apps\Silverlight\Silverlight.exe /q", "", @SW_HIDE) While ProcessExists($Silverlight) ;ProgressSet(25, "Installing MS Silverlight...") TrayTip("Installing Microsoft Silverlight", "Please be patient. " & $Silverlight, 5) Sleep(250) WEnd TrayTip("x", "", 0) _FileWriteLog($Timelog, "Installed Silverlight 5.1.20913.0") ElseIf _VersionCompare($SilverlightVer, "5.1.20913.0") = -1 Then $Silverlight = Run(@ComSpec & " /c " & @ScriptDir & "\Apps\Silverlight\Silverlight.exe /q", "", @SW_HIDE) While ProcessExists($Silverlight) ;ProgressSet(25, "Installing MS Silverlight...") TrayTip("Installing Microsoft Silverlight", "Please be patient. " & $Silverlight, 5) Sleep(250) WEnd TrayTip("x", "", 0) _FileWriteLog($Timelog, "Installed Silverlight 5.1.20913.0") EndIf EndFunc ;==>_InstSilverlight Func _epoupdate() $Agent = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Network Associates\ePolicy Orchestrator\Application Plugins\EPOAGENT3000", "Version") If _VersionCompare($Agent, "4.6.0.3122") = -1 Then $Agentupdate = Run(@ComSpec & " /c " & @ScriptDir & "\Apps\FramePkg.exe /INSTALL=AGENT /s", "", @SW_HIDE) While ProcessExists($Agentupdate) TrayTip("Upgrading ePO to 4.6", "Please be patient. " & $Agentupdate, 5) Sleep(250) WEnd TrayTip("x", "", 0) _FileWriteLog($Timelog, "Upgraded ePO to 4.6") Else If _VersionCompare($Agent, "4.6.0.3122") = 0 Then EndIf EndIf EndFunc ;==>_epoupdate Func _CiscoUpdate() $vpncheck = FileGetVersion("C:\Program Files\Cisco\Cisco AnyConnect VPN Client\vpnui.exe") If _VersionCompare($vpncheck, "3.0.11042.0") = -1 Then AdlibRegister("_WinTitle") $vpnupdate = Run(@ComSpec & " /c " & @ScriptDir & "\Apps\AnyConnect\anyconnect-win-3.0.11042-pre-deploy-k9.msi /passive", "", @SW_HIDE) While ProcessExists($vpnupdate) TrayTip("Upgrading Cisco AnyConnect Client to 3.0", "Please be patient. " & $vpnupdate, 5) Sleep(250) WEnd TrayTip("x", "", 0) FileCopy(@ScriptDir & "\Apps\AnyConnect\nsc2anyconnectvpnprofile01.xml", "C:\ProgramData\Cisco\Cisco AnyConnect Secure Mobility Client\Profile") RegDelete("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run", "Cisco AnyConnect Secure Mobility Agent for Windows") _FileWriteLog($Timelog, "Upgraded Cisco Client to 3.0.11042.0") AdlibUnRegister() Else If _VersionCompare($vpncheck, "3.0.11042.0") = 0 Then EndIf EndIf EndFunc ;==>_CiscoUpdate Func _CiscoDelete() $Search = FileFindFirstFile("C:\Users\*.*") ; Check if the search was successful If $Search = -1 Then MsgBox(0, "Error", "No files/directories matched the search pattern") Exit EndIf While 1 $file = FileFindNextFile($Search) If $file = "" Then ExitLoop ConsoleWrite("Directory: " & $file & @CRLF) If @error Then ExitLoop If $file = "Default" Then ConsoleWrite("Directory: " & $file & " skipped" & @CRLF) ContinueLoop EndIf If $file = "Default User" Then ConsoleWrite("Directory: " & $file & " skipped" & @CRLF) ContinueLoop EndIf If $file = "All Users" Then ConsoleWrite("Directory: " & $file & " skipped" & @CRLF) ContinueLoop EndIf If $file = "Public" Then ConsoleWrite("Directory: " & $file & " skipped" & @CRLF) ContinueLoop EndIf If Not StringInStr(FileGetAttrib("C:\Users\" & $file), "D") Then ConsoleWrite("File: " & $file & " skipped" & @CRLF) ContinueLoop EndIf ; Process directory If FileExists("C:\Users\" & $file & "\Desktop\Cisco AnyConnect VPN Client.lnk") Then $Status = FileDelete("C:\Users\" & $file & "\Desktop\Cisco AnyConnect VPN Client.lnk") ConsoleWrite("C:\Users\" & $file & "\Desktop\Cisco AnyConnect VPN Client.lnk" & @CRLF) If $Status = 1 Then ConsoleWrite("Clean Temp successful : " & $file & @CRLF) Else ConsoleWrite("*** Clean Temp failed *** : " & $file & @CRLF) EndIf Else ConsoleWrite("C:\Users\" & $file & "\Desktop\Cisco AnyConnect VPN Client.lnk : not found" & @CRLF) EndIf WEnd ; Close the search handle FileClose($Search) EndFunc ;==>_CiscoDelete Func _sapupgrade() $sapcheck = RegRead("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Uninstall\SAPBI", "DisplayVersion") If @error <> 0 Then _FileWriteLog($Timelog, "SAP Upgrade not needed.") Else If _VersionCompare($sapcheck, "7.30") = -1 Then $sapupdate = Run(@ComSpec & " /c " & @ScriptDir & "\Apps\SAP\SAPGUI730_ATTENDED.EXE", "", @SW_HIDE) WinWaitActive("SAP GUI for Windows 7.30 Compilation 2 Hotfix1 for Patch 4") ControlClick("SAP GUI for Windows 7.30 Compilation 2 Hotfix1 for Patch 4", "", 4) WinWaitActive("SAP GUI for Windows 7.30") ControlClick("SAP GUI for Windows 7.30", "", 4) While ProcessExists($sapupdate) TrayTip("Upgrading SAP GUI to 7.30", "Please be patient. " & $sapupdate, 5) Sleep(250) WEnd _FileWriteLog($Timelog, "Upgraded SAP GUI to 7.30") $sSerial = _BiosGetSerialNumber() _FileWriteLog($SapInstallLog, @ComputerName & " " & $sSerial) ;_FileCreate(@ScriptDir & "\Apps\SAP\" & $PCName & ".log") Else If _VersionCompare($sapcheck, "7.30") = 0 Then EndIf EndIf EndIf EndFunc ;==>_sapupgrade Func _sccm() If Not ProcessExists("ccmexec.exe") Then $sccm = @ScriptDir & "\Apps\SCCM\SCCM\install.bat" RunWait($sccm) While ProcessExists("ccmsetup.exe") TrayTip("Installing the SCCM Client", "Please be patient.", 5) Sleep(250) WEnd EndIf EndFunc ;==>_sccm #region CNS Func _Putty() If Not FileExists(@ProgramFilesDir & "\PuTTY\putty.exe") Then DirCreate(@ProgramFilesDir & "\PuTTY") FileCopy(@ScriptDir & "\Apps\putty.exe", @ProgramFilesDir & "\PuTTY\") FileCreateShortcut(@ProgramFilesDir & "\PuTTY\putty.exe", @DesktopCommonDir & "\PuTTY.lnk") _FileWriteLog($Timelog, "Installed PuTTY") EndIf EndFunc ;==>_Putty Func _PuttyUpdater() ; $PuttyUpdater = IniRead(@ScriptDir & "\PatchInst.ini", "PuttyUpdater", "Inst", "Not Found") If Not FileExists(@ProgramFilesDir & "\PuTTY\" & $PuttyUpdater) Then FileCopy(@ScriptDir & "\Apps\" & $PuttyUpdater, @ProgramFilesDir & "\PuTTY\") FileCreateShortcut(@ProgramFilesDir & "\PuTTY\" & $PuttyUpdater, @DesktopCommonDir & "\" & $PuttyUpdater & ".lnk") _FileWriteLog($Timelog, "Installed " & $PuttyUpdater) EndIf EndFunc ;==>_PuttyUpdater Func _HyperTerm() If Not FileExists(@ProgramFilesDir & "\Windows NT\hypertrm.exe") Then FileCopy(@ScriptDir & "\Apps\Hyperterm\hypertrm.exe", @ProgramFilesDir & "\Windows NT\") FileCopy(@ScriptDir & "\Apps\Hyperterm\hticons.dll", @ProgramFilesDir & "\Windows NT\") FileCopy(@ScriptDir & "\Apps\Hyperterm\htrn_jis.dll", @ProgramFilesDir & "\Windows NT\") FileCopy(@ScriptDir & "\Apps\Hyperterm\hypertrm.dll", @SystemDir) RunWait(@ComSpec & " /c /s RegSvr32 """, @ScriptDir & "\Apps\Hypterterm\hypertrm.dll") FileCreateShortcut(@ProgramFilesDir & "\Windows NT\hypertrm.exe", @DesktopCommonDir & "\HyperTerminal.lnk") FileCopy(@ScriptDir & "\Apps\Hyperterm\hypertrm.chm", "C:\WINDOWS\Help\") FileCopy(@ScriptDir & "\Apps\Hyperterm\hypertrm.hlp", "C:\WINDOWS\Help\") EndIf EndFunc ;==>_HyperTerm #endregion CNS #region MWS Func _WMDC() $WMDVer = FileGetVersion("c:\windows\WindowsMobile\wmdc.exe") If Not FileExists("c:\windows\WindowsMobile\wmdc.exe") Then $WMD = Run(@ComSpec & " /c " & @ScriptDir & "\Apps\WMDC\drvupdate-x86.exe /q", "", @SW_HIDE) While ProcessExists($WMD) TrayTip("Installing Windows Mobile Device Center", "Please be patient." & $WMD, 5) Sleep(250) WEnd TrayTip("x", "", 0) If _VersionCompare($WMDVer, "6.1.6965.0") = -1 Then $WMD = Run(@ComSpec & " /c " & @ScriptDir & "\Apps\WMDC\drvupdate-x86.exe /q", "", @SW_HIDE) While ProcessExists($WMD) TrayTip("Installing Windows Mobile Device Center", "Please be patient." & $WMD, 5) Sleep(250) WEnd TrayTip("x", "", 0) Else If _VersionCompare($WMDVer, "6.1.6965.0") = 0 Then EndIf EndIf EndIf EndFunc ;==>_WMDC #endregion MWS Func _BiosGetSerialNumber() Local $sRET, $strComputer = @ComputerName Local $objWMIService = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\" & $strComputer & "\root\cimv2") Local $colBIOS = $objWMIService.ExecQuery("SELECT * FROM Win32_BIOS") For $objBIOS In $colBIOS $sRET = $objBIOS.SerialNumber Next If $sRET <> "" Then Return $sRET Else Return SetError(1, 0, 0) EndIf EndFunc ;==>_BiosGetSerialNumber Func _WinTitle() If WinExists("Open File - Security Warning") Then ControlClick("Open File - Security Warning", "", "&Run") EndFunc ;==>_WinTitle Func _WinTitle2() If WinExists("Windows Installer") Then ControlClick("Windows Installer", "", "&Yes") EndFunc ;==>_WinTitle2 #endregion Functions Link to comment Share on other sites More sharing options...
Neejay Posted February 7, 2014 Author Share Posted February 7, 2014 (edited) I just modified my _Patch Function: Func _Patch($KB_Name) $KB_Number = StringTrimLeft($KB_Name, 7) $ext = StringLeft($KB_Name, 17) _ArraySearch($aHotFixList, $KB_Number) If @error <> 0 Then If $ext = $KB_Name & "-x86.msu" Then $inst = Run(@ComSpec & " /c " & $Patches & $KB_Name & "-x86.msu /quiet /norestart", "", @SW_HIDE) ElseIf $ext = $KB_Name & "-O2010.exe" Then $inst = Run(@ComSpec & " /c " & $Patches & $KB_Name & "-O2010.exe /quiet /norestart", "", @SW_HIDE) ElseIf $ext = $KB_Name & ".msu" Then $inst = Run(@ComSpec & " /c " & $Patches & $KB_Name & ".msu /quiet /norestart", "", @SW_HIDE) Else $inst = Run(@ComSpec & " /c " & $Patches & $KB_Name & ".exe /passive /norestart", "", @SW_HIDE) EndIf While ProcessExists($inst) TrayTip("Installing " & "MS" & StringLeft($KB_Name, 6), "Please be patient.", 5) Sleep(250) WEnd TrayTip("x", "", 0) _FileWriteLog($Timelog, "Installed MS" & $KB_Name) EndIf EndFunc ;==>_Patch Edited March 12, 2014 by Neejay 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