bourny Posted January 30, 2009 Share Posted January 30, 2009 I am looking to determine if a program is installed on my system. I usually check by looking at HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{GUID ID} \DisplayName This works fine if I know the GUID will stay the same. In my current case there is a good possibility the product will change its GUID and result in my script triggering an update even though the product is installed just under a different GUID, I have 2 ideas that I dont know how to tackle to work around this issue 1. Output all Guids/keys in HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\ and look thru each display name for the presence of my product name - If it is picked up in any other GUID that I know the GUID hasd changed and to abort the program 2. Somehow other than the registry check the system for the precense of a program called "MY PROGRAM" is installed (Mabe using API / objects etc) Any help appreciated Link to comment Share on other sites More sharing options...
SpookMeister Posted January 30, 2009 Share Posted January 30, 2009 Here is a modified snippet of code I used once, it may give you an idea of how to work with your first workaround. #include <array.au3> $a_software=_InstalledSoftware() _ArrayDisplay($a_software) Func _InstalledSoftware() Local $Count = 1 Local Const $regkey = 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall' While 1 $key = RegEnumKey($regkey, $Count) If @error <> 0 Then ExitLoop ConsoleWrite($key & @CRLF) $line = RegRead($regkey & '\' & $key, 'DisplayName') $line = StringReplace($line, ' (remove only)', '') If $line <> '' Then If Not IsDeclared('avArray') Then Dim $avArray[1][5] ReDim $avArray[UBound($avArray) + 1][5] $avArray[0][0] = UBound($avArray) - 1 $avArray[UBound($avArray) - 1][0] = $line $avArray[UBound($avArray) - 1][1] = RegRead($regkey & '\' & $key, 'DisplayVersion') $avArray[UBound($avArray) - 1][2] = RegRead($regkey & '\' & $key, 'InstallDate') $avArray[UBound($avArray) - 1][3] = RegRead($regkey & '\' & $key, 'Publisher') $avArray[UBound($avArray) - 1][4] = $key EndIf $Count = $Count + 1 WEnd If Not IsDeclared('avArray') Then SetError(1) Return ('') Else SetError(0) Return ($avArray) EndIf EndFunc ;==>_InstalledSoftware [u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote] Link to comment Share on other sites More sharing options...
bourny Posted February 2, 2009 Author Share Posted February 2, 2009 Here is a modified snippet of code I used once, it may give you an idea of how to work with your first workaround. #include <array.au3> $a_software=_InstalledSoftware() _ArrayDisplay($a_software) Func _InstalledSoftware() Local $Count = 1 Local Const $regkey = 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall' While 1 $key = RegEnumKey($regkey, $Count) If @error <> 0 Then ExitLoop ConsoleWrite($key & @CRLF) $line = RegRead($regkey & '\' & $key, 'DisplayName') $line = StringReplace($line, ' (remove only)', '') If $line <> '' Then If Not IsDeclared('avArray') Then Dim $avArray[1][5] ReDim $avArray[UBound($avArray) + 1][5] $avArray[0][0] = UBound($avArray) - 1 $avArray[UBound($avArray) - 1][0] = $line $avArray[UBound($avArray) - 1][1] = RegRead($regkey & '\' & $key, 'DisplayVersion') $avArray[UBound($avArray) - 1][2] = RegRead($regkey & '\' & $key, 'InstallDate') $avArray[UBound($avArray) - 1][3] = RegRead($regkey & '\' & $key, 'Publisher') $avArray[UBound($avArray) - 1][4] = $key EndIf $Count = $Count + 1 WEnd If Not IsDeclared('avArray') Then SetError(1) Return ('') Else SetError(0) Return ($avArray) EndIf EndFunc ;==>_InstalledSoftware Excellent - Seems I missed the "RegEnumKey". This is exactly what I need ... 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