4

I am trying to use a package called virtualenv for Python, which temporarily changes the PATH environment variable to add a certain directory and give convenient access to several executables. My problem is that this doesn't seem to work. The directory gets added to the start of the path as expected, and I can verify this by typing PATH at the prompt, but if I type the name of an exe in that directory, it doesn't run. If I navigate to that directory however, the app will run ok. It seems like Windows is ignoring the altered environment variable, perhaps using what was listed for PATH in the registry (eg. HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\Path).

Does anybody know what could be causing this? I am running as an administrator on Windows 7.

11
  • Are you trying to execute the application from the same command prompt where you verified the modified PATH, or a different one?
    – haimg
    Oct 10, 2011 at 18:42
  • The same one. Literally in the next command in that window.
    – Kylotan
    Oct 10, 2011 at 18:55
  • Are you typing the file extension as well? Is the extension listed in %PATHEXT%? Oct 10, 2011 at 19:35
  • These are .exe files, so the answer is "No" and "Yes" respectively.
    – Kylotan
    Oct 10, 2011 at 21:05
  • 1
    @Kylotan I had a similar problem for ages. I finally sat down and debugged it using Process Monitor (as suggested here), and I found, I had a typo in the path, causing it to ignore a major part of the %Path% variable. Lesson learned: If Windows ignores your changes to %Path%, you probably have a typo in it! Windows likes to silently ignore errors. Btw, why is this thread closed? It is the first hit on Google when looking for: Windows ignores path. Please re-open it, so I can post this as an answer?
    – Domi
    Apr 23, 2014 at 8:20

1 Answer 1

0

It seems that the cmd does load the environment variables when it is created, and you have to close it and open a new one to have those refreshed.

There may be a command to force it to refresh the env_vars -

2
  • 1
    That doesn't sound right, if you have changed the path from inside cmd, I'm fairly sure it updates right away.
    – David
    Jun 19, 2013 at 16:30
  • 2
    Well if you change it using the GUI stuff, which makes total sense on a GUI OS, it does not. also people who -1 should think about how that's going to help the poor guys who make the exact same mistake.
    – Morg.
    Jun 21, 2013 at 9:53

Not the answer you're looking for? Browse other questions tagged .