On Wed, 9 Dec 2020 23:15:08 -0000 (UTC), Arlen Holder wrote:
> SOLVED!
> In summary, typing "hosts" at the Run box executes the "hosts.exe" app key
> value which runs the "hostsedit" shortcut which runs the "Task hosts edit"
> task as administrator (without bringing up any UAC access control prompts).
I haven't seen any of these methods documented on the net, but in my files
I found I had previously solved this problem in 2017 by a different method.
As always, so that all benefit from everything we learn on Windows,
here's a paste from my old logs, which I had forgotten I had documented.
It's "similar" but a _different_ method of editing the hosts file where
this method only uses two of the three components of the previously
documented method (i.e., this method omits the task scheduler trick).
The goal is single-step hosts file editing using native Windows methods:
o Win+R > hosts
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: 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 cascade menu:
Rightclick in any folder "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 any desired 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:
Rightclick on the shortcut you just created to edit its properties.
Select "Properties" from the context menu that results.
Press the Advanced button
Check [x]Run as Administrator
Press OK
That successfully modifies the shortcut which you can then put in your
cascaded start menu which, when clicked, will edit the
hosts file as administrator using your editor of choice.
Taskbar > menu > network > hosts
6. Put the shortcut in a location that you confirm with the command line:
C:\Users\%username%\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 "Win+R > 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, which is easy to do if you have a decent Wi-Fi LAN.
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:
Win+R > Run > hosts <enter> (this should edit the hosts as admin)
Start > Programs > hosts (this should edit the hosts as admin)
Note: This was posted in 2017, which I cleaned up slightly for 2020.
I tested this method in 2017, but didn't test in 2020 so I'm not sure
if the UAC access prompt nag screen comes up or not using this method.
--
Posted out of the goodness of my heart so that others can benefit.