If you are encountering the Cannot Edit Hosts File error and do not receive a prompt asking to allow “Windows Command Processor” to make changes to your device such as in the following image, before the error happens, here is a solution to try.
Check If Powershell PATH Variable Exists For User & Add It If Not
-
Press the windows key or click the start button and type env, then click “Edit the system environmental variables” or manually locate it in the Advanced System Settings.
-
In the window that pops up, click “Environmental Variables”
-
Select the PATH variable so it is highlighted, then click “Edit”
-
In the window that pops up, check the list of variables for "C:\WINDOWS\System32\WindowsPowerShell\v1.0" or "%SYSTEMROOT%\System32\WindowsPowerShell\v1.0"
-
If you do not have "C:\WINDOWS\System32\WindowsPowerShell\v1.0" in the path variables, click “New”. If you don’t have it but do have "%SYSTEMROOT%\System32\WindowsPowerShell\v1.0", you may still try this part to see if it solves the issue.
-
Write or paste "C:\WINDOWS\System32\WindowsPowerShell\v1.0" into the text box, the click okay on all the open windows. Restart your computer and then see if Local successfully edits the host file.
Note: The above process checks and adds the path variable for the listed user. If another user account tries to use local they may still have the issue. They can either also add the path, or it can be added to the path variable in the “System Variables” section. Admin privileges are required to add to the system path variable.