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](https://support.microsoft.com/en-au/help/972034/how-to-reset-the-hosts-file-back-to-the-default) 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](https://www.bleepingcomputer.com/download/hosts-permbat/) 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