I messed up the PATH system variable by accidentally deleting it, and now I am trying to restore it to its original value. I came across some solutions for Windows 8 and earlier versions, but not for Windows 10. Although the values might be similar, I want to find the exact string to make sure I don’t miss anything.
Additionally, the Regedit tree has changed, and I’m having difficulty finding the variable.
3 Answers
Introduction
The PATH system variable in Windows 10 is an essential part of the operating system. It contains a list of directories that the operating system searches when looking for an executable file. However, if this variable gets deleted or modified, it can cause issues with running applications and commands. In this blog post, we will discuss how to restore the PATH system variable in Windows 10 if it has been accidentally deleted.
Method 1: Using the Environment Variables Window
The easiest way to restore the PATH system variable in Windows 10 is by using the Environment Variables window. Here are the steps:
1. Open the Start menu and search for “Environment Variables.”
2. Click on “Edit the system environment variables.”
3. In the System Properties window, click on the “Environment Variables” button.
4. In the Environment Variables window, scroll down to the “System Variables” section and look for the “Path” variable.
5. Click on the “Edit” button and then click on the “New” button.
6. Enter the path to the directory that you want to add to the PATH variable and click “OK.”
7. Repeat step 6 for each directory that you want to add to the PATH variable.
Once you have added all the directories that you want to the PATH variable, click “OK” to close all the windows. The changes will take effect immediately, and you should be able to run commands and applications that rely on the PATH variable.
Method 2: Using Registry Editor
If you are unable to restore the PATH system variable using the Environment Variables window, you can try using Registry Editor. Here are the steps:
1. Press the Windows key + R to open the Run dialog box.
2. Type “regedit” and press Enter to open Registry Editor.
3. In the Registry Editor window, navigate to “HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControlSession ManagerEnvironment.”
4. Look for the “Path” variable and double-click on it.
5. In the Edit Environment Variable window, enter the path to the directory that you want to add to the PATH variable.
6. Click “OK” to save the changes.
7. Repeat step 5 and step 6 for each directory that you want to add to the PATH variable.
Once you have added all the directories that you want to the PATH variable, close the Registry Editor window. The changes will take effect immediately, and you should be able to run commands and applications that rely on the PATH variable.
Method 3: Using Command Prompt
Another way to restore the PATH system variable in Windows 10 is by using Command Prompt. Here are the steps:
1. Open Command Prompt as an administrator.
2. Type the following command and press Enter: setx PATH “%PATH%;C:NewDirectory”
3. Replace “C:NewDirectory” with the path to the directory that you want to add to the PATH variable.
4. Press Enter to execute the command.
5. Repeat step 3 and step 4 for each directory that you want to add to the PATH variable.
Once you have added all the directories that you want to the PATH variable, close Command Prompt. The changes will take effect immediately, and you should be able to run commands and applications that rely on the PATH variable.
Method 4: Using PowerShell
If you prefer using PowerShell, you can also restore the PATH system variable using it. Here are the steps:
1. Open PowerShell as an administrator.
2. Type the following command and press Enter: $oldPath = [Environment]::GetEnvironmentVariable(“Path”, “Machine”)
3. This command saves the current value of the PATH variable to the $oldPath variable.
4. Type the following command and press Enter: $newPath = $oldPath + “;C:NewDirectory”
5. Replace “C:NewDirectory” with the path to the directory that you want to add to the PATH variable.
6. Type the following command and press Enter: [Environment]::SetEnvironmentVariable(“Path”, $newPath, “Machine”)
7. This command sets the new value of the PATH variable.
8. Repeat step 5 and step 6 for each directory that you want to add to the PATH variable.
Once you have added all the directories that you want to the PATH variable, close PowerShell. The changes will take effect immediately, and you should be able to run commands and applications that rely on the PATH variable.
Conclusion
The PATH system variable is a crucial part of the Windows 10 operating system, and accidentally deleting or modifying it can cause issues with running applications and commands. However, there are multiple ways to restore the PATH system variable in Windows 10, including using the Environment Variables window, Registry Editor, Command Prompt, and PowerShell. By following the steps outlined in this blog post, you should be able to restore the PATH system variable and avoid any further issues.
The PATH system variable is used by Windows to specify the directories that should be searched when you enter a command in the command prompt. If the PATH system variable has been deleted, you can restore it by following these steps:
- Press the Windows key + R to open the “Run” dialog.
- Type “regedit” and press Enter to open the Registry Editor.
- In the Registry Editor, navigate to the following key:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment
- In the right pane, right-click and select “New > String Value”.
- Type “PATH” as the name of the new value and press Enter.
- Right-click on the “PATH” value and select “Modify”.
- In the “Edit String” dialog, enter the original value of the PATH system variable in the “Value data” field. You can find the original value by looking in the PATH system variable for other computers or by checking with your system administrator.
After you have restored the PATH system variable, you will need to close and reopen any command prompt windows for the changes to take effect.
Note: It is important to be careful when making changes to the Registry, as incorrect changes can cause serious problems. Make sure to back up the Registry or create a restore point before making any changes.
The following text is taken from a Win 10 Enterprise 64Bit system that I installed recently, and I have not installed any programs on it yet:
%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\
It appears to be the same as the Windows 8 one that you discovered.