1

How to run this command properly?

Pause::Run notepad++ D:\Data\Config\Essential.ahk

I get this error:

Error: Failed attempt to launch program or document:
Action: <notepad++ D:\Data\Config\Essential.ahk>
Params: <>

Specifically: The system cannot find the file specified.

Using Notepad++ for any key, or Pause key with notepad doesn't work. This doesn't involve system directories, as talked in this related question (Why does AutoHotkey respond with a "System cannot find the file" error?). Do you have any idea?

Full error:

Ooker
  • 1,969
  • 4
  • 28
  • 58

2 Answers2

2

Is "notepad++.exe" in your path?

Try specifying the full path to notepad++.exe and see if that fixes it:

Pause::run "C:\Program Files (x86)\Notepad++\notepad++.exe" D:\Data\Config\Essential.ahk

NOTES:

  • make sure notepad++.exe is installed in the above directory
  • you can locate notepad++.exe by opening a command prompt and running cd \ && dir notepad.exe /s
  • Use a command prompt and enter set path to see if notepad++.exe's directory is in your path
Jim U
  • 3,318
  • 1
  • 14
  • 24
0

AHK cannot know that "notepad++" is a program, if you don't use the .exe extension, therefore the error message "The system cannot find the file specified".

Try also

Pause::Run notepad++.exe D:\Data\Config\Essential.ahk

or

Pause::Run notepad++.exe "D:\Data\Config\Essential.ahk" ; more accurate syntax
user3419297
  • 9,537
  • 2
  • 15
  • 24
  • why does this work on Run dialog? Using `Run explorer /path` works as expected – Ooker Nov 09 '17 at 19:39
  • 1
    This answer is incorrect. The following launches the executable "notepad++.exe" without problem even though the `EXE` extension is omited: `F2::run "C:\Program Files (x86)\Notepad++\notepad++" c:\windows\system32\drivers\etc\hosts` – Jim U Nov 09 '17 at 22:00
  • I think, in this case AHK finds out that "notepad++" is a program, because of (= after searching in) the folder path definition and the name of the file itself, as explained in the manual ([Run_Parameters_Target](https://autohotkey.com/docs/commands/Run.htm#Parameters)). – user3419297 Nov 10 '17 at 04:36