Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > alt.comp.os.windows-10 > #47805

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

From Lionel Muller <Erhohterlowe@neomailbox.com>
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 17:46 +0000
Organization Aioe.org NNTP Server
Message-ID <ok5n98$16dt$1@gioia.aioe.org> (permalink)
References (2 earlier) <ok32a4$1jva$1@gioia.aioe.org> <ok3jun$jii$1@dont-email.me> <XnsA7B062F1ABD5auricauricauricauric@213.239.209.88> <ok53jf$cj6$1@dont-email.me> <ok5d24$8tt$1@dont-email.me>

Cross-posted to 2 groups.

Show all headers | View raw


For alt.comp.os.windows-10,microsoft.public.scripting.vbscript Dave "Crash"
Dummy wrote:


> What is the name of the Win10 group? My search of Usenet group names for
> "win10" comes up empty. I can use all the help I can get with Windows 10!

Just for archival purposes, here's the summary of how we enabled, on
Windows 10, editing of the hosts file as administrator in a single step.

I was unable to solve the problem with a batch file because I don't know
anything about batch file sysntax, so a sample was supplied in the original
thread and is appended below.

Here is the original summary solution message.........

SOLVED!
To give back to the newsgroup...
****************************************************************************
Below are two tested ways to admin edit the hosts file in a single click!
****************************************************************************
The goal was single click admin edits using native Windows methods only.
For expert Windows users (who wish to streamline their every action).

1. Optionally download any of the well known HOSTS file on the net:
   http://winhelp2002.mvps.org/hosts.txt
   http://someonewhocares.org/hosts/
   https://github.com/StevenBlack/hosts
   etc.

   Note: Always aiming to improve efficiency, I use the same hosts file 
   on all my devices, whether they are Android, Linux, or Windows, 
   which works for all browsers and for all modern consumer 
   operating systems.

   As such, the steps I use to combine the files above, sorted unique, 
   and to incorporate my manual additions, are not part of this tutorial.

2. Create an administrator "hosts.lnk" shortcut for your start menu:
   Rightclick in any folder (e.g., the Desktop) > New > Shortcut
   Type a location of "cmd" (or "cmd.exe") sans quotes
   Click Next 
   Type an optional "name" (e.g., "Admin edit hosts")
   Click Finish

3. Set that new shortcut to edit the hosts file as admin:
   Rightclick the new Shortcut > Properties 
   Change the Shortcut Target from:
    C:\Windows\System32\cmd.exe
   Change the Shortcut Target to:
C:\Windows\System32\cmd.exe /C "notepad
C:\Windows\System32\Drivers\etc\hosts"
   NOTE: The "/C" tells the command window to die when you're done.
   Note: I'm normalizing to Notepad for others as I use a different editor.

4. Set optional items in the new shortcut:
   Optionally change the "Start in" directory from:
    C:\WINDOWS\system32
   Optionally change the "Start in" directory to:
    C:\WINDOWS\system32\Drivers\etc\
   
   Optionally add a comment line of:
    The "/C" closes the command window.

5. You must set the shortcut to open as Administrator:
   Press the Advanced button
   Check [x]Run as Administrator
   Press OK
 
   That successfully creates a shortcut you can put in your 
   cascaded start menu which, when clicked,  will edit the
   hosts file as administrator using your editor of choice.

6. Put the shortcut in a location that you confirm with the command line:
   C:\Users\me\AppData\Roaming\Microsoft\Windows\Start
Menu\Programs\hosts.lnk

   Note: I'm normalizing to the Classic Start Menu path as I use a 
         different path (but I tested this path for you and it works).

7. Now create the command "Start > Run > hosts"
   Add the following "App Paths" New Key.
   HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\
   hosts.exe (it must end with exe but it can be anything else)
   (Default) = 
   C:\Users\me\AppData\Roaming\Microsoft\Windows\Start
Menu\Programs\hosts.lnk

8. Distribute the hosts file to all your Windows, Linux, Android, and
   iOS devices. 

   Note: I haven't jailbroken my iOS devices, so I only distribute to all
   the Windows, Linux, and Android devices on my network.

9. Test:
   Start > Run > hosts <enter> (this should edit the hosts as admin)
   Start > Run > menu > hosts  (this should edit the hosts as admin)

Voila!
That's two ways to admin edit the hosts file in a single click!
https://www.bestvpn.com/use-your-hosts-file-to-block-ads-and-malware/
============================================================================
If you're a Windows expert, you already know why you'd want this.
And you'd already know about Acrylic DNS (if you want to go that route).

If you're not a Windows expert, read these two explanations please.
http://winhelp2002.mvps.org/hosts.htm
===========================================================================
See also:
Zeezicht:
 Try HOSTSMAN ==>  http://www.abelhadigital.com/hostsman
 It has a very userfriendly "editor" onboard + other features ...
Mayayana:
 http://mayakron.altervista.org/wikibase/show.php?id=AcrylicHome
 Acrylic DNS proxy allows wildcard edits to its hosts file.
===========================================================================
For whatever reason, the batch file method failed.
Here is the batch file that works for opening a command prompt as admin.
===================
@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"\
===================
I wasn't able to modify that batch file to edit the hosts file as admin.
===================
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%"
===================

Back to alt.comp.os.windows-10 | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

What is the easiest way to edit the hosts file on Windows as admin? Lionel Muller <Erhohterlowe@neomailbox.com> - 2017-07-11 06:56 +0000
  Re: What is the easiest way to edit the hosts file on Windows as admin? Lionel Muller <Erhohterlowe@neomailbox.com> - 2017-07-11 07:07 +0000
  Re: What is the easiest way to edit the hosts file on Windows as admin? "Auric__" <not.my.real@email.address> - 2017-07-11 07:33 +0000
  Re: What is the easiest way to edit the hosts file on Windows as admin? Lucifer Morningstar <not@for.mail> - 2017-07-11 17:44 +1000
    Re: What is the easiest way to edit the hosts file on Windows as admin? Lionel Muller <Erhohterlowe@neomailbox.com> - 2017-07-11 17:19 +0000
  Re: What is the easiest way to edit the hosts file on Windows as admin? Zeezicht <zeezicht_adelin.remove@telenet.remove.be> - 2017-07-11 11:23 +0200
    Re: What is the easiest way to edit the hosts file on Windows as admin? Lionel Muller <Erhohterlowe@neomailbox.com> - 2017-07-11 17:19 +0000
  Re: What is the easiest way to edit the hosts file on Windows as admin? "s|b" <me@privacy.invalid> - 2017-07-11 13:49 +0200
    Re: What is the easiest way to edit the hosts file on Windows as admin? Lionel Muller <Erhohterlowe@neomailbox.com> - 2017-07-11 17:19 +0000
  Re: What is the easiest way to edit the hosts file on Windows as admin? slate_leeper <bycy-r0bj@spamex.com> - 2017-07-11 09:15 -0400
    Re: What is the easiest way to edit the hosts file on Windows as admin? Mike Tomlinson <mike@jasper.org.uk> - 2017-07-11 16:33 +0100
      Re: What is the easiest way to edit the hosts file on Windows as admin? Lionel Muller <Erhohterlowe@neomailbox.com> - 2017-07-11 17:29 +0000
  Re: What is the easiest way to edit the hosts file on Windows as admin? "Mayayana" <mayayana@invalid.nospam> - 2017-07-11 09:43 -0400
    Re: What is the easiest way to edit the hosts file on Windows as admin? Lionel Muller <Erhohterlowe@neomailbox.com> - 2017-07-11 17:36 +0000
      Re: What is the easiest way to edit the hosts file on Windows as admin? "Mayayana" <mayayana@invalid.nospam> - 2017-07-11 18:40 -0400
        Re: What is the easiest way to edit the hosts file on Windows as admin? Lionel Muller <Erhohterlowe@neomailbox.com> - 2017-07-11 23:48 +0000
          Re: What is the easiest way to edit the hosts file on Windows as admin? Char Jackson <none@none.invalid> - 2017-07-12 00:00 -0500
            Re: What is the easiest way to edit the hosts file on Windows as admin? Lionel Muller <Erhohterlowe@neomailbox.com> - 2017-07-12 11:49 +0000
        Re: What is the easiest way to edit the hosts file on Windows as admin? "Auric__" <not.my.real@email.address> - 2017-07-12 07:32 +0000
          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
  Re: What is the easiest way to edit the hosts file on Windows as admin? Big Al <BigAl@invalid.com> - 2017-07-11 10:37 -0400
    Re: What is the easiest way to edit the hosts file on Windows as admin? Lionel Muller <Erhohterlowe@neomailbox.com> - 2017-07-11 17:19 +0000
  Re: What is the easiest way to edit the hosts file on Windows as admin? Lionel Muller <Erhohterlowe@neomailbox.com> - 2017-07-11 17:48 +0000
    Re: What is the easiest way to edit the hosts file on Windows as admin? Char Jackson <none@none.invalid> - 2017-07-11 13:38 -0500
      Re: What is the easiest way to edit the hosts file on Windows as admin? Lionel Muller <Erhohterlowe@neomailbox.com> - 2017-07-11 19:11 +0000
        Re: What is the easiest way to edit the hosts file on Windows as admin? Lionel Muller <Erhohterlowe@neomailbox.com> - 2017-07-11 20:41 +0000
          Re: What is the easiest way to edit the hosts file on Windows as admin? Char Jackson <none@none.invalid> - 2017-07-11 17:34 -0500
            Re: What is the easiest way to edit the hosts file on Windows as admin? Lionel Muller <Erhohterlowe@neomailbox.com> - 2017-07-11 23:48 +0000
              Re: What is the easiest way to edit the hosts file on Windows as admin? Lionel Muller <Erhohterlowe@neomailbox.com> - 2017-07-11 23:53 +0000
              Re: What is the easiest way to edit the hosts file on Windows as admin? Char Jackson <none@none.invalid> - 2017-07-11 23:58 -0500
                Re: What is the easiest way to edit the hosts file on Windows as admin? Lionel Muller <Erhohterlowe@neomailbox.com> - 2017-07-12 11:49 +0000
                Re: What is the easiest way to edit the hosts file on Windows as admin? Lionel Muller <Erhohterlowe@neomailbox.com> - 2017-07-12 11:58 +0000
                Re: What is the easiest way to edit the hosts file on Windows as admin? Char Jackson <none@none.invalid> - 2017-07-12 13:37 -0500
                Re: What is the easiest way to edit the hosts file on Windows as admin? Lionel Muller <Erhohterlowe@neomailbox.com> - 2017-07-12 19:00 +0000
            Re: What is the easiest way to edit the hosts file on Windows as admin? Lionel Muller <Erhohterlowe@neomailbox.com> - 2017-07-13 22:34 -0700
              Re: What is the easiest way to edit the hosts file on Windows as admin? Paul <nospam@needed.invalid> - 2017-07-14 02:10 -0400
                Re: What is the easiest way to edit the hosts file on Windows as admin? Lionel Muller <Erhohterlowe@neomailbox.com> - 2017-07-14 07:43 -0700
                Re: What is the easiest way to edit the hosts file on Windows as admin? Lionel Muller <Erhohterlowe@neomailbox.com> - 2017-07-14 12:12 -0700
          Re: What is the easiest way to edit the hosts file on Windows as admin? "Mayayana" <mayayana@invalid.nospam> - 2017-07-11 20:51 -0400
            Re: What is the easiest way to edit the hosts file on Windows as admin? Lionel Muller <Erhohterlowe@neomailbox.com> - 2017-07-12 11:49 +0000
        Re: What is the easiest way to edit the hosts file on Windows as admin? Char Jackson <none@none.invalid> - 2017-07-11 17:27 -0500
          Re: What is the easiest way to edit the hosts file on Windows as admin? Lionel Muller <Erhohterlowe@neomailbox.com> - 2017-07-11 23:48 +0000
            Re: What is the easiest way to edit the hosts file on Windows as admin? Char Jackson <none@none.invalid> - 2017-07-11 23:52 -0500
              Re: What is the easiest way to edit the hosts file on Windows as admin? Lionel Muller <Erhohterlowe@neomailbox.com> - 2017-07-12 11:49 +0000
                Re: What is the easiest way to edit the hosts file on Windows as admin? Lionel Muller <Erhohterlowe@neomailbox.com> - 2017-07-12 12:02 +0000
              Re: What is the easiest way to edit the hosts file on Windows as admin? "Mayayana" <mayayana@invalid.nospam> - 2017-07-12 09:15 -0400
                Re: What is the easiest way to edit the hosts file on Windows as admin? Lionel Muller <Erhohterlowe@neomailbox.com> - 2017-07-12 13:26 +0000
                Re: What is the easiest way to edit the hosts file on Windows as admin? Lionel Muller <Erhohterlowe@neomailbox.com> - 2017-07-12 17:54 +0000
                Re: What is the easiest way to edit the hosts file on Windows as admin? Lionel Muller <Erhohterlowe@neomailbox.com> - 2017-07-12 23:48 +0200
                Re: What is the easiest way to edit the hosts file on Windows as admin? Lionel Muller <Erhohterlowe@neomailbox.com> - 2017-07-12 21:54 +0000
                Re: What is the easiest way to edit the hosts file on Windows as admin? Lionel Muller <Erhohterlowe@neomailbox.com> - 2017-07-12 23:10 +0100
      Re: What is the easiest way to edit the hosts file on Windows as admin? Ken Blake <Ken@invalid.news.com> - 2017-07-11 12:38 -0700
        Re: What is the easiest way to edit the hosts file on Windows as admin? Lionel Muller <Erhohterlowe@neomailbox.com> - 2017-07-11 19:49 +0000
        Re: What is the easiest way to edit the hosts file on Windows as admin? Char Jackson <none@none.invalid> - 2017-07-11 17:40 -0500
          Re: What is the easiest way to edit the hosts file on Windows as admin? Lionel Muller <Erhohterlowe@neomailbox.com> - 2017-07-11 23:48 +0000
            Re: What is the easiest way to edit the hosts file on Windows as admin? Char Jackson <none@none.invalid> - 2017-07-11 23:01 -0500
              Re: What is the easiest way to edit the hosts file on Windows as admin? Lionel Muller <Erhohterlowe@neomailbox.com> - 2017-07-12 11:49 +0000
    Re: What is the easiest way to edit the hosts file on Windows as admin? Lionel Muller <Erhohterlowe@neomailbox.com> - 2017-07-11 20:41 +0000
  Re: What is the easiest way to edit the hosts file on Windows as admin? jetjock <jetjock@example.com> - 2017-07-11 13:56 -0500
    Re: What is the easiest way to edit the hosts file on Windows as admin? Lionel Muller <Erhohterlowe@neomailbox.com> - 2017-07-11 19:11 +0000
    Re: What is the easiest way to edit the hosts file on Windows as admin? Lionel Muller <Erhohterlowe@neomailbox.com> - 2017-07-11 20:41 +0000
  Re: What is the easiest way to edit the hosts file on Windows as admin? Lionel Muller <Erhohterlowe@neomailbox.com> - 2017-07-11 20:59 +0000
  Re: What is the easiest way to edit the hosts file on Windows as admin? Gralber@grelberville.org - 2017-07-11 20:06 -0400
    Re: What is the easiest way to edit the hosts file on Windows as admin? Lionel Muller <Erhohterlowe@neomailbox.com> - 2017-07-12 11:49 +0000
    Re: What is the easiest way to edit the hosts file on Windows as admin? Nomen Nescio <nobody@dizum.com> - 2017-07-12 20:04 +0200
      Re: What is the easiest way to edit the hosts file on Windows as admin? Lionel Muller <Erhohterlowe@neomailbox.com> - 2017-07-12 19:00 +0000

csiph-web