I recently installed openssh on my Windows 7 machine. The install overwrote my Path variable and blew away all of the other paths I use in the command line. I probably have 50 paths in there and it is going to take me forever to remember them all. Is there anyway to recover this variable from before the install?
Your environment is in the Registry, and may be saved as part of a system restore point. You could try reverting to the previous restore point, but it may revert more than just your install of OpenSSH (i.e., you may have to re-install other software).
In case you don't have any restore point or you don't want to go through that process, Microsoft provides a tool called Process Explorer with which you can inspect the path at the time a process was created.
This method won't work if you've restarted your machine as it depends on the processes running before your PATH variable was changed.
- DO NOT REBOOT YOUR MACHINE
- Download Process Explorer by Microsoft
- Extract it somewhere and run it
- Double-click one of the processes which was up before PATH was lost
- Select the “Environment” tab
- Find PATH and copy it (it will also copy the variable name, so you need to take it out)
- Paste it onto your PATH variable.
That should do it. Keep in mind that these PATH variables are resolved, i.e., you won't have any %VARIABLE_HERE% in the path value.
PATH environment variable is stored in Windows Registry under:
Path parameter. ("x" in "ControlSet00x" is a digit.)
If the Registry is backed up as part of one of your System Restore checkpoints, you can extract the backed up copy without restoring your system to a previous checkpoint! To do this:
- Navigate to
C:\Windows\System32\Config. I prefer to do this in an app like Multi Commander, so as not to disturb its NTFS permissions.
- Right-click on
SYSTEMfile. DO NOT mistakenly right-click on SYSTEM.LOG1 or SYSTEM.LOG2
- Click Properties.
- Go to Previous Versions tab.
- Restore a previous version of this file as well as SYSTEM.LOG1 and SYSTEM.LOG2 somewhere else in your computer.
- Now open
- Select File->Load Hive...
- Give the address of the extracted
SYSTEMfile and then give a hive name, like
Now, find your
PATHvariable within this new hive.
You can find it in
- Once you are done, unmount the hive and delete
.REGTRANS-MSfiles that Windows has made for these files.