vbs script to open Hosts file with NotePad

  • Thread starter Thread starter Tony
  • Start date Start date
T

Tony

I am trying to figure out how to put a shortcut on my
desktop (or Start Menu) that will open my \etc\hosts
file...

Any ideas???

Thanks Tony
 
Create a shortcut with this target:

%windir%\notepad.exe %windir%\system32\drivers\etc\hosts

Ray at work
 
P.S. %windir%\system32\drivers\etc path is not guaranteed to be right,
actually. I guess a more reliable way would be to do:

Dim sPath, oShell
Set oShell = CreateObject("WScript.Shell")
sPath =
oShell.RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\P
arameters\DatabasePath")
oShell.Run "notepad.exe " & sPath & "\hosts", 1, False
Set oShell = Nothing

Ray at work
 
In said:
I am trying to figure out how to put a shortcut on my
desktop (or Start Menu) that will open my \etc\hosts
file...

Has to be VBS?

(all one line)
C:\TEMP>shortcut /F:"%userprofile%\desktop\HOSTS.lnk" /A:C
/T:%systemroot%\system32\notepad.exe
/P:%systemroot%\system32\drivers\etc\HOSTS /D:"System HOSTS file"


Shortcut version 1.10
Creates, modifies or queries Windows shell links (shortcuts)

http://www.optimumx.com/
 
Back
Top