Skip to content

Instantly share code, notes, and snippets.

@apa6ec
Created February 13, 2015 18:11
Show Gist options
  • Save apa6ec/d6e667e12b4ebc61ae0c to your computer and use it in GitHub Desktop.
Save apa6ec/d6e667e12b4ebc61ae0c to your computer and use it in GitHub Desktop.
[Win] Fast Change hosts-file (smart shortcut)
@echo off
SetLocal EnableExtensions EnableDelayedExpansion
rem Simple text editor *.exe file
set editor=notepad
rem Hosts file path
set hosts=%SystemRoot%\System32\drivers\etc\hosts
echo Unset read-only
attrib -S -R %hosts%
rem Magic! Open on text-editor
echo Waiting for closing a text editor...
start /wait %editor% %hosts%
rem Set read-only attributes after close editor
echo Set read-only
attrib +R +S %hosts%
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment