"I feel like an idiot" is of course obligatory and accurate as an introduction. Anyway, instead of adding to the user path, I accidentally overwrote it, and lost everything in it. I haven't restarted the system yet. How can I find that information and put it back where it belongs before it's lost forever?
2 Answers
Open Regedit.exe and check HKEY_CURRENT_USER\Environment\Path if that doesn't have the old value anymore, you can try to look at a backup of your user profile.
You need the file C:\Users\username\NTUSER.DAT from a backup,
In Registry editor, select HKEY_Users, in the File menu choose Load Hive... and pick the file mentioned above, give it a name. Look in Environment\Path. When done you should unload the hive using File menu Unload Hive... while the loaded hive is selected.
If you have any programs open which you started before you changed the variable you may want to check the environment variables for those processes in Process Explorer. Explorer.exe would be an option.
- 13,710
I know this is an old question. But I did the same thing. The security policy on my workstation restricts regedit so I did the following.
- Open PowerShell.
%env = Get-ItemProperty -Path "HKCU:\Environment"%env.path- If this returns the previous value then save a copy of it in notepad (just in case) and replace your local path variable with that.
- if you want to stick to powershell, you should be able to use
Set-ItemProperty -Path "HKCU:\Environment" -Name Path -Value %env.path
- 121
HKEY_CURRENT_USER\Environment\Pathhas nothing, and there isn't an NTUSER.dat under my username, but there is one under the Default user. It looks like it was created when I shut down my computer last night (is that when they do that?) – Sword of Spirit Oct 13 '16 at 10:10C:\Program Files (x86)\Mozilla Firefox. So does that mean both the WindowsApps and Firefox entries should be there, or is the Firefox one just coming from its currently running status? – Sword of Spirit Oct 13 '16 at 10:20%USERPROFILE%which is expanded automatically toC:\users\username. So if you ever change your username in the future it still works. – Peter Hahndorf Oct 13 '16 at 10:47NTUSER.datis a hidden system file, that's why you may not see it. There should be one. Thedefault userone is not yours, it is used as a template when creating new users. Most programs change the local machine path, not the user path. – Peter Hahndorf Oct 13 '16 at 10:49NTUSER.DATin your user directory is the currently loaded one and has the same data asHKEY_CURRENT_USERI wrote you need to get one from a backup of your user directory (if you have one). But it seems there was not much in your user path anyways, so you may not bother. By default you only have%USERPROFILE%\AppData\Local\Microsoft\WindowsApps;– Peter Hahndorf Oct 13 '16 at 11:09