I am creating a batch script that replace hosts file in:
%WinDir%\system32\drivers\etc\hosts
I'm going to replace it with a backup that I have in a specific path:
batch script (run with administrative privileges):
%homedrive%\test\hosts-replace.bat
Content:
attrib -s -h -r "%WinDir%\system32\drivers\etc\hosts"
copy /v /y "%HOMEDRIVE%\test\hosts" "%WinDir%\system32\drivers\etc\hosts"
attrib +s +h +r "%WinDir%\system32\drivers\etc\hosts"
The problem is that i'm not sure if this is enough, since bleepingcomputer.com recommends running this command before the replacement (But the site does not explain how to reverse the command or its objective):
echo,Y|cacls "%WinDir%\system32\drivers\etc\hosts" /G everyone:f
Question: What is the correct way to replace hosts file with a batch script and reset the permissions on the hosts file to default?
Thanks in advance
%WinDir%
": From the "SS64 Command line reference": "Set by default as windir=%SystemRoot%. %WinDir% pre-dates Windows NT. Its use in many places has been replaced by the system variable: %SystemRoot%"