Get and edit a remote computers hosts file

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.


'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$\Windows\System32\drivers\etc\hosts"


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: