title: Running File from Notepad Plus Plus and Current Directory
body: <p>There are a number of examples on the web of how to run a file from the Notepad Plus Plus (NPP). But they all fail to account for the fact that the current working directory is the location of the NPP's executable, and not the location of the file.<br>
  Usually they go something like this:</p>
  
  <pre><code>cmd /K "$(FULL_CURRENT_PATH)" 
  </code></pre>
  
  <p>Consider the following Python script:</p>
  
  <pre><code>with open('somefile.txt', 'a') as file:
      file.write('Hello there.\n')
  </code></pre>
  
  <p>This file will be created in the NPP folder, which is not at all what most people would expect. Most people would want it in the same location as the Python file.</p>
  
  <p>You could also do something like this, and it works as expected, but this limits you to Python files only:</p>
  
  <pre><code>&lt;Command name="Run This Python File" Ctrl="no" Alt="no" Shift="yes" Key="116"&gt;cmd /K python &amp;quot;$(FULL_CURRENT_PATH)&amp;quot;&lt;/Command&gt;
  </code></pre>
  
  <p>I would not want to add extra code to the Python script to change the current working directory, as normally this would not be needed.</p>
  
  <p>I have been trying to solve this and came up with the following. This line goes in "<em>shortcuts.xml</em>" in the NPP folder.</p>
  
  <pre><code>&lt;Command name="Run This File" Ctrl="yes" Alt="no" Shift="no" Key="116"&gt;cmd /K &amp;quot;cd &amp;quot;$(CURRENT_DIRECTORY)&amp;quot; &amp;amp;&amp;amp; &amp;quot;$(FULL_CURRENT_PATH)&amp;quot;&amp;quot;&lt;/Command&gt;
  </code></pre>
  
  <p>So you shut down the NPP, edit the "<em>shortcuts.xml</em>" by adding this line, using another editor, then launch the NPP.
  To run the file, use <em>Ctrl+F5</em> key combination.</p>
  
  <p>This works in Windows 10, but fails in Windows XP.</p>
  
  <p>How can I tweak it to work in Windows XP?</p>