Search code examples
windowspowershelladministrator

Can't open PowerShell with administrative rights


I'm running Windows 10 and a few weeks ago I managed to do something (in the middle of the night - can't remember) such that I can't open PowerShell (nor PowerShell ISE) with administrative rights anymore. When opening it via right-click -> as admin, the Shell opens and closes immediately. Opening without administrative rights works fine.

I managed to find the error through opening a cmd as admin and typing the command "PowerShell". It says (translated):

"The type initializer for "System.Management.Automation.Runspaces.LocalRunspace" caused an exception"

Google seems not to come up with similar cases. Any suggestions?


Solution

  • I solved it. The problem was, that I had changed the registry entries in "\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion" to "%ProgramFiles%" a while ago, in an attempt to change the default location of new programs to whichever path I defined in the environment variable. Now I hardcoded it to my new desired location (on D:). I can open the PowerShell as admin again.