Link to home
Avatar of Theo

asked on

Am I an Administrator or not

I want to edit my hosts-file (W10), but I am not allowed. When I check the perimissions of the file I have Full Control, but nevertheless I cannot save any changes. According to the User Accounts I am administrator but when I right click on the Command Prompt or the Power shell, to enter as an administrator, nothing happens.
Avatar of Michael B. Smith
Michael B. Smith
Flag of United States of America image

Blurred text
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Easy.  Right click on Notepad and select Run as Administrator. Navigate in Notepad to HOSTS. Edit and save. I do this whenever I have to edit HOSTS. Even if your are the Windows Admin, you still need to do this.
Avatar of Theo


@ John: When I do this it tells me thet tha directory Etc does not contain any search results., whereas the Hosts file ought to be in here.
Once you have opened Notepad with Run as Administrator, navigate to the folder, and then for File Type (in Notepad), select All Files.  HOSTS will show up.
Here you go.

User generated image
Hosts and other systems files are protected.  You must EXPLICITLY access them as an administrator... not just be logged in as one.  John has explained what to do and you can also run a command prompt as an admin and then navigate to c:\windows\system32\drivers\etc and then run notepad hosts to edit the file.
From Vista onwards we have the user access control technology to help secure our computer
Likewise in Linux if you are an administrator and you want to edit a protected item you would use
sudo command

In both cases an account that is an administrator will not be prompted for administrator credentials

When an administrator logs on, two separate access tokens are created for the user: a standard user access token and an administrator access token. The standard user access token contains the same user-specific information as the administrator access token, but the administrative Windows privileges and SIDs are removed. The standard user access token is used to start apps that do not perform administrative tasks (standard user apps). The standard user access token is then used to display the desktop (explorer.exe). Explorer.exe is the parent process from which all other user-initiated processes inherit their access token. As a result, all apps run as a standard user unless a user provides consent or credentials to approve an app to use a full administrative access token.
I struck this issue myself recently but found an easy workaround that I used.

  1. Right click on the Hosts file in File Explorer, copy and paste the existing hosts file to something like hosts.txt
  2. Edit the new hosts.txt file
  3. Rename the existing hosts file to something like hosts.bak (Windows allows me to rename for some reason, but not over write it)
  4. Save the edited hosts.txt file and rename to just hosts (no extension)
  5. Done

You'll get some UAC prompts to confirm the above rename operation, but it does work.

I hope that's helpful.

Regards, Andrew
could possibly do this as well :

$file = "$env:windir\System32\drivers\etc\hosts"
" bob" | Add-Content -PassThru $file
" john" | Add-Content -PassThru $file

Script isn't hard.  But, they'd have to set or bypass their script execution policy and run it as administrator.
Might be better off to give them an old fashion batch file to get around the execution policy, but they'd still have to run as.

Set file="%windir%\System32\drivers\etc\hosts"
echo bob >> %file%
echo john >>  %file%

Found on Spiceworks:

reference :
Easier just to use Notepad as Administrator. Nothing else to do.
Avatar of Theo


Gentlemen, thanks,
as it has been mentioned - you still need to do rights elevation, even if logged in as admin.

if you have a regular need to edit - you can do it the following way -
1) create a shortcut to that file (i created it on desktop, but i use it REALLY often. you may choose your favorite location).
2) rightclick the shortcut and in properties preceed the filename by "notepad" (no quotes), and apply changes.
3) in advanced properties for shortcut tick "run as administrator" checkbox.

now when you invoke this shortcut, it immediately asks for access rights elevation, and - voila - save works as a charm.
also, you may just want to save a general shortcut for notepad (or whatever favorite plain text editor you have) with that "run as Administrator" checkbox, to be asked for access rights elevation immediately .