Win7: Change Host file from Dos window?

JEDI

Lifer
Sep 25, 2001
30,160
3,300
126
my host file has ad blockers but sometimes i need to temporarily disable it to get cashback from ordering from websites.

in WinXP, i had a simple .bat to rename the host file. then another simple .bat file to name it back.

but in Win7 it says Access is denied.

I am logged in as Admin.
i had to open Windows Explorer and click directories all the way down to get to the Host file in drivers/etc.

how can i make my .bat file work in Win7?
 

Nothinman

Elite Member
Sep 14, 2001
30,672
0
0
Use a better browser with an ad-block extension that can be easily toggled on and off?
 

hhhd1

Senior member
Apr 8, 2012
667
3
71
haven't tried it, but give is a go:

give "everyone" permission on the file to "full control"

Edit,

ofc, the file that needs the permission modified is the hosts file, and not the bat file.
 

Nothinman

Elite Member
Sep 14, 2001
30,672
0
0
haven't tried it, but give is a go:

give "everyone" permission on the file to "full control"

Edit,

ofc, the file that needs the permission modified is the hosts file, and not the bat file.

Since he's doing renames the object that needs permission is the parent directory, not the file itself.
 

theevilsharpie

Platinum Member
Nov 2, 2009
2,322
14
81
how can i make my .bat file work in Win7?

Right-click on it and run as Administrator. Alternatively, you should be able to set a compatibility flag in the .bat file's properties that will automatically request privilege elevation.

haven't tried it, but give is a go:

give "everyone" permission on the file to "full control"

Edit,

ofc, the file that needs the permission modified is the hosts file, and not the bat file.

Please don't do this.
 

cl-scott

ASUS Support
Jul 5, 2012
457
0
0
Use a better browser with an ad-block extension that can be easily toggled on and off?

I have to agree. The HOSTS file is kind of a poor man's DNS, and it's an extremely clumsy and ineffectual tool for blocking ads. On an Android device you can at least argue that it is very battery friendly, but on a computer capable of running Windows you don't even have that somewhat flimsy excuse.
 

cl-scott

ASUS Support
Jul 5, 2012
457
0
0
which broswer? chrome?

Firefox and Adblock Plus is the best solution from a technical standpoint. The Gecko rendering engine can literally be interrupted by extensions, so AdBlock Plus can literally prevent the browser from even downloading ads. The extension can also alter the layout of the page, to let you reclaim the space used by the ads. So they aren't just hidden, it's as if they never even existed.

Chrome has a version of AdBlock Plus, but it's rather neutered in comparison because extensions cannot interact with the rendering engine in the same way they can on Firefox. Generally the page is downloaded, rendered, and then filtered through the extension. So you might see the page with ads, then it flashes and reloads without the ads. Supposedly Google was very interested in having a version of NoScript for Chrome way back when, but so far Google hasn't really made any serious efforts to add the needed functionality. The same basic functionality needed for AdBlock Plus to work most efficiently.
 

Nothinman

Elite Member
Sep 14, 2001
30,672
0
0
which broswer? chrome?

I personally use Chrome with Ad-block simply because I like it better. But the issues that cl-scott mention are something you should consider. Where the FF extension will block the entire request to an ad, Chrome's Ad-block will download and remove it after the fact.