I accidentally deleted the Path environment variable by creating a new one with Path name. How can I restore my old Path environment variable?

  • 1
    Remember 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.
    – Baodad
    Commented Aug 9, 2016 at 18:29
  • I do not have "History Files" activated, nor "system protection enabled", but I found a very simple solution, just look into a proccess details started before this change, as suggested by @dosaki at superuser.com/a/1127136/1743317. You will need to download the Proccess Explorer at learn.microsoft.com/en-us/sysinternals/downloads/…
    – ruzenhack
    Commented Oct 30, 2022 at 18:13
  • IF ALL ELSE FAILS: search all disk for files containing string "C:\Windows\system32;" no quotes case insensitive and with ';' at the end. You can use other strings you know were part of the lost PATH. If you are lucky, you will find a *.log or *.dmp file that contains the lost path. This can work when system restore point, reg backup .. is not available and you already restarted PC not knowing the %PATH% is totaled.
    – CrHasher
    Commented Nov 26, 2022 at 8:13

9 Answers 9


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).

  • 13
    Excellent 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!
    – triadiktyo
    Commented Oct 3, 2016 at 14:28
  • This partially works as procexp does show the environment but long variables are not displayed completely. Also there's no way to export or something. Commented Jun 20, 2017 at 19:54
  • 1
    Certain 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. Commented Sep 3, 2017 at 11:30
  • Great 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/…
    – A-S
    Commented May 13, 2020 at 7:55
  • I do not have "History Files" activated, nor "system protection enabled", but I found a very simple solution, just look into a proccess details started before this change, as suggested by @dosaki at superuser.com/a/1127136/1743317. You will need to download the Proccess Explorer at learn.microsoft.com/en-us/sysinternals/downloads/…
    – ruzenhack
    Commented Oct 30, 2022 at 18:12

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)

Example of previous versions of RegBack

and examined the earliest ControlSet within the HKEY_LOCAL_MACHINE/System node of that copy of the registry file, ControlSet002:

enter image description here

and copied out the previous value of my path variable from the key Control\Session Manager\Environment\Path within that level.

enter image description here

Your mileage may vary, as I don't know exactly what triggers the backup of the registry.

  • 2
    Even 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" Commented Mar 12, 2014 at 6:38
  • What 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?
    – Ungeheuer
    Commented Oct 18, 2016 at 2:50
  • Where are those backups stored? Commented Nov 3, 2017 at 1:28
  • 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 click Path

The previous Path should be there.

  • 2
    This 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. Commented Jun 20, 2017 at 19:56
  • 9
    It shows the current path. Not the old one. Commented Nov 3, 2017 at 1:26
  • it doesnt show me the path at all :(
    – Ayyash
    Commented Oct 26, 2018 at 10:36
  • The WinAVR installer clobbered my PATH variable instead of appending to it... Worked for me, thanks for the save! Commented Feb 10, 2019 at 16:24

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.


"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:


Thanks for the responses and suggestions, which had lead me into the right direction to create this answer.

Here are the steps to recover your previous PATH environmental variable contents if you have any application or background process running that has started before your PATH had changed:

  1. Download Progress Explorer: https://learn.microsoft.com/nl-nl/sysinternals/downloads/process-explorer .
  2. Open progexp.exe.
  3. In the Process list, find an application that has been running since before your PATH change. Right click the application and select Properties....

enter image description here

  1. In the properties window, click the Environment tab. You will see the PATH variable that was used to start this application with. If no environmental variables show up for this process, try another process.

enter image description here

  1. Click the Path entry in the list and press ctrl + c to copy their contents.
  2. Paste the copied contents in a text editor and remove the initial Path part. You now have the lost PATH entries that you had lost. WARNING: This obtained Path consists of the system PATH combined with your user-specific PATH (in that order, separated by a ;). If only one of both PATH variables has been lost, you can use the remaining one to determine where the split between system and user paths was.

This method works because environmental variables are cloned into a new environment when a process starts, thus remaining unchanged for the lifetime of that process (unless deliberately changed). So as long as you have a process running that started before an undesired change to PATH was made, it is possible to get the pre-changed PATH using this method.


I only discovered the problem with the environment variables days after they got ruined by the installation of an outdated app. But I still had a full registry backup. There one can find all the system environment variables as off the date of the backup. These can then be compared with the current situation as per System / Advanced system settings / Environment variables. Depending upon how recent the backup is, and assuming no environment variable changes since then, you are ok. Worst case is that you'll have to reinstall the apps that you had installed after the registry backup and before losing your path data, which is typically less work than a restore. Below I'll explain how this can be done.

  1. Open the backup.reg file with Notepad++ (free and excellent editor). Find HKEY_LOCAL_MACHINE/SYSTEM/ControlSet001/Control/Session Manager/Environment. If that does not work try ControlSet002 or higher.

  2. Copy paste the hex(2) hash data for the PATH into a new Notepad++ window. Find/replace all ',' (commas w/o the quotes) with ' ' and all '00' with '', and all double spaces ' ' with a single space ' '. You should now be left with "pure hex" without commas or zeros as separator.

  3. Open http://www.rapidtables.com/convert/number/hex-to-ascii.htm . This is a hex to ascii converter. Copy paste the "pure hex" data into the hex window and click convert. You can now see your path data, and copy paste them into Notepad, compare with the current version, and add the missing data. You're back in business!

  4. As a bonus you might also want to check on the other environment variables by comparing the data in the Notepad++ backup.reg with the current values. Missing data can be retrieved in the same way as explained above.


I accidentally deleted the Path environment variable

So did I, and many commands that used to work suddenly produced an error:

The term '<command>' is not recognized as the name of a cmdlet, function, script file, or operable program. 

The other answers to this problem didn't work for me, so

I had to recover the Path environment variable a little at a time:

  1. From a plain command prompt, not PowerShell, enter where <command>, e.g., where npm.
  2. Enter "environment variables" in Cortana to edit the system environment variables.
  3. Under System variables, find the Path variable and click Edit.
  4. Add each file path from step 1.
  5. Restart your computer.
  6. Repeat for each command that produces the error.
  7. Enjoy using commands that work. :-)

enter image description here


I have just retrieved it by doing as follows: My previous Path settings was still on the dos cmd prompt screen. So right click on it with your mouse. Take 'Select All'. This copies your screen. Open Notepad, and paste. Now highlight the Path definition in notepad, right click and copy. Go back to dos cmd prompt screen. right click and paste This has worked for me so Good Luck!

  • 2
    This duplicates information already present in another answer, and pre-supposes that one happens to have a command prompt already open in this situation.
    – bertieb
    Commented Sep 5, 2015 at 15:38

You must log in to answer this question.

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