An elegant way to open, edit and save the hosts file?

Whatever i tried, i couldn't even save the changes over at the Administrator account, "access denied". Does anyone here, by any chance, know a trick using a CACLS command or something similar, that is capable to enable me adding a few changes to that file? I tried running Wordpad in Admin mode, and of course setting the save to . and all, but WIndows didn't let me save that file

I'd rather avoid messing with the permissions in the properties, especially with system files, so i better ask you guys.

There are some tips in the internet, yes, but in this case it didn't work as described.

:thinking: :flushed_face:

  • Create a copy
  • Make your changes
  • Overwrite the original
1 Like

What @lxp said . Or I've found that running Notepad++ as Admin has let edit and save the hosts directly.

That doesn't work. Windows complains that the file is used by another process. Which doesn't surprise me.

That's exactly what i tried, but it didn't work. Thanks guys, i will investigate further. It's nothing urgent, but those smart MS guys surely knew, why they made it such a PITA to get this done.

I don't know, this has worked for me for years but sounds like it won't for you:

@admin
C:\Windows\System32\notepad.exe C:\Windows\System32\drivers\etc\hosts 

Windows 11 Pro 23H2

1 Like

No, that didn't work either. This hosts thing is utterly stupid, as is Microsoft. It doesn't offer any "no extension" option. Instead i get .txt, which is obviously wrong, but when i save it under *.* (the only other option), it saves a txt file anyway. I also tried Powertoys (and kicked it off my SSD, shortly after), but this is a "Powertoy" in the sense, that they expect us to hack in every single entry, plus host name, by hand. Well, i wanted to add a +300 files list to exclude all telemetry servers, so they can stick their Powertools Hosts Editor up, they know where.

And thanks. By the way, that was one of the first things i've tried, Set ADMIN=Toggle,10, but that also didn't let me save the changes.

Always look on the bright side: at least one of your security suites is doing its job well :slight_smile:

You mean Windows Defender and TinyWall? Because those are the only two i have installed here.

As the Chief Paranoid Officer, I expected you to run at least two suites like Kaspersky :smiley:

Give @Crash's solution another try, it doesn't get any better:

Sounds like TinyWall is blocking it. Check it's settings. You might have 2:

  • Prevent modification of the hosts file
  • Enable domain blocklist

You want both turned off if you want to manage the HOSTS file yourself. I guess.

Blurry screenshot found online:

Yes, you're right. I guess that was on by default. But in the meantime i was able to save the changes, in safe boot mode. But i'm still wondering, why ALL, literally all security settings for my files and folders are greyed out, even in safe mode. I have read a few fixes on the web, but they all seem to be very cumbersome and complicated. I have no idea, how i possibly could have messed up those settings, since i'm quite sure i never bothered to make changes there.

Otherwise my machine runs like a charm, no problems at all, except for that old glitch in the task bar, when it's centered, where some icons look plain and ugly (sometimes, so it's not even a reliable bug), until i close and re-open that software. Anyway, i have plans for a big upgrade of my computer, because i need a little bit more power for our music productions (16 Gigs of RAM are too little these days), and hopefully i will be able to change the security settings again. Thanks!

Thanks, CPO, you weren't off that much. Who would have suspected, that a tiny firewall setting could have such a giant impact. You always keep on learning. :smiley:

Doh! o)

What's the benefit of this TinyWall software?..
It's just another GUI for the regular windows firewall, right?

1 Like

Yes. But in 100 years i wouldn't know how to set up this utterly confusing Windows firewall, where a simple user like me could mess up tons of things in a very risky way. Therefore i'm thankful for this lightweight and easy to use tool.

:+1: :clinking_beer_mugs:

And i'd like to add, that it's not bothering me with too many alarms, pop-ups and warnings. It does its job in the least intrusive way, as opposed to the "big" firewall suites out there with their over-zealous behavior. Nevertheless it's reliable, whenever an executable has changed due to a version update, where it requires me to intervene, re-allowing the software, depending on the nature of the changes.

Sounds like it is too unobtrusive.

If security software makes an operation fail, like editing the hosts file, there might be a good reason for it but it should tell you that's what happened so you aren't left chasing your tail or thinking something else is broken.

Also because if it actually thinks software on the machine is trying to do something malicious, and is sure enough to break the action instead of allowing it, then it should be telling you it thinks your system is under attack, not silently making things fail and leaving you unaware.

1 Like

Just so you know, you can also use DO to manage firewall.. o)

These are just some context menus I added some years ago which run "netsh advfirewall firewall add/remove rule.." etc. Not much used these days, I stopped running "block all in- and outgoing" at some point, too much effort to keep it up, unfortunately. o)

The TinyWall software is probably just "locking" the file, not hooking into the file system in some way, so it does not even know about other tools trying to open that hosts file, so it also will not tell you? Just a guess.. The MS firewall popups are not the best, so I can see why you'd try with a different GUI on it.

I'm better off using TinyWall. I have no idea what's public or private, incoming or outgoing, et cetera. I will 100% mess up my system, if i would try to manage things only using the Windows firewall. I have no clues about networking. And since TinyWall is very lightweight, i don't see the point in experimenting.