Best way to find an executable

Get help with using AutoHotkey and its commands and hotkeys
User avatar
BGM
Posts: 419
Joined: 20 Nov 2013, 20:56
GitHub: bgmCoder
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: 188
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: 419
Joined: 20 Nov 2013, 20:56
GitHub: bgmCoder
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: 1388
Joined: 20 Jul 2014, 10:16
GitHub: Masonjar13
Location: Не Россия

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.
User avatar
jeeswg
Posts: 4959
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.php?f=5&t=36484&p=168051#p168051

Return to “Ask For Help”

Who is online

Users browsing this forum: FanaticGuru, fohrums and 24 guests