You can configure the NPPExec plugin in Notepad++ to have a startup script. I use this to set certain environment values that I don't normally use to make script execution easier. The problem is that I can't run that startup script more than once, or it will damage the environment.

However, when Notepad++ starts up with a startup script, that script also becomes the current script. So if you try to run the current script, you run the startup script again.

Is there some kind of condition or something that I can put in the script that will allow it to only run once? Like the last line of the script sets an environment variable, and the first line aborts if the variable is set?

It's really annoying to have to restart a fresh copy of Notepad++ just because I forgot to set the current script and pressed F5.

  • What difficulties are you having following your own suggestion of setting a new environment variable and making the script execution conditional upon its non-existence ? – harrymc Sep 14 '11 at 6:30
  • @harrymc: The problem is that I don't know how to do that. I don't know how to do conditional logic in NPPEXEC's language. – Nicol Bolas Sep 14 '11 at 6:33

There is no easy way to resolve your issue. Currently, NppExec does not supports conditional statements at all, and will unlikely support them in near future (see forum topic). Startup script becoming current is a default behaviour, and not me nor my friends knows how to change that.

There is a hard way, still - as NppExec is open-source, you may edit the sources to stop startup script from becoming current. The only question remains - does it worth the efforts?...


Strange: Environment variables are easy to define and reference, but I cannot find any conditional test of any kind in nppexec.

Another idea would be to finish the startup script with the npp_close command, to at least get it out of the way so it cannot be executed via F5.


You could do it by creating a powershell script then pointing your nppexec at that.

  • 1
    To clarify, your solution is to just use a shell script to set the paths and so forth outside of Notepad++, yes? But then, wouldn't I have a useless console window sitting there taking up room in my taskbar? – Nicol Bolas Dec 12 '11 at 23:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.