Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > microsoft.public.scripting.vbscript > #11709
| From | "Mayayana" <mayayana@invalid.nospam> |
|---|---|
| Newsgroups | alt.comp.os.windows-10, microsoft.public.scripting.vbscript |
| Subject | Re: What is the easiest way to edit the hosts file on Windows as admin? |
| Date | 2017-07-12 08:14 -0400 |
| Organization | A noiseless patient Spider |
| Message-ID | <ok53jf$cj6$1@dont-email.me> (permalink) |
| References | <ok1sqo$1llk$1@gioia.aioe.org> <ok2kei$4d1$1@dont-email.me> <ok32a4$1jva$1@gioia.aioe.org> <ok3jun$jii$1@dont-email.me> <XnsA7B062F1ABD5auricauricauricauric@213.239.209.88> |
Cross-posted to 2 groups.
** Posted in VBS group from a HOSTS file discussion in Win10 group. ** "Auric__" <not.my.real@email.address> wrote | Mayayana wrote: | | > I have a VBS file I keep on my Desktop. When I | > visit a page that I think may have new muck I | > download the webpage, drop it on the script, which | > then parses the page for URLs and shows me a | > list. I can select any on the list to be added to | > both HOSTS files, cancel, and/or add other URLs. | | Would you be willing to post that script over in | microsoft.public.scripting.vbscript ? | http://www.jsware.net/jsware/browsertips.php5#host The download there (hosts.zip) is a package designed to provide a basic primer about HOSTS files for people concerned about privacy. There are two versions, one for IE and one for other browsers. The "iebut" subfolder has scripts and icons. I wrote this some time ago. I don't know which version of IE breaks it. Probably 11, which breaks IE-specific functions. But I don't really know. It also predates IE tabs, assuming there's just one actual browser window of the IE variety running. The IE package takes advantage of the ability to add a custom button to the IE toolbar that then links to a script. When you click the button, the script uses Shell.Application to get the collection of Explorer/IE windows, finds an IE instance, gets the document content, and parses that. So it's a one-click approach. If you wanted to use that I guess you might need to edit the code to step down into the browser window collection. I don't remember exactly how it works now. I think the actual IE browser windows are embedded inside windows of class IEFrame or some such. And I don't know how the ShellApp.Windows collection deals with that. But I suppose very few people care about HOSTS and also use IE these days, anyway. The CollectURLs script is for use with other browsers, or any webpage. Use File -> SaveAs to get the webpage. Drop the HTML file onto the script. It gets parsed to find URLs. It's not perfect and could probably be improved. The code just looks for ".com", ".net", etc. Many pages now are mostly obfuscated javascript and sleazy URLs are often obfuscated, assembled by script rather than written in the page HTML. The script won't catch those. It can still be handy, though; a lot easier than trying to read the source code. After parsing the page content it pops up a window with a list of URLs found. The list can be edited, aded to, or even just used to add a new URL instead of editing HOSTS by hand. I added Acrylic HOSTS to my version. For anyone with experience scripting that would be easy to do. Around line 160-ish the script adds the new URLs to HOSTS. The same code can be repeated to do the same for Acrylic HOSTS. A final caveat: As has been touched on in this thread, later versions of Windows can be a pain in the neck with file restrictions. If you don't turn off UAC you can't drop files onto VBS because there's no way to elevate. Also, many AV programs now monitor HOSTS and may complain or block editing. Maybe something like Lionel's approach of clearing restrictions via BAT file first would work. I've never tried that.
Back to microsoft.public.scripting.vbscript | Previous | Next — Next in thread | Find similar | Unroll thread
Re: What is the easiest way to edit the hosts file on Windows as admin? "Mayayana" <mayayana@invalid.nospam> - 2017-07-12 08:14 -0400
Re: What is the easiest way to edit the hosts file on Windows as admin? Lionel Muller <Erhohterlowe@neomailbox.com> - 2017-07-12 12:31 +0000
Re: What is the easiest way to edit the hosts file on Windows as admin? "Dave \"Crash\" Dummy" <invalid@invalid.invalid> - 2017-07-12 10:55 -0400
Re: What is the easiest way to edit the hosts file on Windows as admin? Sam Hill <sam@example.com> - 2017-07-12 15:25 +0000
Re: What is the easiest way to edit the hosts file on Windows as admin? "Dave \"Crash\" Dummy" <invalid@invalid.invalid> - 2017-07-12 18:41 -0400
Re: What is the easiest way to edit the hosts file on Windows as admin? "Mayayana" <mayayana@invalid.nospam> - 2017-07-12 13:01 -0400
Re: What is the easiest way to edit the hosts file on Windows as admin? "Dave \"Crash\" Dummy" <invalid@invalid.invalid> - 2017-07-12 18:46 -0400
Re: What is the easiest way to edit the hosts file on Windows as admin? Lionel Muller <Erhohterlowe@neomailbox.com> - 2017-07-12 17:46 +0000
csiph-web