Why does AutoHotkey respond with a “System cannot

2019-05-07 06:51发布

问题:

I'm new to AutoHotkey and cannot understand why this script is giving me the error:

 Failed to launch program or document
 Action: <C:\Windows\System32\msg.exe>
 Params: <* "Initiated.">
 Specifically: The system cannot find the file specified.

Here is the simple script in my test.ahk file:

Run, "C:\Windows\System32\msg.exe" * "Initiated."

I've verified that the msg.exe file is in the c:\Windows\System32 folder and I can run it without the script from both a command prompt and by clicking on the msg.exe program. I can also create a shortcut for msg.exe and it works, but I cannot figure out how to get the test.ahk script file to see it.

I tried running the script (by clicking on the test.ahk file), as Administrator but get the same error.

回答1:

That path gets redirected to C:\Windows\SysWOW64 for 32-bit programs.

Try changing the path in your script to "C:\Windows\SysNative\msg.exe"

Or better yet, don't put non-system files in directories owned by the OS.