简体   繁体   中英

Batch script to update hosts file on boot-up using curl

I am trying to get a .bat script to run on boot-up and purge the hosts file with a new one.

I have this working on Windows Server 2008 Standard X86 and it has been working consistently for over a year. I installed 'curl', hard linked it to System32 and schedule the following .bat script using local group policy:

curl x.x.x.x/latest/hosts > C:\Windows\System32\drivers\etc\hosts

Now I want to get the same script working on windows server 2008 R2. I have the same thing setup and it works if I double-click the .bat file. However, when the script runs on startup via GPO, it simply wipes the hosts file completely and I have to login manually and double-click the .bat script.

Any idea what's causing this? Is it a difference between Server 2008 R2 and Server 2008 STD?

Try

curl.exe x.x.x.x/latest/hosts > C:\Windows\System32\drivers\etc\hosts.tmp
move C:\Windows\System32\drivers\etc\hosts.tmp C:\Windows\System32\drivers\etc\hosts

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM