Best way to find an executable

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
BGM
Posts: 507
Joined: 20 Nov 2013, 20:56
Contact:

Best way to find an executable

22 Feb 2018, 16:51

My script is a GUI for another program, but it needs to assure that the other program is installed, and needs to find the file path.

The program could be installed anywhere - c:\program files\thisapp, c:\program files (x86)\thisapp, c:\thisapp, etc.
However, it always resides in a folder with it's own application name, in my example here, "thisapp".
Sometimes it may also be an environmental variable.

What is the best approach to discovering it's location?
I want to add a sort of wizard that will locate the executable.

So far, all I can think of is to use FileLoop somehow and hope it doesn't take forever, or look in the most likely places and hope it's just there.
RickC
Posts: 302
Joined: 27 Oct 2013, 08:32

Re: Best way to find an executable

22 Feb 2018, 17:29

Have you tried a search loop through HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall? If the app writes an entry there then it should be easy to find its InstallLocation.

Have a look at https://autohotkey.com/docs/commands/LoopReg.htm#new for more info/examples.

Hope this helps...
User avatar
BGM
Posts: 507
Joined: 20 Nov 2013, 20:56
Contact:

Re: Best way to find an executable

22 Feb 2018, 17:38

The program in mind won't have an entry there - it uses an unconventional installer.
User avatar
Masonjar13
Posts: 1555
Joined: 20 Jul 2014, 10:16
Location: Не Россия
Contact:

Re: Best way to find an executable

22 Feb 2018, 20:11

The best efficiency method I can think of is to loop through the folders in the most likely places (start deeper and go up) (with recursion). So, check the folders in, say, program files, then if it's not there, check the next place. If all else fails, then you can do a system-wide search.

Alternatively, if it's already running, you can just grab the path from the processes command line info. Just prompt the user to run it, while constantly checking the processes, wait for it to exist, then grab it and continue.
OS: Windows 10 Pro | Editor: Notepad++
My Personal Function Library | Old Build - New Build
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Best way to find an executable

22 Feb 2018, 20:59

- If it has a Start menu link, try searching in these folders:
A_StartMenu
A_StartMenuCommon
- Some programs store their full paths in the registry:
HKEY_CLASSES_ROOT\Applications
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths
Best way to get the path to an executable - AutoHotkey Community
https://autohotkey.com/boards/viewtopic ... 51#p168051
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: CodeKiller, just me, rc76, yxldh and 194 guests