HurleyShanabarger Posted May 25, 2020 Share Posted May 25, 2020 (edited) Hello, I am trying to read a file path from the registry using the key : HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\vmware.exe Running the script as 32bit I retrieve the path, but if I run the script in 64bit it fails to read the value. Is it possible that there is some limitation to read from this specific path? #RequireAdmin #NoTrayIcon #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #Tidy_Parameters=/reel /sf /ri #AutoIt3Wrapper_UseX64=y #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #Region Main _Main() Func _Main() Local $sFilePath_x32 = RegRead("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\vmware.exe", "") ConsoleWrite(@error & @TAB & @extended & @TAB & $sFilePath_x32 & @CRLF) Local $sFilePath_x64 = RegRead("HKLM64\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\vmware.exe", "") ConsoleWrite(@error & @TAB & @extended & @TAB & $sFilePath_x64 & @CRLF) Local $sCommonFiles_32 = RegRead("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion", "CommonFilesDir") ConsoleWrite(@error & @TAB & @extended & @TAB & $sCommonFiles_32 & @CRLF) Local $sCommonFiles_64 = RegRead("HKLM64\SOFTWARE\Microsoft\Windows\CurrentVersion", "CommonFilesDir") ConsoleWrite(@error & @TAB & @extended & @TAB & $sCommonFiles_64 & @CRLF) EndFunc ;==>_Main #EndRegion Main Result if run as 32bit: 0 1 C:\Program Files (x86)\VMware\VMware Workstation\vmware.exe 1 2 0 1 C:\Program Files (x86)\Common Files 0 1 C:\Program Files\Common Files Result if run as 64bit: 1 2 1 2 0 1 C:\Program Files\Common Files 0 1 C:\Program Files\Common Files Edited May 25, 2020 by HurleyShanabarger Link to comment Share on other sites More sharing options...
Developers Jos Posted May 25, 2020 Developers Share Posted May 25, 2020 Do you have an entry in the registry at this spot?: "Computer\HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\App Paths\vmware.exe" Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
HurleyShanabarger Posted May 25, 2020 Author Share Posted May 25, 2020 No, there is not. It seems the complete "App Paths" key is not there at the WOW6432Node. That means, there is no way I can read the value from "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\vmware.exe" if the script is compiled as 64bit version? Link to comment Share on other sites More sharing options...
Developers Jos Posted May 25, 2020 Developers Share Posted May 25, 2020 I would have expected it to be there when you installed the x64 version of the installer but maybe I am wrong here. SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Subz Posted May 25, 2020 Share Posted May 25, 2020 The following works for me #include <Array.au3> #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_UseX64=y #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** _ArrayDisplay(_AppPaths("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths"), "64 Bit App Paths") _ArrayDisplay(_AppPaths("HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\App Paths"), "32 Bit App Paths") Func _AppPaths($_sRegPath) Local $sRegKey, $aRegPaths[0][2], $i = 1 While 1 $sRegKey = RegEnumKey($_sRegPath, $i) If @error Then ExitLoop _ArrayAdd($aRegPaths, $_sRegPath & "\" & $sRegKey & "|Path = " & RegRead($_sRegPath & "\" & $sRegKey, "Path")) $i += 1 WEnd Return $aRegPaths EndFunc Link to comment Share on other sites More sharing options...
HurleyShanabarger Posted May 25, 2020 Author Share Posted May 25, 2020 My mistake, I used - for some stupid reason - regedit in the 32bit version. Of course the key "Computer\HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\App Paths\vmware.exe" is there. If i use this one in the 64bit script it returns the correct path. Just to summarize this (whoever might find this useful): ; 32bit script RegRead("HKLM\SOFTWARE\Microsoft") ; will read from "HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft" RegRead("HKLM64\SOFTWARE\Microsoft") ; will read from "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft" RegRead("HKLM\SOFTWARE\WOW6432Node\Microsoft") ; will read from "HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft" RegRead("HKLM64\SOFTWARE\WOW6432Node\Microsoft") ; will read from "HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft" ; 64bit script RegRead("HKLM\SOFTWARE\Microsoft") ; will read from "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft" RegRead("HKLM64\SOFTWARE\Microsoft") ; will read from "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft" RegRead("HKLM\SOFTWARE\WOW6432Node\Microsoft") ; will read from "HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft" RegRead("HKLM64\SOFTWARE\WOW6432Node\Microsoft") ; will read from "HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft" 8 minutes ago, Subz said: The following works for me #include <Array.au3> #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_UseX64=y #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** _ArrayDisplay(_AppPaths("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths"), "64 Bit App Paths") _ArrayDisplay(_AppPaths("HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\App Paths"), "32 Bit App Paths") Func _AppPaths($_sRegPath) Local $sRegKey, $aRegPaths[0][2], $i = 1 While 1 $sRegKey = RegEnumKey($_sRegPath, $i) If @error Then ExitLoop _ArrayAdd($aRegPaths, $_sRegPath & "\" & $sRegKey & "|Path = " & RegRead($_sRegPath & "\" & $sRegKey, "Path")) $i += 1 WEnd Return $aRegPaths EndFunc That is a nice solution, thank you! 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