Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > microsoft.public.scripting.vbscript > #11714
| 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.
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 microsoft.public.scripting.vbscript | Previous | Next — Previous 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