0

I was writing a batch file that was supposed to automatically set up a computer to receive "psexec" remote commads. Unluckly i didn't really pay attention to what i was writing and i wrote this command and then ran It:

setx /M Path "C:\Windows\System32\PSTools"

You can imagine what happened... I erased all the other path variables! Then, panicking, mis-reading an online-forum, I restarted the computer. I had no backups, no saving points and neither, obviously, opened cmd's or powershell's session. My questions are:

  1. Is there still a way to recover the path variables i lost or they're gone forever?
  2. If they're gone, is there a way for me to like "re-write" them or just get a list of the missing ones?

I know that my questions will seem stupid to the experienced programmers and i apologise for that, but I actually started this project with almost zero skills in bat, cmd, and the other stuffs... Thanks to everyone that will help <3


Updated: Ok, i have found in "C:\" a folder called "Windows.old", is It possible that inside It are still stored the path variables? Inside this folder there are mostly the same folders and files as "C:\Windows" one and is full of ".mui" files, but if I do the "advanced start-up" the computer says there are no restore points. I guess that in C:\Windows.Old there are still the path variable I had before updating to Windows 10. They've remained the same sice then, I haven't downloaded any new software, how can I access to that old path variables??

2
  • since you have no backups ... and destroyed the previous values ... you will need to restore one of your restore points. they are likely somewhat old, tho, so that may not work for all your newer changes. ///// every time you run an install, most apps trigger creating a restore point. so you may be able to get that back.
    – Lee_Dailey
    Commented Mar 18, 2022 at 0:17
  • Default paths are stored somewhere within the install.wim|install.esd and it's a good bet they're listed somewhere on Microsoft Docs as well. Since I'm not certain where that information resides in either, the simplest way to do this is to have someone copy and paste their $PATH - I can do so first thing in the morning.
    – JW0914
    Commented Mar 18, 2022 at 2:40

2 Answers 2

2

System %PATH%:

  • Default:
    %SystemRoot%\system32\WBEM;C:\Windows\system32\WBEM;C:\Windows\system32;C:\Windows;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\PowerShell\7\;C:\Windows\System32\OpenSSH\;%UserProfile%\AppData\Local\Microsoft\WindowsApps
    
  • OEM Intel Drivers:
    C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\
    
  • Applications:
    # ADK (Windows 10):
      C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Deployment Tools;C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Deployment Tools\amd64\Oscdimg;C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment
    
    # Git:
      C:\Program Files\Git\cmd
    
    # Github Desktop:
      %UserProfile%\AppData\Local\GitHubDesktop\bin
    
    # Gpg4Win:
      C:\Program Files (x86)\Gpg4win\..\GnuPG\bin
    
    # OpenVPN:
      C:\Program Files\OpenVPN\bin
    
    # PuTTY:
      C:\Program Files\PuTTY\
    
    # smartmontools:
      C:\Program Files\smartmontools\bin
    
    # VS Code:
      %UserProfile%\AppData\Local\Programs\Microsoft VS Code\bin
    
    # WinSCP:
      C:\Program Files (x86)\WinSCP\
    

User %PATH%:

  • Default:
    %UserProfile%\AppData\Local\Microsoft\WindowsApps
    
  • OEM Intel Drivers:
    C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\
    
  • Applications:
    # Github Desktop:
      %UserProfile%\AppData\Local\GitHubDesktop\bin
    
    # smartmontools:
      C:\Program Files\smartmontools\bin
    
    # VS Code:
      %UserProfile%\AppData\Local\Programs\Microsoft VS Code\bin
    
2
  • Path to powershell?
    – Io-oI
    Commented Mar 18, 2022 at 15:07
  • @iTwasnTme Under System Default - Built-in: C:\Windows\System32\WindowsPowerShell\v1.0 | PowerShell 7: C:\Program Files\PowerShell\7
    – JW0914
    Commented Mar 18, 2022 at 16:56
0

Is there a way to recover the path variables I lost or are they gone forever?

If you have no system restore points, they are gone unless you recreate them.

If they're gone, is there a way for me to re-write them or just get a list of the missing ones?

You can re-write (edit) your Path variable manually. However, this assumes you know the correct paths in the first place. Individually reinstalling any software that writes to your Path variable is another option. Unfortunately, unless you have copied the paths in your Path variable at some point, there is no backup list of these variables that I am aware of. You'll likely have to just wait for a program or Windows to complain it can't find something and work from there.

That said, Windows 10 does have a number of "default" Path variables that should be present on any installation of Windows. These are presented in another question I answered. Manually re-creating these variables (assuming that they are missing) should help avoid basic issues like missing Windows console commands, issues with PowerShell or problems with Windows Apps. Note that the Windows Apps path is a User PATH (not System Path) variable.

4
  • Ok, i have found in "C:\" a folder called "Windows.old", is It possible that inside It are still stored the path variables? Inside this folder there are mostly the same folders and files as "Windows" one and is full of ".mui" files, but if I do the "advanced start-up" the computer says there are no restore points. What should I do?
    – Xcode
    Commented Mar 18, 2022 at 16:22
  • Windows.OLD is where Windows was previously installed before you upgraded to Windows 10. You cannot use the restore points from the old windows to restore the new windows. You may, however, inspect the registry hives from the old Windows to see what the system PATH was then. Commented Mar 18, 2022 at 17:25
  • @RossPresser How can i do that??? My paths had always been the same for years!!
    – Xcode
    Commented Mar 18, 2022 at 17:48

You must log in to answer this question.

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