views:

37

answers:

1

hello, i want to use this batch script to add new entries into my host file automatically by using windows batch.

my problem: the script just adds one line to the hosts file, also when i run the script as a administrator, so what's wrong? :(

@echo off

set hostspath=%windir%\System32\drivers\etc\hosts

echo 62.116.159.4 ns1.intranet.de >> %hostspath%
echo 217.160.113.37 ns2.intranet.de >> %hostpath%
echo 89.146.248.4 ns3.intranet.de >> %hostpath%
echo 74.208.254.4 ns4.intranet.de >> %hostpath%

exit

thanks for your help ! :- )

msec

+3  A: 

Plain typo. hostspath vs hostpath ;)

@echo off

set hostspath=%windir%\System32\drivers\etc\hosts

echo 62.116.159.4 ns1.intranet.de >> %hostspath%
echo 217.160.113.37 ns2.intranet.de >> %hostpath%
echo 89.146.248.4 ns3.intranet.de >> %hostpath%
echo 74.208.254.4 ns4.intranet.de >> %hostpath%

exit

be here now
works! thank you
msec