Skip to content

Instantly share code, notes, and snippets.

@flying-sausages
Last active January 27, 2021 15:38
Show Gist options
  • Save flying-sausages/36b300fdf0c93083c25b130014cf6cf4 to your computer and use it in GitHub Desktop.
Save flying-sausages/36b300fdf0c93083c25b130014cf6cf4 to your computer and use it in GitHub Desktop.
Resetting Powershell's path to defaults

Note: This was written on Windows 20H2, make sure things haven't changed since

Did you run some command from stack overflow that wiped your PATH? Did you assume the PATH variable on Windows works like it does on Linux? Are you getting ObjectNotFound with every command you run?

Fret not because so did I once upon a time and I learned from my mistakes. Better write them down before I forget

Steps

Try the following:

  1. Delete the entire registry ree under HKEY_CURRENT_USER\Console including the directory itself
  2. Reset your PATH in the System Environment variable tto the following values:
    %SystemRoot%\system32
    %SystemRoot%
    %SystemRoot%\System32\Wbem
    %SystemRoot%\System32\WindowsPowerShell\v1.0
    
  3. Reset your User's PATH in a pretty similar way
    %USERPROFILE%\AppData\Local\Microsoft\WindowsApps
    %USERPROFILE%\.dotnet\tools
    

After doing all this, you might have to log out of your user session, and log back in. Or maybe restart? 🤷

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment