Chimaera Posted October 11, 2011 Posted October 11, 2011 (edited) Ok i started with this from storme, but it dosent give 64 bit checking and install location is not very reliable, so i started looking at UninstallString instead as most programs seem to have it Func GetInstalledPath() Static $sInstalledPath = "" If $sInstalledPath = "" Then $sInstalledPath = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Malwarebytes' Anti-Malware_is1", "InstallLocation") If @error Then $sInstalledPath = "" Return SetError(1, 0, "") EndIf EndIf Return $sInstalledPath EndFunc ;==>GetInstalledPath So i started messing about like this $FindPath = GetInstalledPath() $TrimPath = StringTrimRight( $FindPath, 11) ConsoleWrite ($TrimPath & @CRLF) Func GetInstalledPath() Static $sInstalledPath = "" If $sInstalledPath = "" Then $RegExist = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\CCleaner", "UninstallString") If @error = 1 Then $sInstalledPath = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\CCleaner", "UninstallString") Else $sInstalledPath = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\CCleaner", "UninstallString") EndIf If @error Then $sInstalledPath = "" Return SetError(1, 0, "") EndIf EndIf Return $sInstalledPath EndFunc ;==>GetInstalledPath This dosent work so i tried the guinness approach MsgBox(0, "_IsRegistryExist()", _IsRegistryExist("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\CCleaner", "UninstallString")) ; 0 = Doesn't Exist MsgBox(0, "_IsRegistryExist()", _IsRegistryExist("HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\avast", "UninstallString")) ; 1 = Exists Func _IsRegistryExist($sKeyName, $sValueName) RegRead($sKeyName, $sValueName) If @error Then Return 0 EndIf Return 1 EndFunc ;==>_IsRegistryExist and blow me down it dosent work either... The CCleaner exists without a shadow of doubt yet it wont find it.. all im trying to do is make it find the right uninstall key whether 32/64 so i can set the program location using the $TrimPath = StringTrimRight( $FindPath, 11) anyone know why this wont work? Edited October 11, 2011 by Chimaera If Ive just helped you ... miracles do happen. Chimaera CopyRobo() * Hidden Admin Account Enabler * Software Location From Registry * Find Display Resolution * _ChangeServices()
JohnOne Posted October 11, 2011 Posted October 11, 2011 (edited) They both work for me. You may need #requireadmin. EDIT: oops no, I'm using 32 bit. Edited October 11, 2011 by JohnOne AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
Chimaera Posted October 11, 2011 Author Posted October 11, 2011 Already tried that and also #AutoIt3Wrapper_Res_Compatibility=Vista,Windows7 When i set it up for a 64 bit like the avast eg in the guinness one it works for me but i cant get both to work Ive been messing about a few hrs now and i cant see why the hell it dosent work Well unless im doing something dumb If Ive just helped you ... miracles do happen. Chimaera CopyRobo() * Hidden Admin Account Enabler * Software Location From Registry * Find Display Resolution * _ChangeServices()
JohnOne Posted October 11, 2011 Posted October 11, 2011 As far as I know you really do need admin rights to read those keys, so I'd keep it in anyway. Have you manually checked those keys? AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
Chimaera Posted October 11, 2011 Author Posted October 11, 2011 (edited) Just tried again with the guinness one and requireadmin and it still gives me a 0ive been in regedit and yes the key is there with about 8 valuesUninstallString being one off them and ""C:\Program Files\CCleaner\uninst.exe"" being the data within Edited October 11, 2011 by Chimaera If Ive just helped you ... miracles do happen. Chimaera CopyRobo() * Hidden Admin Account Enabler * Software Location From Registry * Find Display Resolution * _ChangeServices()
JFX Posted October 11, 2011 Posted October 11, 2011 Don't complicate this, disable the registry reflection. Change HKEY_LOCAL_MACHINE to HKEY_LOCAL_MACHINE64 Now You only need to check, depending on the OS architecture and the software installed. but no longer have to care about which Autoit.exe you use.
Chimaera Posted October 11, 2011 Author Posted October 11, 2011 (edited) The whole point is for it to find the uninstall string whether its a 32 or 64 bit OS It has nothing to do with the autoit exe type as i only compile to x86 Im using the result from this as a check to whether a program exists on a drive which i then check for file version, this is to save hardcoding c:\program files etc etc for 32 bit and 64bit os es as this will give me the correct location to work with Edited October 11, 2011 by Chimaera If Ive just helped you ... miracles do happen. Chimaera CopyRobo() * Hidden Admin Account Enabler * Software Location From Registry * Find Display Resolution * _ChangeServices()
Ascend4nt Posted October 12, 2011 Posted October 12, 2011 (edited) Maybe do a little debugging to see what DOES show up? #include <Array.au3> Local $sKey="HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" Local $aVals[100] For $i= 1 to 100 $aVals[$i]= RegEnumKey($sKey, $i) If @error <> 0 then ExitLoop Next _ArrayDisplay($aVals,"Subkeys under "&$sKey) *edit: Have you also tried this registry key?: HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Uninstall Edited October 12, 2011 by Ascend4nt My contributions: Performance Counters in Windows - Measure CPU, Disk, Network etc Performance | Network Interface Info, Statistics, and Traffic | CPU Multi-Processor Usage w/o Performance Counters | Disk and Device Read/Write Statistics | Atom Table Functions | Process, Thread, & DLL Functions UDFs | Process CPU Usage Trackers | PE File Overlay Extraction | A3X Script Extract | File + Process Imports/Exports Information | Windows Desktop Dimmer Shade | Spotlight + Focus GUI - Highlight and Dim for Eyestrain Relief | CrossHairs (FullScreen) | Rubber-Band Boxes using GUI's (_GUIBox) | GUI Fun! | IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) | Magnifier (Vista+) Functions UDF | _DLLStructDisplay (Debug!) | _EnumChildWindows (controls etc) | _FileFindEx | _ClipGetHTML | _ClipPutHTML + ClipPutHyperlink | _FileGetShortcutEx | _FilePropertiesDialog | I/O Port Functions | File(s) Drag & Drop | _RunWithReducedPrivileges | _ShellExecuteWithReducedPrivileges | _WinAPI_GetSystemInfo | dotNETGetVersions | Drive(s) Power Status | _WinGetDesktopHandle | _StringParseParameters | Screensaver, Sleep, Desktop Lock Disable | Full-Screen Crash Recovery Wrappers/Modifications of others' contributions: _DOSWildcardsToPCRegEx (original code: RobSaunder's) | WinGetAltTabWinList (original: Authenticity) UDF's added support/programming to: _ExplorerWinGetSelectedItems | MIDIEx UDF (original code: eynstyne) (All personal code/wrappers centrally located at Ascend4nt's AutoIT Code)
Chimaera Posted October 12, 2011 Author Posted October 12, 2011 Gives me an error (15) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.:$aVals[$i]= RegEnumKey($sKey, $i)^ ERROR Ill have a look into that as well thanks HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\UninstallIm only trying to find a simple way that checks whether a program exists and gives me the install location, which i can then feed to other things that use it If Ive just helped you ... miracles do happen. Chimaera CopyRobo() * Hidden Admin Account Enabler * Software Location From Registry * Find Display Resolution * _ChangeServices()
Ascend4nt Posted October 12, 2011 Posted October 12, 2011 oops, that should be: $aVals[$i-1]= RegEnumKey($sKey, $i) You can adjust the array size of course to whatever you need. My contributions: Performance Counters in Windows - Measure CPU, Disk, Network etc Performance | Network Interface Info, Statistics, and Traffic | CPU Multi-Processor Usage w/o Performance Counters | Disk and Device Read/Write Statistics | Atom Table Functions | Process, Thread, & DLL Functions UDFs | Process CPU Usage Trackers | PE File Overlay Extraction | A3X Script Extract | File + Process Imports/Exports Information | Windows Desktop Dimmer Shade | Spotlight + Focus GUI - Highlight and Dim for Eyestrain Relief | CrossHairs (FullScreen) | Rubber-Band Boxes using GUI's (_GUIBox) | GUI Fun! | IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) | Magnifier (Vista+) Functions UDF | _DLLStructDisplay (Debug!) | _EnumChildWindows (controls etc) | _FileFindEx | _ClipGetHTML | _ClipPutHTML + ClipPutHyperlink | _FileGetShortcutEx | _FilePropertiesDialog | I/O Port Functions | File(s) Drag & Drop | _RunWithReducedPrivileges | _ShellExecuteWithReducedPrivileges | _WinAPI_GetSystemInfo | dotNETGetVersions | Drive(s) Power Status | _WinGetDesktopHandle | _StringParseParameters | Screensaver, Sleep, Desktop Lock Disable | Full-Screen Crash Recovery Wrappers/Modifications of others' contributions: _DOSWildcardsToPCRegEx (original code: RobSaunder's) | WinGetAltTabWinList (original: Authenticity) UDF's added support/programming to: _ExplorerWinGetSelectedItems | MIDIEx UDF (original code: eynstyne) (All personal code/wrappers centrally located at Ascend4nt's AutoIT Code)
BrewManNH Posted October 12, 2011 Posted October 12, 2011 (edited) Gives me an error (15) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.: $aVals[$i]= RegEnumKey($sKey, $i) This "For $i= 1 to 100", should be this "For $i= 0 to 99". Nevermind, that wouldn't work for the RegEnumKey, it just causes the exitloop to fire because of the 0. Ascend4nt was right in his post above. Edited October 12, 2011 by BrewManNH 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
Chimaera Posted October 12, 2011 Author Posted October 12, 2011 Ok that works and gives me this [0]|AddressBook [1]|Adobe Flash Player ActiveX [2]|Adobe Flash Player Plugin [3]|Adobe Shockwave Player [4]|AlwaysUnloadDll [5]|AudELSvc [6]|AudioCS [7]|AutoItv3 [8]|avast [9]|CADI [10]|Connection Manager [11]|DAEMON Tools Lite [12]|Digsby [13]|DirectDrawEx [14]|Driver San Francisco [15]|ENTERPRISE [16]|Fontcore [17]|IE40 [18]|IE4Data [19]|IE5BAKEX [20]|IEData [21]|IrfanView [22]|KLiteCodecPack_is1 [23]|Malwarebytes' Anti-Malware_is1 [24]|MobileOptionPack [25]|Mozilla Firefox 8.0 (x86 en-US) [26]|NewsLeecher_is1 [27]|OpenAL [28]|QuickPar [29]|Rage_is1 [30]|SchedulingAgent [31]|SciTE4AutoIt3 [32]|True BoxShot_is1 [33]|Universal Extractor_is1 [34]|VLC media player [35]|WIC [36]|WinCHM 4.19 - Help authoring software_is1 [37]|WinRAR archiver [38]|YTdetect There was 143 in total all the lower ones were MS stuff and office components Anyway look whats missing, im beginning to suspect this is something to do with 64bit issues I even tried a wow64 redirect disable just in case but ccleaner is still in regedit and programs and features as installed This is beyond weird Ive attached a image of the regedit so you can see im not lying If Ive just helped you ... miracles do happen. Chimaera CopyRobo() * Hidden Admin Account Enabler * Software Location From Registry * Find Display Resolution * _ChangeServices()
Chimaera Posted October 14, 2011 Author Posted October 14, 2011 Through some research the only keys that are valid are (well on my system)HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\UninstallHKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\UninstallHKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall So ive knocked up a test rig and ill take it to work and check there as some machines have ccleaner installed I just dont understand why the key is there and its not at the same time on my system ?? If Ive just helped you ... miracles do happen. Chimaera CopyRobo() * Hidden Admin Account Enabler * Software Location From Registry * Find Display Resolution * _ChangeServices()
JFX Posted October 14, 2011 Posted October 14, 2011 What's the output if you run this? ConsoleWrite(@OSVersion & ' ' & @OSArch & @CRLF & @CRLF) $var1 = RegRead("HKLM64\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\CCleaner", "UninstallString") ConsoleWrite('1: ' & $var1 & @TAB & @error & @CRLF) $var2 = RegRead("HKLM64\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\CCleaner", "UninstallString") ConsoleWrite('2: ' & $var2 & @TAB & @error & @CRLF) $reg_query = Run('REG QUERY HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\CCleaner /v UninstallString', '', @SW_HIDE, 2) Local $var3 While 1 $var3 &= StdoutRead($reg_query) If @error Then ExitLoop Wend ConsoleWrite('3: ' & $var3 & @CRLF) $reg_query = Run(@WindowsDir & '\sysnative\REG.exe QUERY HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\CCleaner /v UninstallString', '', @SW_HIDE, 2) Local $var4 While 1 $var4 &= StdoutRead($reg_query) If @error Then ExitLoop Wend ConsoleWrite('4: ' & $var4 & @CRLF) Is it different if you run as admin or not?
Chimaera Posted October 14, 2011 Author Posted October 14, 2011 (edited) I get this as normal but i only use an admin acc WIN_7 X64 1: "C:\Program Files\CCleaner\uninst.exe" 0 2: 1 3: ERROR: The system was unable to find the specified registry key or value. 4: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\CCleaner UninstallString REG_SZ "C:\Program Files\CCleaner\uninst.exe" with a couple of blank spaces underneath EDIT With the help from you all i ended up with this #RequireAdmin $soft = "\CCleaner" $string_search = "UninstallString" $path_1 = "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Uninstall" & $soft $path_2 = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" & $soft $path_3 = "HKLM64\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" & $soft $path_4 = "HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall" & $soft If _IsRegistryExist($path_1, $string_search) = 1 Then $soft_path = RegRead($path_1, $string_search) ConsoleWrite("1 " & $soft_path & @CRLF) ElseIf _IsRegistryExist($path_2, $string_search) = 1 Then $soft_path = RegRead($path_2, $string_search) ConsoleWrite("2 " & $soft_path & @CRLF) ElseIf _IsRegistryExist($path_3, $string_search) = 1 Then $soft_path = RegRead($path_3, $string_search) ConsoleWrite("3 " & $soft_path & @CRLF) ElseIf _IsRegistryExist($path_4, $string_search) = 1 Then $soft_path = RegRead($path_4, $string_search) ConsoleWrite("4 " & $soft_path & @CRLF) EndIf Func _IsRegistryExist($sKeyName, $sValueName); 0 = Doesn't Exist / 1 = Exists <<< author = guinness RegRead($sKeyName, $sValueName) If @error Then Return 0 EndIf Return 1 EndFunc ;==>_IsRegistryExist Edited October 15, 2011 by Chimaera If Ive just helped you ... miracles do happen. Chimaera CopyRobo() * Hidden Admin Account Enabler * Software Location From Registry * Find Display Resolution * _ChangeServices()
Ascend4nt Posted October 14, 2011 Posted October 14, 2011 (edited) Ooh, nice catch JFX. I didn't even know that HKLM64 option was available in RegRead. That must use the flag 'KEY_WOW64_64KEY' when opening the registry key (via RegOpenKeyEx). That should solve Chimaera's 32-bit code problem then. (try HKLM64 if HKLM doesn't work, HKCU64 if HKCU doesn't.. etc). Good stuff to know. Some good MSDN links:32-bit and 64-bit Application Data in the RegistryAccessing an Alternate Registry ViewRegistry ReflectionRegistry Redirector Seems most programs should always avoid tacking 'Wow6432Node' onto a registry key value, even though some use it in 64-bit code. However, there's no HKLM32 equivalent in AutoIt regread currently (i.e. using KEY_WOW64_32KEY when opening a key), so thats why some code uses it, I presume. 'Registry Reflection' should prevent such a need in most keys though. Edited October 14, 2011 by Ascend4nt My contributions: Performance Counters in Windows - Measure CPU, Disk, Network etc Performance | Network Interface Info, Statistics, and Traffic | CPU Multi-Processor Usage w/o Performance Counters | Disk and Device Read/Write Statistics | Atom Table Functions | Process, Thread, & DLL Functions UDFs | Process CPU Usage Trackers | PE File Overlay Extraction | A3X Script Extract | File + Process Imports/Exports Information | Windows Desktop Dimmer Shade | Spotlight + Focus GUI - Highlight and Dim for Eyestrain Relief | CrossHairs (FullScreen) | Rubber-Band Boxes using GUI's (_GUIBox) | GUI Fun! | IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) | Magnifier (Vista+) Functions UDF | _DLLStructDisplay (Debug!) | _EnumChildWindows (controls etc) | _FileFindEx | _ClipGetHTML | _ClipPutHTML + ClipPutHyperlink | _FileGetShortcutEx | _FilePropertiesDialog | I/O Port Functions | File(s) Drag & Drop | _RunWithReducedPrivileges | _ShellExecuteWithReducedPrivileges | _WinAPI_GetSystemInfo | dotNETGetVersions | Drive(s) Power Status | _WinGetDesktopHandle | _StringParseParameters | Screensaver, Sleep, Desktop Lock Disable | Full-Screen Crash Recovery Wrappers/Modifications of others' contributions: _DOSWildcardsToPCRegEx (original code: RobSaunder's) | WinGetAltTabWinList (original: Authenticity) UDF's added support/programming to: _ExplorerWinGetSelectedItems | MIDIEx UDF (original code: eynstyne) (All personal code/wrappers centrally located at Ascend4nt's AutoIT Code)
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