System hacks: restore Windows 10 path environment variables

Sometimes, we execute some commands or run some programs in the Windows 10 “Run” window, when even if you do not specify the specific path of the program, just enter the name of the program (such as notepad.exe), you can quickly call successfully. This is because the Windows default path environment variable is in effect, it will guide to find the required program.

However, sometimes because of manual operation or software operation errors, accidentally delete the path environment variable, which may cause the next time after the start, running programs can not find the path of the problem. So, how to recover the path environment variable when it is lost?

First of all, when you find that the path environment variable is lost, it is best not to reboot the system in a hurry. At this point, there is hope for successful recovery through command prompt window, PowerShell window, registry, etc. Of course, there are remedies after rebooting the system.

1. Recover with Command Prompt or PowerShell

If the path variable is deleted or modified in the “Environment Variables” window under the “Advanced” tab of the System Properties window, you can try to get the path environment variable by running the following command in the Command Prompt window (Figure 1).

echo %PATH%

1922A-LJBL-1

Alternatively, you can go to a PowerShell window and run the following command to get it (Figure 2)

Get-ItemProperty -Path “HKCU:Environment”

1922A-LJBL-2

Finally, fill in the obtained path environment variable value into the corresponding position in the environment variable setting window to restore.

2. Recover using the user configuration backup file

If you have a backup of the user configuration file or a backup of the system, find the file named NTUSER.DAT in the user name subfolder located in the Users folder (Figure 3). Open this file with Notepad, which contains the environment variables for the old path, and look for PATH-related statements to get the path environment variables. Of course, this method relies on the prerequisite of having a backup.

1922A-LJBL-3

3. Use registry editor to get the path

Press Win+R to open the “Run” box and type regedit to open the Registry Editor. In the registry editor, navigate to “HKEY_CURRENT_USEREnvironment” (Figure 4), the Path environment variable is listed under the Environment key. Double-click it to open it and copy all the paths to Notepad, then you can use the path value to reset it in the Environment Variables Settings window.

1922A-LJBL-4

If you have restarted the system after the environment variables have been deleted by mistake, the environment variables in the registry may also be cleared. In this case, search for the entry named Environment in the registry and check if the path environment variable is still included under the relevant option that appears in the results. If the default path environment variable in the registry is completely cleared, then you can go to the registry of the same version of Windows 10, find and copy the default path environment variable value, and restore it.

Leave a Comment