A Windows XP help forum. PCbanter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » PCbanter forum » Windows 10 » Windows 10 Help Forum
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

What is the easiest way to edit the hosts file on Windows as admin?



 
 
Thread Tools Rate Thread Display Modes
  #16  
Old July 11th 17, 06:29 PM posted to alt.comp.os.windows-10
Lionel Muller
external usenet poster
 
Posts: 119
Default What is the easiest way to edit the hosts file on Windows as admin?

For alt.comp.os.windows-10 Mike Tomlinson wrote:


I put the hosts file on the desktop (Target:
E:\Windows\System32\drivers\etc\hosts)

Now I just right click on that icon and select "open with notepad."


A good tip. Thanks.


The goal is single click admin editing of the hosts file.
Only a Windows expert will know how to do this.

While I keep a perfectly clean desktop, I would put any links in the
cascaded menu, so that they work in a single click (although I prefer the
registry which is the simplest at
Start Run hosts return

I already have a shortcut adapted from the opening a command window as
administrator in my cascaded menu that works to edit the hosts file as
admin in a single click, but that menu shortcut also opens up a command
window which is an extra click to close.

In trying to understand your single-slick suggestion, you said you put the
"hosts" file on the desktop, and right clicked to edit it in Notepad, but I
think you missed a ton of steps because that doesn't edit the hosts file as
admin and put it back in without a txt extension.

You can force it to do that, but it's so many steps as to not qualify in
the least as a single-click menu solution.

But maybe I misunderstood what you were suggesting?
Can you clarify what I'm supposed to put in my menus that will open up the
hosts file as admin in a single click?
Ads
  #17  
Old July 11th 17, 06:36 PM posted to alt.comp.os.windows-10
Lionel Muller
external usenet poster
 
Posts: 119
Default What is the easiest way to edit the hosts file on Windows as admin?

For alt.comp.os.windows-10 Mayayana wrote:


A side note that might be of interest to people
who edit HOSTS:

http://mayakron.altervista.org/wikib...id=AcrylicHome


Thank you Mayayana for the Acrylic DNS suggestion which I already knew
about and which is a great way to reduce my hosts file from the 30,000
lines it currently is to probably down to only ten thousand lines or so.

I really should have made the OP more clear because almost all the answers
are off target, which is my fault.

So if I could start again, I'd say this isn't a question which has an
obvious answer since the goal is to get as close to a single-click admin
editing of the hosts file as possible.

Anyone can edit the hosts file in a series of clicks, but it takes an
expert to do it in one click.

That's why I'm asking the experts here for advice.

If the hosts file ended with "txt" it would be trivial.
If the hosts file didn't have to be edited as admin, it would be trivial.

But the fact is that Windows doesn't do anything automatic by default with
a file that has no extension other than to pop up a search for the editor,
which is a waste of steps for a file that I know what I want to edit it in.

Also, it has to be edited as admin.

It was my fault for not being clear that only a Windows expert could
possibly answer the question, as I already tried to do it in a single step:
Start Run hosts return

I can get that to easily work if I don't have to edit as admin and if the
hosts file had an extension, so what I'm trying to get is a single click
admin edit of the hosts file sans extension.

We solved a very similar problem with opening up a command window as admin
just a few weeks ago, so I tried the batch file method, but it failed.

What would you modify in this batch file (which opens a command window as
admin) to make it edit the hosts file instead?
===================
@ECHO OFF

REM Open a new shell "Run As Administrator"
REM Based on script by foxidrive on alt.msdos.batch

SETLOCAL ENABLEEXTENSIONS

IF NOT "%~1"=="" goto :START

SET MyFile=%TEMP%\Admin.vbs"
Echo Set UAC = CreateObject("Shell.Application") "%MyFile%"
Echo UAC.ShellExecute "%~f0", "%cd%", "", "runas", 1 "%MyFile%"
Start "" /MIN "%MyFile%"
goto :EOF

:START
Cmd /k "CD /D "%*" & Echo Administrator: & color 4F"\
===================
This didn't work but I really don't know what it's doing.
===================
@ECHO OFF
SET MyFile=C:\Windows\System32\Drivers\etc\hosts
Echo Set UAC = CreateObject("Shell.Application") "%MyFile%"
Echo UAC.ShellExecute "%~f0", "%cd%", "", "runas", 1 "%MyFile%"
Start "" /MIN "notepad.exe %MyFile%"
===================
  #18  
Old July 11th 17, 06:48 PM posted to alt.comp.os.windows-10
Lionel Muller
external usenet poster
 
Posts: 119
Default What is the easiest way to edit the hosts file on Windows as admin?

For alt.comp.os.windows-10 Good Guy wrote:


What is the quickest way to edit the hosts file on Windows as admin?


You won't know or understand it because it's rocket science. People
have tried it in the past but failed because they were all like you;
For simple things, you are always looking for difficult ways of doing
them!!.

I take it you are a German Jew? Lionel is a jewish name and Muller is
German.,


I'm adopted so I don't know what I am but I have freckles and red hair and
I sunburn easily, so I'm probably Celtic or maybe Kieven Russ.

Anyway, I knew that the question was a difficult question that only a
Windows expert could answer, since anyone can edit the hosts file, but
nobody in this thread has yet suggested a single-click method.

The closest to a single-click method is the "cmd -K" shortcut method that a
Windows expert proposed for opening a command window as admin a few weeks
ago, which worked, but it took two clicks, which is twice as many as what
we're trying to accomplish here.

Since editing the hosts file is done scores of times every day, saving
clicks is what the goal is, so I dutifully apologize that I didn't make it
clear in the OP that anything more than a click is already too much.

Hence it "is" rocket science, as the method that I have working is two
clicks, but I need to get it down to one click.

Likewise, the "App Paths" method, which works in one click for a *.txt file
that doesn't have to be edited as admin works fine:
Start Run hosts enter
But modifying the "App Paths" in the registry to open the hosts file
requires an expert because Windows is stupid when it comes to files sans
extension, coupled with the requirement to open the file as admin.

So, yes, it "is" rocket science to get a registry key that edits the hosts
file as admin, even though it's trivial to edit any other normal file that
way.

Similarly, the batch file method that works to open a command window as
admin doesn't work yet either, which takes someone who knows how to modify
the file below to edit the hosts file as admin instead:
===================
@ECHO OFF

REM Open a new shell "Run As Administrator"
REM Based on script by foxidrive on alt.msdos.batch

SETLOCAL ENABLEEXTENSIONS

IF NOT "%~1"=="" goto :START

SET MyFile=%TEMP%\Admin.vbs"
Echo Set UAC = CreateObject("Shell.Application") "%MyFile%"
Echo UAC.ShellExecute "%~f0", "%cd%", "", "runas", 1 "%MyFile%"
Start "" /MIN "%MyFile%"
goto :EOF

:START
Cmd /k "CD /D "%*" & Echo Administrator: & color 4F"\
===================

In summary, this is a question that only a Windows expert (what you call a
rocket scientist) can answer, which is how to edit the hosts file as admin
in a single click on Windows 10.

I have it down to two clicks - but I'm trying to make it a single click
since it's done a score of times every day.
  #19  
Old July 11th 17, 07:38 PM posted to alt.comp.os.windows-10
Char Jackson
external usenet poster
 
Posts: 10,449
Default What is the easiest way to edit the hosts file on Windows as admin?

On Tue, 11 Jul 2017 17:48:32 +0000 (UTC), Lionel Muller
wrote:

Since editing the hosts file is done scores of times every day, snip


I'm sure you realize that the number of people doing what you're doing
is tiny, tiny, tiny. :-)

I'd bet that most Windows users *never* edit their hosts file.

Anyway, back to the quest for the single click solution!

  #20  
Old July 11th 17, 08:11 PM posted to alt.comp.os.windows-10
Lionel Muller
external usenet poster
 
Posts: 119
Default What is the easiest way to edit the hosts file on Windows as admin?

For alt.comp.os.windows-10 jetjock wrote:


What is the quickest way to edit the hosts file on Windows as admin?


Right click on the Hosts file and open it with Wordpad or Notepad.
Edit the file and save. Can't be much simpler.


The number of steps to do that are horrendous, especially since the hosts
file is only editable by admin, it has no extension (which Notepad doesn't
understand when you save, and it's buried in the Windows hierarchy so
that's already far more clicks than the two-click solution that is already
working).

This batch file method might work though, but I have to modify it.
============= start batch file =============
@echo off
TITLE Modifying your HOSTS file
COLOR F0
ECHO.


:: BatchGotAdmin
:-------------------------------------
REM -- Check for permissions
nul 2&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"


REM -- If error flag set, we do not have admin.
if '%errorlevel%' NEQ '0' (
echo Requesting administrative privileges...
goto UACPrompt
) else ( goto gotAdmin )

:UACPrompt
echo Set UAC = CreateObject^("Shell.Application"^)
"%temp%\getadmin.vbs"
set params = %*:"="
echo UAC.ShellExecute "cmd.exe", "/c %~s0 %params%", "", "runas", 1
"%temp%\getadmin.vbs"

"%temp%\getadmin.vbs"
del "%temp%\getadmin.vbs"
exit /B

:gotAdmin
pushd "%CD%"
CD /D "%~dp0"
:--------------------------------------

:LOOP
SET Choice=
SET /P Choice="Do you want to modify HOSTS file ? (Y/N)"

IF NOT '%Choice%'=='' SET Choice=%Choice:~0,1%

ECHO.
IF /I '%Choice%'=='Y' GOTO ACCEPTED
IF /I '%Choice%'=='N' GOTO REJECTED
ECHO Please type Y (for Yes) or N (for No) to proceed!
ECHO.
GOTO Loop


:REJECTED
ECHO Your HOSTS file was left
unchanged%systemroot%\Temp\hostFileUpdate.log
ECHO Finished.
GOTO END


:ACCEPTED
setlocal enabledelayedexpansion
::Create your list of host domains
set LIST=(diqc.oca wiki.oca)
::Set the ip of the domains you set in the list above
set diqc.oca=192.168.111.6
set wiki.oca=192.168.111.4
:: deletes the parentheses from LIST
set _list=%LIST:~1,-1%
::ECHO %WINDIR%\System32\drivers\etc\hosts tmp.txt
for %%G in (%_list%) do (
set _name=%%G
set _value=!%%G!
SET NEWLINE=^& echo.
ECHO Carrying out requested modifications to your HOSTS file
::strip out this specific line and store in tmp file
type %WINDIR%\System32\drivers\etc\hosts | findstr /v !_name! tmp.txt
::re-add the line to it
ECHO %NEWLINE%^!_value! !_name!tmp.txt
:verwrite host file
copy /b/v/y tmp.txt %WINDIR%\System32\drivers\etc\hosts
del tmp.txt
)
ipconfig /flushdns
ECHO.
ECHO.
ECHO Finished, you may close this window now.
ECHO You should now open Chrome and go to "chrome://net-internals/#dns"
(without quotes)
ECHO then click the "clear host cache" button
GOTO END

:END
ECHO.
ping -n 11 192.0.2.2 nul
EXIT
============= end batch file =============
https://stackoverflow.com/questions/...d-host-entries
  #21  
Old July 11th 17, 08:11 PM posted to alt.comp.os.windows-10
Lionel Muller
external usenet poster
 
Posts: 119
Default What is the easiest way to edit the hosts file on Windows as admin?

For alt.comp.os.windows-10 Char Jackson wrote:


Since editing the hosts file is done scores of times every day, snip


I'm sure you realize that the number of people doing what you're doing
is tiny, tiny, tiny. :-)

I'd bet that most Windows users *never* edit their hosts file.

Anyway, back to the quest for the single click solution!


I already have the command-line-as-admin solution working, which is two
clicks, so I just need to figure out why the command line opens up when I
don't need it when the Target is set to:
C:\Windows\System32\cmd.exe /K "notepad C:\Windows\System32\Drivers\etc\hosts"

I'm also sure the batch file method will work also, which opens the hosts
file as admin in a single click when I get it to work.

The best solution, if I could get it to work, is
Start Run hosts enter
But the AppPaths key is hampered by the dual facts that the file has to be
opened as administrator and Windows10 became stupid because you can't set
the default editor for filenames that have no extensions.

As for editing the hosts file, if nobody did it, then the MVP Hosts file
and Acrylic DNS wouldn't have so many customers, so millions of people must
be doing it for all the reasons we already know.
  #22  
Old July 11th 17, 08:38 PM posted to alt.comp.os.windows-10
Ken Blake[_5_]
external usenet poster
 
Posts: 2,221
Default What is the easiest way to edit the hosts file on Windows as admin?

On Tue, 11 Jul 2017 13:38:29 -0500, Char Jackson
wrote:

On Tue, 11 Jul 2017 17:48:32 +0000 (UTC), Lionel Muller
wrote:

Since editing the hosts file is done scores of times every day, snip


I'm sure you realize that the number of people doing what you're doing
is tiny, tiny, tiny. :-)

I'd bet that most Windows users *never* edit their hosts file.



Right, by far!

But I'll go even farther: I'll bet that most Windows users have no
idea what the hosts file is.

And farther still: I'll bet that most Windows users have *never* even
heard of the hosts file.
  #23  
Old July 11th 17, 08:49 PM posted to alt.comp.os.windows-10
Lionel Muller
external usenet poster
 
Posts: 119
Default What is the easiest way to edit the hosts file on Windows as admin?

For alt.comp.os.windows-10 Ken Blake wrote:


I'd bet that most Windows users *never* edit their hosts file.



Right, by far!

But I'll go even farther: I'll bet that most Windows users have no
idea what the hosts file is.

And farther still: I'll bet that most Windows users have *never* even
heard of the hosts file.


I'm not going to argue that most users don't even know what a hosts file
is, but I would expect the Windows experts here to all know what a hosts
file is and there are millions of users for the MVP hosts file, and even
more millions who resort needlessly to ad blockers, and even more millions
who complain about ads and spying, so, it's obvious that a hosts file is an
important file to know how to edit for anyone trying to solve these
problems efficiency.

Anyway, I don't want to argue that since the problem remains whether or not
the millions of people who do understand what a hosts file is have an
answer to the question.

I just want to edit the hosts file in one click and I've just solved that,
but I'm still looking for better solutions.

To report back, I just solved the two-click problem by looking up the "cmd
/?" options, and simply changing the admin shortcut target from "cmd /K" to
"cmd /C" which reduces the steps in half to a single click.

This works as a one-click shortcut to edit the hosts file as admin:
Target =
C:\Windows\System32\cmd.exe /C "notepad C:\Windows\System32\Drivers\etc\hosts"
[x]Open as Administrator

So now I just need to figure out how to run that shortcut from:
Start Run that-shortcut
  #24  
Old July 11th 17, 08:53 PM posted to alt.comp.os.windows-10
Good Guy[_2_]
external usenet poster
 
Posts: 3,354
Default What is the easiest way to edit the hosts file on Windows asadmin?

On 11/07/2017 18:48, Lionel Muller wrote:

Since editing the hosts file is done scores of times every day,


Only if you are trying to cover your tracks. For example, Key Generator
creators like to block anything they think is spying on them. So tell
us are you selling drugs or arms or whatever? Are you sponsoring
terrorists who are stupid enough to blow themselves up to reach Allah?

Frankly, you should be using the darkweb where only you can identify
yourself to your peers and still remain anonymous.

Editing hosts file "scores of time" everyday is the work of an idiot who
has nothing better to do in life.




--
With over 500 million devices now running Windows 10, customer
satisfaction is higher than any previous version of windows.

  #25  
Old July 11th 17, 08:56 PM posted to alt.comp.os.windows-10
Good Guy[_2_]
external usenet poster
 
Posts: 3,354
Default What is the easiest way to edit the hosts file on Windows asadmin?

On 11/07/2017 19:56, jetjock wrote:
Right click on the Hosts file and open it with Wordpad or Notepad.
Edit the file and save. Can't be much simpler.


Ah but there is no fun in doing that!! is it? Some people like to do
the hard way. I say some people because I bet you don't edit your hosts
file "scores of time" in a day!!! Not even in 6 months!!

--
With over 500 million devices now running Windows 10, customer
satisfaction is higher than any previous version of windows.

  #26  
Old July 11th 17, 09:07 PM posted to alt.comp.os.windows-10
Good Guy[_2_]
external usenet poster
 
Posts: 3,354
Default What is the easiest way to edit the hosts file on Windows asadmin?

On 11/07/2017 20:11, Lionel Muller wrote:


As for editing the hosts file, if nobody did it, then the MVP Hosts file
and Acrylic DNS wouldn't have so many customers, so millions of people
must
be doing it for all the reasons we already know.



Don't be fooled by the numbers on MVP Hosts file. It has been around
since 2001 and the numbers are for the past 17 years. You need to
average it out. In any case people download all sorts of things from
the web to see what the hell it is all about but after 30 minutes they
come to the conclusion that it is all rubbish!!. What do you block
scores of time in a day? Why not learn to use your firewall settings
effectively?

The only time I edit a host file is when I want to create a domain name
such as: example.com on my machine so that I can edit the webpages, and
test them before uploading. I have apache running on my machine and
also Microsoft IIS so that I can create php/mysql scripts and/or
ASP/C-sharp MVC webpages on visual studio. I have never had to change
anything for a very long time now as everything is setup as I wanted it
to be.





--
With over 500 million devices now running Windows 10, customer
satisfaction is higher than any previous version of windows.

  #27  
Old July 11th 17, 09:41 PM posted to alt.comp.os.windows-10
Lionel Muller
external usenet poster
 
Posts: 119
Default What is the easiest way to edit the hosts file on Windows as admin?

For alt.comp.os.windows-10 Good Guy wrote:


Right click on the Hosts file and open it with Wordpad or Notepad.
Edit the file and save. Can't be much simpler.


Ah but there is no fun in doing that!! is it? Some people like to do
the hard way. I say some people because I bet you don't edit your hosts
file "scores of time" in a day!!! Not even in 6 months!!


I solved the problem, so now we can edit any file as admin that has no
filename extension in a single click, using two different methods.

This was always a question for Windows experts, where only an expert would
understand the question and the solution.
  #28  
Old July 11th 17, 09:41 PM posted to alt.comp.os.windows-10
Lionel Muller
external usenet poster
 
Posts: 119
Default What is the easiest way to edit the hosts file on Windows as admin?

For alt.comp.os.windows-10 Good Guy wrote:


Since editing the hosts file is done scores of times every day,


Only if you are trying to cover your tracks. For example, Key Generator
creators like to block anything they think is spying on them. So tell
us are you selling drugs or arms or whatever?


Yes. I am selling drugs and arms. In fact, I just got a shipment of arms,
cut off at the elbow, that you may be interested in buying. They're much
better quality than those that I sold you last week that had the hands
removed.

Are you sponsoring terrorists who are stupid enough to blow themselves
up to reach Allah?


Yes. Of course I am. How did you know? You are astute.
I'm actually on a crusade to get all terrorists to use the windows hosts
file so that they don't get all those annoying ads for faux black market
weapons.

Frankly, you should be using the darkweb where only you can identify
yourself to your peers and still remain anonymous.


Some day I'll learn what exactly the dark web is.
At this point, I have never had a need for it.

Editing hosts file "scores of time" everyday is the work of an idiot who
has nothing better to do in life.


That's like saying washing your hands every time you go to the bathroom is
the "work of an idiot who has nothing better to do in life".

Anyway, there are good reasons to edit a hosts file but if you don't
subscribe to them, I'm not the guy here to tell you otherwise.
http://winhelp2002.mvps.org/hosts.htm

If you want to use ad blockers unique to each browser and OS, who am I to
try to dissuade you from all that fun.

Anyway, I solved the problem, which really was just a Windows expert
problem of how to edit a file as admin that had no filename extension in a
single click.

I solved it two ways, which I will write up so that those who care about
the Windows problem, and if they're Windows experts, they'll be able to do
it for themselves if they wish.

I give back to the group!
  #29  
Old July 11th 17, 09:41 PM posted to alt.comp.os.windows-10
Lionel Muller
external usenet poster
 
Posts: 119
Default What is the easiest way to edit the hosts file on Windows as admin?

For alt.comp.os.windows-10 Good Guy wrote:


Don't be fooled by the numbers on MVP Hosts file. It has been around
since 2001 and the numbers are for the past 17 years. You need to
average it out. In any case people download all sorts of things from
the web to see what the hell it is all about but after 30 minutes they
come to the conclusion that it is all rubbish!!. What do you block
scores of time in a day? Why not learn to use your firewall settings
effectively?


I am not fooled by the numbers.
There is good logic in using the same hosts file on all your devices in
your household.
http://winhelp2002.mvps.org/hosts.htm
http://www.techexams.net/blogs/jdmur...hosts-file.htm

In fact, I have been editing my hosts file for so long that I can't even
tell you reliably how many years it has been. I combine all the available
files and then I sort unique, which gets me about 50,000 lines. Then I
manually add lines as needed to the master hosts file on one computer,
whether Linux or Windows, and periodically I merge the individual machine
edits and re-populate all machines (Windows, Linux, and Android) with the
same hosts file for the entire household.

I just laugh when I hear people suggesting ad blockers for example, since I
have no need for ad blockers that only work for one browser or for one
operating system. I use the same hosts file on all operating systems (I
have trouble with iOS because it's not rooted though).

The only time I edit a host file is when I want to create a domain name
such as: example.com on my machine so that I can edit the webpages, and
test them before uploading. I have apache running on my machine and
also Microsoft IIS so that I can create php/mysql scripts and/or
ASP/C-sharp MVC webpages on visual studio. I have never had to change
anything for a very long time now as everything is setup as I wanted it
to be.


Every time I run into an obnoxious ad or web site, I add it to the hosts
file. Periodically, I cull the major reliable hosts files on the net and
run through a sort unique so that I can add all the new research.
http://winhelp2002.mvps.org/hosts.txt
http://someonewhocares.org/hosts/
https://github.com/StevenBlack/hosts
etc
Periodically I synchronize all the hosts files on my Linux, Windows, and
Android devices.

Anyway, I solved the problem in two ways.
I'm writing it up for everyone else to benefit from.
  #30  
Old July 11th 17, 11:27 PM posted to alt.comp.os.windows-10
Char Jackson
external usenet poster
 
Posts: 10,449
Default What is the easiest way to edit the hosts file on Windows as admin?

On Tue, 11 Jul 2017 19:11:18 +0000 (UTC), Lionel Muller
wrote:

For alt.comp.os.windows-10 Char Jackson wrote:


Since editing the hosts file is done scores of times every day, snip


I'm sure you realize that the number of people doing what you're doing
is tiny, tiny, tiny. :-)

I'd bet that most Windows users *never* edit their hosts file.

Anyway, back to the quest for the single click solution!


I already have the command-line-as-admin solution working, which is two
clicks, so I just need to figure out why the command line opens up when I
don't need it when the Target is set to:
C:\Windows\System32\cmd.exe /K "notepad C:\Windows\System32\Drivers\etc\hosts"

I'm also sure the batch file method will work also, which opens the hosts
file as admin in a single click when I get it to work.

The best solution, if I could get it to work, is
Start Run hosts enter
But the AppPaths key is hampered by the dual facts that the file has to be
opened as administrator and Windows10 became stupid because you can't set
the default editor for filenames that have no extensions.

As for editing the hosts file, if nobody did it, then the MVP Hosts file
and Acrylic DNS wouldn't have so many customers, so millions of people must
be doing it for all the reasons we already know.


Neither of those things, MVP Hosts file or Acrylic DNS, mean that people
are editing their hosts file scores of times per day. Quite the
opposite, I'd guess.

Can you give me some idea of the types of changes you're making? I may
be missing something important on my own systems.

 




Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off






All times are GMT +1. The time now is 06:54 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 PCbanter.
The comments are property of their posters.