How to restore the Path environment variable I deleted?
Solution 1
I lost my PATH with a program install earlier today, but with all the existing programs already running, it was easy to get it back. If you have a command window open, run:
echo %PATH%
If you don't, you can look at the environment variables of currently-running programs with Process Explorer (procexp).
Solution 2
I followed the advice in the answer to a related question here and recovered my previous path setting as of this morning using regedit. Expanding a bit on that answer, here's how I did it. (Read the linked answer to get the full instructions, I don't provide all the details here.)
I selected my earliest backup from today (11:43 AM timestamp in 'Today' section)
and examined the earliest ControlSet within the HKEY_LOCAL_MACHINE/System node of that copy of the registry file, ControlSet002:
and copied out the previous value of my path variable from the key Control\Session Manager\Environment\Path within that level.
Your mileage may vary, as I don't know exactly what triggers the backup of the registry.
Solution 3
- From the start menu, open Run (or press ⊞ Win+R).
- Type
regedit
- Find
HKEY_LOCAL_MACHINE folder
- Go to the
SYSTEM folder
- Go to the
ControlSet002
folder - Go to
Control
folder - Go to
Session Manager
- Go to
Environment
folder - Then, inside
Environment
folder, double clickPath
- Find
The previous Path should be there.
Solution 4
You could do a system restore.
To restore your PC using System Restore
Swipe in from the right edge of the screen, and then tap Search. (If you're using a mouse, point to the upper-right corner of the screen, move the mouse pointer down, and then click Search.) Enter Recovery in the search box, tap or click Settings, and then tap or click Recovery.
Tap or click Open System Restore, and follow the prompts.
Solution 5
"Restoring" from a default set is another option, with the risk of some installed apps complaining until fixed.
Background: Happened when launching WLM after a reboot. The only thread with information regarding the missing WLDcore.dll suggested a missing PATH
environment variable.
Before the said reboot, there was an admin PS console open in the attempt to make Curl accept commands. Must have knocked out the PATH
variable with it somehow.
Fortunately, and unfortunately, Brink's default PATH values were copied to
System Properties\Environment Variables before accessing the values from ControlSet001 (no ControlSet002 here) referred to in other answers in this thread.
So the only option to recover the original values was with the system restore also mentioned in this thread. A good thing is the apps that use PATH
on this machine document their requirements of it, so easy to repair.
For those who experienced similar, here's Brink's Windows 10 values:
%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Windows Live\Shared
And his bare minimum for previous OSes:
%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\
Related videos on Youtube
deno
Updated on September 18, 2022Comments
-
deno over 1 year
I accidentally deleted the Path environment variable by creating a new one with Path name. How can I restore my old Path environment variable?
-
Baodad almost 8 yearsRemember that each Windows console session has its own PATH environment variable, which can be displayed or changed using the PATH command. But if you close the console and open a new one, the original system PATH will be restored. I'm not sure if this is the case with an elevated console session.
-
-
Jahmic about 10 yearsEven easier, a note from the old question "Note that for System, depending on how long ago this was, you can just go back into HKLM(old control set version)\Control\Session Manager\Environment without loading an old hive"
-
bertieb over 8 yearsThis duplicates information already present in another answer, and pre-supposes that one happens to have a command prompt already open in this situation.
-
triadiktyo over 7 yearsExcellent answer. Saved me from restoring a backup. May I share a potentially not-so-obvious trick of how to open a command window if you don't have one open. If you have a program that has an open dialog (I used Chrome since it was open before I lost the path), hit Ctrl-O to open a website. Navigate to C:\Windows\system32\ and find cmd.exe. Right-click on cmd.exe and click Open. This will bring up a command prompt with the environment variables of the software (chrome in this instance) and you can echo %path% to get your old env variables!
-
Ungeheuer over 7 yearsWhat is MOLD? When i go to the previous versions of Regback, I see one previous folder, and despite the depth of the linked answer, I still don't know what to do. Also, how did you manage to open the HKEY_LOCAL_MACHINE/System node of any Regback folder?
-
javydreamercsw almost 7 yearsThis partially works as procexp does show the environment but long variables are not displayed completely. Also there's no way to export or something.
-
javydreamercsw almost 7 yearsThis should be the accepted answer. The one chosen works for short variables and doesn't allow for copy and paste. Here you can do it as needed.
-
Stein Åsmul over 6 yearsCertain MSI packages can cause this problem - zapping the PATH environment variable. This is a useful trick if that happens to you - as is using System Restore if that is available. If you are on an SOE (Standard Operating Environment, or standardized desktops), you could try to copy the PATH variable from another computer - it is better than nothing and might work properly too if the application estate is the same on both computers.
-
Shimmy Weitzhandler over 6 yearsIt shows the current path. Not the old one.
-
Shimmy Weitzhandler over 6 yearsWhere are those backups stored?
-
Ayyash over 5 yearsit doesnt show me the path at all :(
-
shadowtalker over 5 yearsThe WinAVR installer clobbered my PATH variable instead of appending to it... Worked for me, thanks for the save!
-
A-S about 4 yearsGreat solution, and I love Process Explorer, but as mentioned by others - long parameter are getting cut-out. I really recommend this answer: superuser.com/questions/523688/…