Home > front end >  How does AutoHotkey determine which executable is launchable with a mere `.exe` name?
How does AutoHotkey determine which executable is launchable with a mere `.exe` name?

Time:10-17

In my experience, #f::Run mailmaster will launch mailmaster.exe when pressing #f, but throws when doing #f::Run QQMusic:

enter image description here

I had to provide the full path for QQMusic.exe whereas I didn't have to provide the full path for mailmaster.exe.

According to the documentation:

Run can launch Windows system programs from any directory. Note that executable file extensions such as .exe can be omitted.

Run notepad

Since both mailmaster.exe and QQMusic.exe are non-system programs and they are not included in the Path environment variable, why AutoHotkey is giving different behaviors for them?

And performance-wise, providing the full path versus just the .exe name, which is faster?

CodePudding user response:

It's specified in the documentation:

Target

A document, URL, executable file (.exe, .com, .bat, etc.), shortcut (.lnk), or system verb to launch (see remarks). If Target is a local file and no path was specified with it, A_WorkingDir will be searched first. If no matching file is found there, the system will search for and launch the file if it is integrated ("known"), e.g. by being contained in one of the PATH folders.

So pretty much if it's found in PATH.
You can try this for example by typing notepad, mailmaster and QQMusic in cmd or powershell. Notepad is found in PATH, and on your system I'm assuming mailmaster is as well, and QQMusic isn't.
You should get the same results as with the AHK Run command.

As for performance, I don't know, I guess this is something you could benchmark.
I'd guess that providing the full path is more efficient.
But maybe finding something from PATH is very well optimized on the the Windows side of things, so maybe there is little to no difference.

  • Related