Updating the 'hosts' file from a .CMD file.

Copper Contributor

My 4 PC systems are Windows 10 Pro Build 1803.

My goal is to have a common .CMD file, which updates the 'hosts' file.

A user, who is an Administrator, and a member of the Administrators group, will run this .CMD on each system, to ensure consistency across them.

I've renamed, and attached the .CMD file as a .DOC for those interested to see the complete picture.

In diagnosing the 'Access Denied' message I've place 'pause' statements either side of the 'copy' statement which produces the 'Access Denied'. The vast majority of the .CMD file is 'defensive', and can be safely ignored.

I've check the permissions on the C:\windows\system32\drivers\etc folder, and can confirm that the user running this .CMD has 'write' permission.

 

If you can shed some light on where the issue lies, I'd be most grateful.

TIA.

0 Replies