Keithdib Posted July 22, 2011 Posted July 22, 2011 Hi I am trying to write a script that will uninstall a software package. the package generates a different ProductCode on each machine and each time its installed so I cannot use this as a reference. I have been using _RegSearch [with help from PsaltyDS] what I need is a script that would work something like, $www = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" $xxx = "DisplayName" $yyy = "DisplayVersion" $zzz = "UninstallString" search on the above then give the UninstallString as an other variable to then allow "Msiexec /X $mmm....etc" to be run thanks
JohnOne Posted July 22, 2011 Posted July 22, 2011 $www = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall") AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
Exit Posted July 22, 2011 Posted July 22, 2011 $www = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall")$www = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall","Valuename") App: Au3toCmd UDF: _SingleScript()
JohnOne Posted July 22, 2011 Posted July 22, 2011 I stand Corrected(said the man in the orthopedic shoes) AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
Keithdib Posted July 22, 2011 Author Posted July 22, 2011 Hi thanks for speedy reply, but this will only ready entries with names such as Abobe, Microsoft etc it will not read entries with starting and ending {} thanks Keith
JohnOne Posted July 22, 2011 Posted July 22, 2011 "the package generates a different ProductCode on each machine and each time its installed" I'm not sure what you mean by that. Regardless of the productcode, its installation and uninstallation registry entries should still be at the same location. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
Keithdib Posted July 22, 2011 Author Posted July 22, 2011 Sorry I ment ProductGuidThe package leaves registry entries HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CruuentVersion\Unnstall\{this string is different each time} ....i.e no vendor nametherefore I need to search within all the entries for SoftwareID or DisplayName & DisplayVersion, then I need the UninstallString from withinthanks
JohnOne Posted July 22, 2011 Posted July 22, 2011 I imagine the _RegSearch() function you spoke of, contains these, but have a look at RegEnumVal() and RegEnumKey() functions in the helpfile. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
Exit Posted July 22, 2011 Posted July 22, 2011 Perhaps this helps $key = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\" For $i = 1 To 99999 $tempkey = RegEnumKey($key, $i) If @error Then ExitLoop $Displayname = RegRead($key & $tempkey, "DisplayName") $UninstallString = RegRead($key & $tempkey, "UninstallString") ConsoleWrite($UninstallString & @LF & $Displayname & @LF & $tempkey & @LF & @LF) Next App: Au3toCmd UDF: _SingleScript()
Keithdib Posted July 22, 2011 Author Posted July 22, 2011 Thanks forumer100 I have changed it very slightly to $key = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\" For $i = 1 To 99999 $tempkey = RegEnumKey($key, $i) If @error Then ExitLoop $Displayname = RegRead($key & $tempkey, "DisplayName") $DisplayVersion = RegRead($key & $tempkey, "DisplayVersion") $UninstallString = RegRead($key & $tempkey, "UninstallString") ConsoleWrite($Displayname & @LF & $DisplayVersion & @LF & $UninstallString & @LF & @CRLF & @CRLF) Next however it still does not display keys that use {} only names... the app all ways installs as {this string changes} thanks Keith
Syed23 Posted July 22, 2011 Posted July 22, 2011 (edited) Hi Keithdib, Hope the below code may give some help! The below code will read all the registry keys and it's uninstall valude from under it.s Uninstall registry key. #include"Array.au3" Global $a Global $key = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" Global $key64 = "HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall" Global $val = "uninstallstring" Dim $a = 1 Dim $List[1] Dim $Display[1] $i = 1 $val = "uninstallstring" While 1 $array = RegEnumKey($key, $a) $array2 = RegRead($key & "\" & $array, "uninstallstring") If $array <> "" Then $a += 1 $Display[$i - 1] = RegRead($key & "\" & $array, "DisplayName") If $Display[$i - 1] = "" Then $Display[$i - 1] = "Display Name is not Found" $List[$i - 1] = $array2 If $List[$i - 1] = "" Then $List[$i - 1] = "No Uninstall Key Found" $List[$i - 1] = $List[$i - 1] & '|' & $Display[$i - 1] ReDim $List[UBound($List) + 1] ReDim $Display[UBound($Display) + 1] $i += 1 Else ExitLoop EndIf WEnd _ArrayDisplay($Display) _ArrayDisplay($List) Edited July 22, 2011 by Syed23 Thank you,Regards,[font="Garamond"][size="4"]K.Syed Ibrahim.[/size][/font]
Keithdib Posted July 22, 2011 Author Posted July 22, 2011 Hi Syed23 Is there a reason 2 arrays need to be used? keith
Syed23 Posted July 22, 2011 Posted July 22, 2011 Hi Syed23Is there a reason 2 arrays need to be used?keithi feel that could be better to handle Display name; Uninstall string; This is just sample code.. you can modify as you want Thank you,Regards,[font="Garamond"][size="4"]K.Syed Ibrahim.[/size][/font]
Exit Posted July 22, 2011 Posted July 22, 2011 Thanks forumer100 I have changed it very slightly to .......... however it still does not display keys that use {} only names... the app all ways installs as {this string changes} I forgot the x64 installers. Here the modified code: $key = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\" For $i1 = 1 To 2 ConsoleWrite(@LF & @LF & "*******" & $key & "*************" & @LF & @LF) For $i = 1 To 99999 $tempkey = RegEnumKey($key, $i) If @error Then ExitLoop $Displayname = RegRead($key & $tempkey, "DisplayName") If @error Then ContinueLoop $msg = "Key: " & $tempkey & @LF $msg &= "DispName: " & $Displayname & @LF $DisplayVersion = RegRead($key & $tempkey, "DisplayVersion") $msg &= "DispVersion: " & $DisplayVersion & @LF $UninstallString = RegRead($key & $tempkey, "UninstallString") $msg &= "Uninstall: " & $UninstallString & @LF ConsoleWrite($msg & @LF & @LF) Next $key = "HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\" Next App: Au3toCmd UDF: _SingleScript()
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