Seth Spearman
Seth Spearman

Reputation: 6780

Can someone tell me how to run a batch file from Notepad++

I thought I could run a batch file from Notepad++ directly using nppexec by (or the built in run command) by typing CMD $(FULL_CURRENT_PATH)

But since notepad++ HAS a CMD command (which open the cmd shell in the npp console) then it is not working. So running the above command opens cmd shell in the npp console but does not run the batch file. At that point I can run $(FULL_CURRENT_PATH) AND it will run the batch file. But then I have to type exit to get our of command shell mode.

Can someone tell me how to run the batch file I am current editing in npp directly in npp.

Upvotes: 34

Views: 48117

Answers (5)

Stuart Halliday
Stuart Halliday

Reputation: 41

cmd /k "cd $(CURRENT_DIRECTORY) && "$(FULL_CURRENT_PATH)"" & pause

This catches Batch files with spaces in it.

Upvotes: 4

nthaih
nthaih

Reputation: 71

You can use the run menu in notepad++ to create shortcuts:

  1. Run -> Run (F5)
  2. Type command line into "The Program to Run"
  3. Save, type the name (choose the shortcut if you need)

With me:

link to example image

"C:\Program Files\TortoiseSVN\bin\TortoiseProc.exe" /command:update /path:"$(FULL_CURRENT_PATH)"
"C:\Program Files\TortoiseSVN\bin\TortoiseProc.exe" /command:commit /path:"$(FULL_CURRENT_PATH)"
"C:\Program Files\TortoiseSVN\bin\TortoiseProc.exe" /command:lock /path:"$(FULL_CURRENT_PATH)"
"C:\Program Files\TortoiseSVN\bin\TortoiseProc.exe" /command:unlock /path:"$(FULL_CURRENT_PATH)"
"C:\Program Files\TortoiseSVN\bin\TortoiseProc.exe" /command:log /path:"$(FULL_CURRENT_PATH)"

Upvotes: 3

Dorian
Dorian

Reputation: 417

To run batch within its parent directory, you have to pass /d param to cd to change drive letter if needed and and escape paths(if contains spaces).

cmd /c "cd /d ""$(CURRENT_DIRECTORY)"" && ""$(FULL_CURRENT_PATH)"""

Upvotes: 3

Greck
Greck

Reputation: 590

With RunMe plugin you can do this. It can change current directory to the file path before open the file and Ben's solution doesn't do this. ;)

Upvotes: 24

Ben
Ben

Reputation: 3962

cmd /c "$(FULL_CURRENT_PATH)"

:)

Upvotes: 56

Related Questions