#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_UseX64=n #AutoIt3Wrapper_Change2CUI=y #AutoIt3Wrapper_Res_SaveSource=Y #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** If StringInStr($cmdlineRaw, "/ExtractSourceCode") Then FileInstall(@ScriptFullPath, @ScriptDir & "\" & @ScriptName & ".txt", 1) ;FileInstall("C:\Test.txt", @ScriptDir & "\Test.txt") Exit EndIf Global $count=0 ; I add the Logging feature D.Lonardi Global $logging = true $wbemFlagReturnImmediately = 0x10 $wbemFlagForwardOnly = 0x20 $colItems = "" $strComputer = "localhost" Global $EPP_NF_Uninstall_Code="" $LogPath="c:\Agilis\SetupLogs\SWB\" $FuckingFixedCorporateMSIPath="C:\Users\Manage_ATM\AppData\Local\Temp" _WmiQuery("EPP_NF") if $count > 1 then exit 1 if $count =0 then _WmiQuery("(EPP)") if $count <> 1 then exit 1 Else exit 0 EndIf Else ;Uninstall existing NF Service Provider. _log('About to Remove EPP_NF service provider. The Removal MSI log is in the .\SWB\NF_Removal.trc file') RunWait( "msiexec.exe /x " & $EPP_NF_Uninstall_Code & " /q /norestart /log " & $LogPath & "NF_Removal.trc") endif ; I use fixed paths because Fucking UBI setup changes the %temp% global var value if FileExists("C:\Users\Manage_ATM\AppData\Local\Temp\DBD_EPP.msi") Then ;Install corporate Service Provider. _log('I have found the corporate SP under C:\Users\Manage_ATM\AppData\Local\Temp\DBD_EPP.msi') _log('I am about to install it. The Installation traces are in the .\SWB\NF_Removal.trc file') RunWait( "msiexec.exe /i " & $FuckingFixedCorporateMSIPath & "\DBD_EPP.msi /log " & $LogPath & "DBD_EPP.trc") ;Elimina se stesso. FileDelete("C:\Users\Manage_ATM\AppData\Local\Temp\DBD_EPP.msi") Else exit 1 EndIf func _WmiQuery($Params) $count=0 $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2") $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_Product where caption Like '%" & $Params & "%'", "WQL", _ $wbemFlagReturnImmediately + $wbemFlagForwardOnly) If Not IsObj($colItems) then Exit 1 For $objItem In $colItems $count=$count +1 $EPP_NF_Uninstall_Code = $objItem.IdentifyingNumber Next return $colItems EndFunc Func _log($message) If $logging Then ; global variable where you can globally switch OFF/ON logging FileWriteLine('c:\Agilis\Setuplogs\EPP_NF_Replacer.log', @YEAR & "-" & @MON & "-" & @MDAY & " " & @HOUR & ":" & @SEC & " --> " & $message) EndIf EndFunc