mdwerne Posted February 25, 2011 Posted February 25, 2011 I have a script that runs through a bunch of Java MSI codes and, if found, runs msiexec to remove that version. I am trying to find a way to log when the for loop finds something and executes. So far all I have gotten is 80 or so useless lines in my logfile that correspond to the items in my array. I hope that made sense. Here is a snippet of my code, how can use _FileWriteLog so that a line is written ONLY when the MSI code is found? Where I currently have _FileWriteLog is obviously wrong. $Array = StringSplit("{F4588301-0A06-11D6-A761-00B0D079AF64},{1666FA7C-CB5F-11D6-A78C-00B0D079AF64},{7148F0A8-6813-11D6-A77B-00B0D0142000},{7148F0A8-6813-11D6-A77B-00B0D0142010}," & _ "{7148F0A8-6813-11D6-A77B-00B0D0142020},{7148F0A8-6813-11D6-A77B-00B0D0142030},{7148F0A8-6813-11D6-A77B-00B0D0142040}," & _ "{7148F0A8-6813-11D6-A77B-00B0D0142050},{7148F0A8-6813-11D6-A77B-00B0D0142060},{7148F0A8-6813-11D6-A77B-00B0D0142070}," & _ "{7148F0A8-6813-11D6-A77B-00B0D0142080},{7148F0A8-6813-11D6-A77B-00B0D0142090},{7148F0A8-6813-11D6-A77B-00B0D0142100}," & _ "{7148F0A8-6813-11D6-A77B-00B0D0142110},{7148F0A8-6813-11D6-A77B-00B0D0142120},{7148F0A8-6813-11D6-A77B-00B0D0142130}," & _ "{7148F0A8-6813-11D6-A77B-00B0D0142140},{7148F0A8-6813-11D6-A77B-00B0D0142150},{7148F0A8-6813-11D6-A77B-00B0D0142160}," & _ "{7148F0A8-6813-11D6-A77B-00B0D0142170},{7148F0A8-6813-11D6-A77B-00B0D0142180},{7148F0A8-6813-11D6-A77B-00B0D0142190}," & _ "{3248F0A8-6813-11D6-A77B-00B0D0150000},{3248F0A8-6813-11D6-A77B-00B0D0150010},{3248F0A8-6813-11D6-A77B-00B0D0150020}," & _ "{3248F0A8-6813-11D6-A77B-00B0D0150030},{3248F0A8-6813-11D6-A77B-00B0D0150040},{3248F0A8-6813-11D6-A77B-00B0D0150050}," & _ "{3248F0A8-6813-11D6-A77B-00B0D0150060},{3248F0A8-6813-11D6-A77B-00B0D0150070},{3248F0A8-6813-11D6-A77B-00B0D0150080}," & _ "{3248F0A8-6813-11D6-A77B-00B0D0150090},{3248F0A8-6813-11D6-A77B-00B0D0150100},{3248F0A8-6813-11D6-A77B-00B0D0150110}," & _ "{3248F0A8-6813-11D6-A77B-00B0D0150120},{3248F0A8-6813-11D6-A77B-00B0D0150130},{3248F0A8-6813-11D6-A77B-00B0D0150140}," & _ "{3248F0A8-6813-11D6-A77B-00B0D0150150},{3248F0A8-6813-11D6-A77B-00B0D0150160},{3248F0A8-6813-11D6-A77B-00B0D0150170}," & _ "{3248F0A8-6813-11D6-A77B-00B0D0150180},{3248F0A8-6813-11D6-A77B-00B0D0150190},{3248F0A8-6813-11D6-A77B-00B0D0150200}," & _ "{3248F0A8-6813-11D6-A77B-00B0D0150210},{3248F0A8-6813-11D6-A77B-00B0D0150220},{3248F0A8-6813-11D6-A77B-00B0D0150230}," & _ "{3248F0A8-6813-11D6-A77B-00B0D0160000},{3248F0A8-6813-11D6-A77B-00B0D0160010},{3248F0A8-6813-11D6-A77B-00B0D0160020}," & _ "{3248F0A8-6813-11D6-A77B-00B0D0160030},{3248F0A8-6813-11D6-A77B-00B0D0160040},{3248F0A8-6813-11D6-A77B-00B0D0160050}," & _ "{3248F0A8-6813-11D6-A77B-00B0D0160060},{3248F0A8-6813-11D6-A77B-00B0D0160070},{3248F0A8-6813-11D6-A77B-00B0D0160080}," & _ "{3248F0A8-6813-11D6-A77B-00B0D0160090},{26A24AE4-039D-4CA4-87B4-2F83216010FF},{26A24AE4-039D-4CA4-87B4-2F83216011FF}," & _ "{26A24AE4-039D-4CA4-87B4-2F83216012FF},{26A24AE4-039D-4CA4-87B4-2F83216013FF},{26A24AE4-039D-4CA4-87B4-2F83216014FF}," & _ "{26A24AE4-039D-4CA4-87B4-2F83216015FF},{26A24AE4-039D-4CA4-87B4-2F83216016FF},{26A24AE4-039D-4CA4-87B4-2F83216017FF}," & _ "{26A24AE4-039D-4CA4-87B4-2F83216018FF},{26A24AE4-039D-4CA4-87B4-2F83216019FF},{26A24AE4-039D-4CA4-87B4-2F83216020FF}," & _ "{26A24AE4-039D-4CA4-87B4-2F83216021FF},{26A24AE4-039D-4CA4-87B4-2F83216022FF},{26A24AE4-039D-4CA4-87B4-2F83216023FF}," & _ "{26A24AE4-039D-4CA4-87B4-2F83216024FF},{26A24AE4-039D-4CA4-87B4-2F83217000FF}", ",") For $i = 1 To $Array[0] Local $InstallCheck = RegRead("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\" & $Array[$i], "") If @error == -1 Then RunWait("msiexec /x " & $Array[$i] & " /qn /norestart REBOOT=ReallySuppress") _FileWriteLog(@HomeDrive & "\SNL JavaUpdater.log", $Array[$i] & " removed") Next Thanks for any suggestions, -Mike
PsaltyDS Posted February 25, 2011 Posted February 25, 2011 Just put that inside the IF statement: For $i = 1 To $Array[0] Local $InstallCheck = RegRead("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\" & $Array[$i], "") If @error == -1 Then RunWait("msiexec /x " & $Array[$i] & " /qn /norestart REBOOT=ReallySuppress") _FileWriteLog(@HomeDrive & "\SNL JavaUpdater.log", $Array[$i] & " removed") EndIf Next Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
mdwerne Posted February 25, 2011 Author Posted February 25, 2011 Just put that inside the IF statement: For $i = 1 To $Array[0] Local $InstallCheck = RegRead("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\" & $Array[$i], "") If @error == -1 Then RunWait("msiexec /x " & $Array[$i] & " /qn /norestart REBOOT=ReallySuppress") _FileWriteLog(@HomeDrive & "\SNL JavaUpdater.log", $Array[$i] & " removed") EndIf Next Thanks...always learning.
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