1.

Solve : Simple .bat file?

Answer»

Hi, as topic name said i need help making simple .bat file.
When it run it should EDIT this file...
C:\Windows\system32\drivers\etc\hosts
Can ANYONE post exemple?How do you want it to be edited? Appending a line based on user input or what?
You haven't given much to go on.

What reason do you have for needing to do this?when run,user need to see just this..not to type anything or do anything

CONFIGURATION to your hosts are changed successful.

Press any button to continue.

and i need this to change hosts. so it allow people to connect to lineage2 private server@echo off

>>"C:\Windows\system32\drivers\etc\hosts" echo line you want to add

echo Configuration to your hosts are changed successful.
echo.
pausethanks you...
now, i have only 1 qusetong, can it make to delete all exiting lines in that file, and insert new lines, that is given as command?>"C:\Windows\system32\drivers\etc\hosts" echo line you want to add

Use only one redirection arrow (>)

here
Code: [Select]@echo off

COLOR 0A

>"C:\Windows\system32\drivers\etc\hosts" echo 127.0.0.1
>"C:\Windows\system32\drivers\etc\hosts" echo 89.149.200.219 l2authd.lineage2.com
>"C:\Windows\system32\drivers\etc\hosts" echo 89.149.200.219 l2testauthd.lineage2.com


echo Configuration to your hosts are changed successful.
echo.
pause


and when i run it it create only last line?
this Code: [Select]89.149.200.219 l2testauthd.lineage2.comOh, I didn't realise that you were doing multiline.

Only use one redirection arrow for the first line, but 2 for all the REST, like below:

@echo off

COLOR 0A

>"C:\Windows\system32\drivers\etc\hosts" echo 127.0.0.1
>>"C:\Windows\system32\drivers\etc\hosts" echo 89.149.200.219 l2authd.lineage2.com
>>"C:\Windows\system32\drivers\etc\hosts" echo 89.149.200.219 l2testauthd.lineage2.com


echo Configuration to your hosts are changed successful.
echo.
pausethx dude



Discussion

No Comment Found