tomchantler / edithosts Goto Github PK
View Code? Open in Web Editor NEWEasy way to add and remove Windows hosts file entries
License: MIT License
Easy way to add and remove Windows hosts file entries
License: MIT License
When using the add host it does not add it on a new line so if you already have a host file with other entries it will append the new host to the last one on the list which then makes Windows think its one long host name for the previous one.
Hey tom, thank you for your script(s).
I've been digging for a way to automate some of this and was pointed here. I'm entirely a layman and while I figured out how to get the script to add "a" entry (even with my preferred spacing!) I cannot figure out how to modify it to add multiple entries.
care to share an example with me of getting the script to add a second entry so i can modify it for my needs from that point? I can barely create a simple robocopy batch file so a powershell script like this is way way above and beyond!
(while im bothering you, same for the RemoveFromHosts just in case. I don't want to use up more of your time when i get to that point if its different)
It appears the script expects a fresh hosts file that is saved so that any addition will be on a brand new line. If the hosts file was previously edited and someone deleted the empty line it will append on the same line as the last entry. Example:
I'm not a powershell wizard but I'm guessing there might be a way to check if there is fresh CRLF before appending?
I had some PowerShell weirdness with the first line in any of the 3 scripts. The first line when copying the whole script was not hashed out (icon showing blue rather than green) which somehow stopped the parameters completely.
Once editing the first line to hash it out from fresh (icon then turning green) or deleting the first line completely (a reference to the author) the script seemed happy.
Not sure if I'm missing something obvious here but never seen this before and easy fix. Perhaps environmental to myself.
Nevertheless - thanks for the scripts!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.