21
4
I needed to add a new entry to my PATH variable. This is a common activity for me in my job, but I've recently started using Windows 8. I assumed the process would be similar to Windows 7, Vista, XP...
Here's my sequence of events:
- Open System properties (Start-> [type "Control Panel"] -> Control Panel\System and Security\System -> Advanced system settings -> Environment Variables)
- Add the new path to beginning of my USER PATH variable (C:\dev\Java\apache-ant-1.8.4\bin;)
- Opened a command prompt (Start -> [type "command prompt" enter] -> [type "path" enter]
My new path entry is not available (see attached image and vide). I Duplicated the exact same process on a Windows 7 machine and it worked.
EDIT
Windows 8 Environment Variables and Command Prompt video
EDIT
This is definitely not the behavior of Windows 7. Watch this video to see the behavior I expect working in Windows 7. http://youtu.be/95JXY5X0fII
EDIT 5/31/2013
So, after much frustration, I wrote a small C# app to test the WM_SETTINGCHANGE
event. This code receives the event in both Windows 7 and Windows 8. However, in Windows 8 on my system, I do not get the correct path; but, I do in Windows 7. This could not be reproduced in other Windows 8 systems.
Here is the C# code.
using System;
using Microsoft.Win32;
public sealed class App
{
static void Main()
{
SystemEvents.UserPreferenceChanging += new UserPreferenceChangingEventHandler(OnUserPreferenceChanging);
Console.WriteLine("Waiting for system events.");
Console.WriteLine("Press <Enter> to exit.");
Console.ReadLine();
}
static void OnUserPreferenceChanging(object sender, UserPreferenceChangingEventArgs e)
{
Console.WriteLine("The user preference is changing. Category={0}", e.Category);
Console.WriteLine("path={0}", System.Environment.GetEnvironmentVariable("PATH"));
}
}
OnUserPreferenceChanging
is equivalent to WM_SETTINGCHANGE
C# program running in Windows 7 (you can see the event come through and it picks up the correct path).
C# program running in Windows 8 (you can see the event come through, but the wrong path).
There is something about my environment that is precipitating this problem. However, is this a Windows 8 bug?
EDIT 2014-04-28
Due to this and several other issues, we no longer use Windows 8 on the desktop. We do not have an environment to continue testing and experimenting with this problem. There is still no answer or resolution to this problem for us. The answers below did not resolve our problem.
2I think you need to reboot after making the changes for them to take effect. – Enigma – 2013-05-10T15:02:18.790
@Enigma Why? I didn't need to reboot in Windows 7, Vista, XP, 2000... – mawcsco – 2013-05-10T15:08:42.467
@mawcsco You did in 7 at least. Opening command prompts from the start menu launches with the environment from the Explorer shell, which was loaded when you logged in. You need to either kill/restart explorer, log out or back in, or restart the system. – Darth Android – 2013-05-10T15:17:21.740
@mawcsco - I needed to reboot in 7 for PATH changes to take effect. Have you tried a reboot yet? – Enigma – 2013-05-10T15:38:06.693
1
@Enigma A reboot should not be necessary. http://serverfault.com/questions/8855/how-do-you-add-a-windows-environment-variable-without-rebooting
– mawcsco – 2013-05-10T15:41:49.487@mawcsco - So then whatever is the issue here may be an issue for me as well. "Any programs spawned via Explorer after this should get the updated environment, although already-running programs will not, unless they handle the setting change message." – Enigma – 2013-05-10T17:22:43.977
1I've just checked this on both Windows 7 and Windows 8: in either case the new environment variable was visible in
cmd
when a new instance was launched. Of course the already runningcmd
didn't get the updated environment. – Alexey Ivanov – 2013-05-10T17:39:38.420@AlexeyIvanov I've just created a video with the problem on my Windows 8 Machine. When YouTube is done "processing" I will post the link. – mawcsco – 2013-05-10T21:15:16.213
@Enigma I think it's reasonable to conclude that there is an issue and that it may have existed in Windows 7, thus you've experienced a similar issue in Windows 7. Alexey Ivanov indicates that he does not experience this issue and we tried to reproduce it on my neighbor's Surface Pro with no luck. – mawcsco – 2013-05-10T21:17:06.623
Try changing something in the system path instead of the user path. – jdigital – 2014-03-08T00:53:44.210