Get and edit a remote computers hosts file

2011/12/04 | By | Reply More

For those times when you don’t have easy access to computer and need to view its hosts file then the below script can come in handy.

Download Button5

'script will get and allow you to edit a remote computers hosts file
'it also changes the association for extensionless files like the hosts file to open with notepad

'Get and open Remote Computers Hosts file
on error resume next

Set WshShell = Wscript.CreateObject("Wscript.Shell")
strcomputer  = inputbox("Enter remote computer name or leave as localhost for this computer","Get Hosts file","Localhost")

If strComputer = "" Then
End If

'Associate Extensionless Files with Notepad "%comspec% /c c: & assoc .=txtfile"
WScript.Sleep 500 'give association time to take effect

'open hosts file on remote
wshShell.Run "\" & strcomputer & "c$WindowsSystem32driversetchosts"

Category: Scripts, VBS

Leave a Reply

%d bloggers like this: