Sign in to follow this  
Followers 0
VelvetElvis

Finding an Installed Program Path in Registry

17 posts in this topic

I have a script that calls an external software application. Right now, I have the user store the .exe path and filename in an .ini file (in case it's installed in a non-standard location.) But that's ugly. It would be much neater if I could have AutoIt find this file from a registry entry. I haven't had any luck in figuring this out.

Can someone give me some help in finding a path to an installed executable, or alternatively the path to the default file handler for a particular extension (in this case ".twb")? Thanks.

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Hi,

Can someone give me some help in finding a path to an installed executable, or alternatively the path to the default file handler for a particular extension (in this case ".twb")?

I hope you will get the path of the executable and not of the icon (or maybe the icon is in the same folder) :

Local $sExtension = ".twb"

Local $sType = RegRead("HKEY_CLASSES_ROOT" & $sExtension, "")
If $sType = "" Then Exit -1 ;Extension not found

Local $sDefaultIcon = RegRead("HKEY_CLASSES_ROOT" & $sType & "DefaultIcon", "")

ConsoleWrite($sDefaultIcon & @CrLf)

Edit : typo.

Br, FireFox.

Edited by FireFox

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

maybe this:

#include <GUIConstants.au3>


$gui_width = 500
$gui_height = 600

Global $count = 1, $all_keys = "", $main_key = "HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindowsCurrentVersionUninstall"

GUICreate("Installed Software", $gui_width, $gui_height, @Desktopwidth/2 - $gui_width/2, @DesktopHeight/2 - $gui_height/2 - 75)
$gui_list = GUICtrlCreateList ("", 10, 10, $gui_width - 20, $gui_height - 20)
GUISetState ()

While 1
$act_key = RegEnumKey ($main_key, $count)
If @error <> 0 then ExitLoop
$act_name = RegRead ($main_key & "" & $act_key, "InstallLocation")
$act_name = StringReplace ($act_name, " (remove only)", "")
If $act_name <> "" Then $all_keys = $all_keys & $act_name & "|"
$count = $count + 1
WEnd

GUICtrlSetData ($gui_list, $all_keys)
While 1
$msg = GUIGetMsg()
If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend
Edited by Danyfirex

Share this post


Link to post
Share on other sites

I was thinking along the same lines as DanyFirex, however looking just at my machine I see almost 80% of what I have installed (all common, 3rd party apps) has nothing written to the InstallLocation value.


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

Hi,

I hope you will get the path of the executable and not of the icon (or maybe the icon is in the same folder) :

Local $sExtension = ".twb"

Local $sType = RegRead("HKEY_CLASSES_ROOT" & $sExtension, "")
If $sType = "" Then Exit -1 ;Extension not found

Local $sDefaultIcon = RegRead("HKEY_CLASSES_ROOT" & $sType & "DefaultIcon", "")

ConsoleWrite($sDefaultIcon & @CrLf)

Edit : typo.

Br, FireFox.

Tried it with ".au3"

Unfortunately, it returns an icon, and not the correct folder either.

C:\Program Files\AutoIt3\Icons\au3script_v10.ico

Share this post


Link to post
Share on other sites

maybe this:

#include <GUIConstants.au3>


$gui_width = 500
$gui_height = 600

Global $count = 1, $all_keys = "", $main_key = "HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindowsCurrentVersionUninstall"

GUICreate("Installed Software", $gui_width, $gui_height, @Desktopwidth/2 - $gui_width/2, @DesktopHeight/2 - $gui_height/2 - 75)
$gui_list = GUICtrlCreateList ("", 10, 10, $gui_width - 20, $gui_height - 20)
GUISetState ()

While 1
$act_key = RegEnumKey ($main_key, $count)
If @error <> 0 then ExitLoop
$act_name = RegRead ($main_key & "" & $act_key, "InstallLocation")
$act_name = StringReplace ($act_name, " (remove only)", "")
If $act_name <> "" Then $all_keys = $all_keys & $act_name & "|"
$count = $count + 1
WEnd

GUICtrlSetData ($gui_list, $all_keys)
While 1
$msg = GUIGetMsg()
If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend

Thanks. But in the case of the AutoIt install for example, I would be looking for the default file handler for ".au3" files. I don't see AutoIt in the results (unless I'm blind) :o

Share this post


Link to post
Share on other sites

Maybe I'm approaching this the wrong way.

What my app does is open a reporting program called "Tableau", then load a Tableau report (a .twbx file). It then manipulates the menu to update the data.

Maybe I should go back to just getting ShellExecute() to call the report file, which will open with the default handler. I wanted to avoid this, in the event that the user changed the default handler for .twbx files. This could happen if the user did not have the Tableau application installed, and only had the crippled Tableau Reader installed, which breaks my app.

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

Maybe I'm approaching this the wrong way.

What my app does is open a reporting program called "Tableau", then load a Tableau report (a .twbx file). It then manipulates the menu to update the data.

Maybe I should go back to just getting ShellExecute() to call the report file, which will open with the default handler. I wanted to avoid this, in the event that the user changed the default handler for .twbx files. This could happen if the user did not have the Tableau application installed, and only had the crippled Tableau Reader installed, which breaks my app.

in that case, check out this, In terms of getting what you are looking for

HKEY_CLASSES_ROOT.twbxshellopencommand

if the command is not there check out this to get a grasp on how it might be set up.

http://msdn.microsoft.com/en-us/library/cc144158%28VS.85%29.aspx

Edited by DicatoroftheUSA
1 person likes this

Share this post


Link to post
Share on other sites

in that case, check out this, In terms of getting what you are looking for

HKEY_CLASSES_ROOT\.twbx\shell\open\command

if the command is not there check out this to get a grasp on how it might be set up.

http://msdn.microsoft.com/en-us/library/cc144158%28VS.85%29.aspx

I'm at home now, and don't have the app installed, but checked out a few other extensions. Sad to learn that there isn't a standard for these keys. In the few I checked, I didn't see any with the "\shell\open\command" hierarchy. Some extensions have a "PersistentHandler" subfolder, while a lot don't.

I guess this means if I'm going to use the registry method, I'll have to check both a machine with Tableau and another with the crippled Reader, and see if there's an identifiable key.

Other than that, I like your idea of checking for the app in its normally installed location, and failing that, hunting for it.

Thanks for your input!

Share this post


Link to post
Share on other sites

$ExtReg = inputbox("input extension" , "type the extension with the '.'" , ".au3")

$name = regread("HKLMSOFTWARECLASSES" & $ExtReg , "")

;~ msgbox (0, '' , $name)

$path = regread("HKLMSOFTWARECLASSES" & $name & "shellopencommand" , "")

msgbox (0, '' , $path)

1 person likes this

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

Another way could be this. but need split, because this list uninstaller path.

#include<GUIConstants.au3>


$gui_width = 500
$gui_height = 600

Global $count = 1, $all_keys = "", $main_key = "HKLMSOFTWAREMicrosoftWindowsCurrentVersionUninstall"

GUICreate("Installed Software", $gui_width, $gui_height, @Desktopwidth/2 - $gui_width/2, @DesktopHeight/2 - $gui_height/2 - 75)
$gui_list = GUICtrlCreateList ("", 10, 10, $gui_width - 20, $gui_height - 20)
GUISetState ()

While 1
$act_key = RegEnumKey ($main_key, $count)
If @error <> 0 then ExitLoop
$act_name = RegRead ($main_key & "" & $act_key, "UninstallString")
$act_name = StringReplace ($act_name, " (remove only)", "")
If $act_name <> "" Then $all_keys = $all_keys & $act_name & "|"
$count = $count + 1
WEnd

GUICtrlSetData ($gui_list, $all_keys)
While 1
$msg = GUIGetMsg()
If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend
Edited by Danyfirex

Share this post


Link to post
Share on other sites

$ExtReg = inputbox("input extension" , "type the extension with the '.'" , ".au3")

$name = regread("HKLM\SOFTWARE\CLASSES\" & $ExtReg , "")

;~ msgbox (0, '' , $name)

$path = regread("HKLM\SOFTWARE\CLASSES\" & $name & "\shell\open\command" , "")

msgbox (0, '' , $path)

This looks to be what I need. Thanks!

Share this post


Link to post
Share on other sites

If you have WinAPIEx or the latest Alpha release then use this >>

#include <APIConstants.au3>
#include <WinAPIEx.au3>

ConsoleWrite(_WinAPI_AssocQueryString('.au3', $ASSOCSTR_EXECUTABLE) & @CRLF)

_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

Share this post


Link to post
Share on other sites

For more details check out this >>

#include <APIConstants.au3>
#include <WinAPIEx.au3>

Local $sFilePath = _WinAPI_AssocQueryString('.au3', $ASSOCSTR_EXECUTABLE)

; See >> http://www.autoitscript.com/forum/topic/133768-pathfull-pathgetrelative-and-pathsplit-created-using-the-functions-from-winapiexau3/
MsgBox(4096, '', 'FilePath: ' & $sFilePath & @CRLF & _
        'Directory: ' & _WinAPI_PathRemoveFileSpec($sFilePath) & @CRLF & _
        'Executable: ' & _WinAPI_PathStripPath($sFilePath) & @CRLF & _
        'Extension: ' & _WinAPI_PathFindExtension($sFilePath) & @CRLF)

_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

Share this post


Link to post
Share on other sites

For more details check out this >>

#include <APIConstants.au3>
#include <WinAPIEx.au3>

Local $sFilePath = _WinAPI_AssocQueryString('.au3', $ASSOCSTR_EXECUTABLE)

; See >> http://www.autoitscript.com/forum/topic/133768-pathfull-pathgetrelative-and-pathsplit-created-using-the-functions-from-winapiexau3/
MsgBox(4096, '', 'FilePath: ' & $sFilePath & @CRLF & _
        'Directory: ' & _WinAPI_PathRemoveFileSpec($sFilePath) & @CRLF & _
        'Executable: ' & _WinAPI_PathStripPath($sFilePath) & @CRLF & _
        'Extension: ' & _WinAPI_PathFindExtension($sFilePath) & @CRLF)

Very informative.

The answer by "boththose" was workable, but didn't work quite as planned. In my example, I have both Tableau and Tableau Reader installed. Even when I set the Tableau reader to be the default for .twbx files, the code in his example returned Tableau (and not the reader). Still, it would do me

Your example in your first reply is perfect. It correctly identified the proper handler. Thank you!

Share this post


Link to post
Share on other sites

WinAPIEx has a lot more 'under the hood.' My second example was just to demonstrate how to find the extension and folder path using WinAPIEx. Glad it worked for you.


_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0