Hi, I don't even know if this is one problem or two. First, I tried to edit the 'hosts' file but wasn't let save the change as having no permission. I'm the only user and administrator. I took over ownership and gave full rights to myself, rebooted, still the same. Second, I tried to run notepad as administrator for the same reason. It wouldn't open. Then, I wanted to start it from an elevated command prompt, but cmd didn't start as admin either. This, like notepad, opened nicely as 'normal', neither as admin. I run Windows 8 Enterprise 64 bit. Thanks for any help.
Open Command Prompt in Admin mode ,type the following command and then press Enter. sfc /scannow let it do its thing, slight chance it may repair any corrupted values your OS may have.
Does the elevated CMD even refuse when started via Win+X? For the host file, i always copy to new location, edit it there and copy back .
\I would do the same using an external Win2Go drive, not using the running Windows, change the file and replace with the original. That would give me the freedom for even if that file is locked within Windows.
It's read-only file, you have to clear it first From elevated cmd: Code: SET hosts=%windir%\system32\drivers\etc\hosts attrib -r %hosts% notepad %hosts% attrib +r %hosts%
You can add a reference in your right click menu if you want with this. Save as a .reg and run. May need a reboot. Code: Windows Registry Editor Version 5.00 ;Take Ownership of any File or Directory [HKEY_CLASSES_ROOT\*\shell\runas] @="Take Ownership" "NoWorkingDirectory"="" [HKEY_CLASSES_ROOT\*\shell\runas\command] @="cmd.exe /c takeown /f \"%1\" && icacls \"%1\" /grant administrators:F" "IsolatedCommand"="cmd.exe /c takeown /f \"%1\" && icacls \"%1\" /grant administrators:F" [HKEY_CLASSES_ROOT\Directory\shell\runas] @="Take Ownership" "NoWorkingDirectory"="" [HKEY_CLASSES_ROOT\Directory\shell\runas\command] @="cmd.exe /c takeown /f \"%1\" /r /d y && icacls \"%1\" /grant administrators:F /t" "IsolatedCommand"="cmd.exe /c takeown /f \"%1\" /r /d y && icacls \"%1\" /grant administrators:F /t" ;add hosts file to right click [HKEY_CLASSES_ROOT\Directory\Background\shell\Edit HOSTS file] @="Edit HOSTS file" "HasLUAShield"="" ;"icon"="C:\Program Files\Internet Explorer\iexplore.exe" [HKEY_CLASSES_ROOT\Directory\Background\shell\Edit HOSTS file\command] @=hex(2):6e,00,6f,00,74,00,65,00,70,00,61,00,64,00,2e,00,65,00,78,00,65,00,20,\ 00,25,00,77,00,69,00,6e,00,64,00,69,00,72,00,25,00,5c,00,73,00,79,00,73,00,\ 74,00,65,00,6d,00,33,00,32,00,5c,00,64,00,72,00,69,00,76,00,65,00,72,00,73,\ 00,5c,00,65,00,74,00,63,00,5c,00,68,00,6f,00,73,00,74,00,73,00,00,00
The elevated command prompt wouldn't open from Win + X either. In all cases I see the whirling blue circle as the machine is working for a second, then nothing. The hosts file is not checked as read only. If I try to copy back an edited version, the paste option is grayed out. Neither me nor any program that I try to run can exercise administrator's rights. Maybe that's blocked somehow?
Or simply copy it to the desktop, edit and then put it back overwriting it. It's easier, faster, isn't it?
Never had a problem editing my host file- read only or not. I run CMD as admin and open notepad from inside it. Open host file, make changes and then save. @ Mister X, if read only is his problem, copying the file to the desktop will not nullify the read only file attribute.
You're right, I've checked the file and yes, again you are right. Sorry for the misleading info from me.
let me ask something about this too. few days ago i needed to take control of a file in Windows folder, tried the .reg trick but it didn't worked... ended up doing it manually. isn't there a way of doin't it automatically? i've tried many things, none worked, im on windows 8 btw.
If you open it by choosing to open with notepad or something, I'm not sure you can modify it. "Open With" does not open the program with admin permissions unless the program defaults to requiring admin permissions. Notepad definitely does NOT do that. Also, take ownership is neat, but you have to be careful how it is set up. The meat of a take ownership reg file is that it runs ICACLS to give permissions to administrator usually. If you don't open the editing program as administrator, how is it supposed to give you permission? What I suggest: Open admin notepad (winkey+r "notepad" ctrl-shift-enter) Opening with ctrl-shift-enter instead of regular enter will open it as admin. You still have to change the file so that it is not read-only. You can do that in file explorer. If it won't let you do it, copy it somewhere else, remove the read-only and copy it back and overwrite.
No need to grant admin's permissions! just move hosts to your desktop, then you can edit now !! When done, move to etc folder.