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

%3CLINGO-SUB%20id%3D%22lingo-sub-202525%22%20slang%3D%22en-US%22%3EUpdating%20the%20'hosts'%20file%20from%20a%20.CMD%20file.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-202525%22%20slang%3D%22en-US%22%3E%3CP%3EMy%204%20PC%20systems%20are%20Windows%2010%20Pro%20Build%201803.%3C%2FP%3E%3CP%3EMy%20goal%20is%20to%20have%20a%20common%20.CMD%20file%2C%20which%20updates%20the%20'hosts'%20file.%3C%2FP%3E%3CP%3EA%20user%2C%20who%20is%20an%20Administrator%2C%20and%20a%20member%20of%20the%20Administrators%20group%2C%20will%20run%20this%20.CMD%20on%20each%20system%2C%20to%20ensure%20consistency%20across%20them.%3C%2FP%3E%3CP%3EI've%20renamed%2C%20and%20attached%20the%20.CMD%20file%20as%20a%20.DOC%20for%20those%20interested%20to%20see%20the%20complete%20picture.%3C%2FP%3E%3CP%3EIn%20diagnosing%20the%20'Access%20Denied'%20message%20I've%20place%20'pause'%20statements%20either%20side%20of%20the%20'copy'%20statement%20which%20produces%20the%20'Access%20Denied'.%20The%20vast%20majority%20of%20the%20.CMD%20file%20is%20'defensive'%2C%20and%20can%20be%20safely%20ignored.%3C%2FP%3E%3CP%3EI've%20check%20the%20permissions%20on%20the%20C%3A%5Cwindows%5Csystem32%5Cdrivers%5Cetc%20folder%2C%20and%20can%20confirm%20that%20the%20user%20running%20this%20.CMD%26nbsp%3Bhas%20'write'%20permission.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIf%20you%20can%20shed%20some%20light%20on%20where%20the%20issue%20lies%2C%20I'd%20be%20most%20grateful.%3C%2FP%3E%3CP%3ETIA.%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
New 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