prathapml, on 14 October 2004 - 11:45 AM, said:
But if you do want user to say yes, this will do the task you want, copy/paste into notepad, and save as .BAT:
@echo off TITLE Modifying your HOSTS file COLOR 85 ECHO. :LOOP SET Choice= SET /P Choice="Do you want to modify HOSTS file ? (Y/N)" IF NOT '%Choice%'=='' SET Choice=%Choice:~0,1% ECHO. IF /I '%Choice%'=='Y' GOTO ACCEPTED IF /I '%Choice%'=='N' GOTO REJECTED ECHO Please type Y (for Yes) or N (for No) to proceed! ECHO. GOTO Loop :REJECTED ECHO Your HOSTS file was left unchanged >> %systemroot%\Temp\yourinstall.log ECHO Finished. GOTO END :ACCEPTED ECHO Carrying out requested modifications to your HOSTS file echo 127.0.0.1 local host >> %WinDir%\system32\drivers\etc\hosts ECHO Finished. GOTO END :END ECHO. EXIT
Its quite self-explanatory. While the rest of the command-line script will do your yes/no part, the below line is what does the actual modification.
echo 127.0.0.1 local host >> %WinDir%\system32\drivers\etc\hostsThat is, you can "echo" whatever line you want into the HOSTS file, using the double-forward symbol. The location of the hosts file above, is given for win2k/XP/2k3. For win95/98/ME, its located at a different place.
Hi there this script you did... could it be modded to Delete lines from the HOST FILE Normally it's just one of these lines. But i need it to look for all 3
# 127.0.0.1 www.blah blah blah.org # 127.0.0.1 blah blah blah.org # 127.0.0.1 update blah blah blah.org
And Delete all 3 And Nothing else or just one of the lines Normally the top Line..
It's a Game Launcher & if any other Launchers are used this new Launcher will Give an error " Cannot connect to remote server " Until the one or the 3 lines are deleted..
I thank you in advance to anyone that can help. Am new to writing Scripts & ,bat files or exe
P.S I use Windows 8 Pro .. but it never give me the option when i joined
Do i have to add
DELHOST # 127.0.0.1 www.blah blah blah.org DELHOST # 127.0.0.1 blah blah blah.org DELHOST # 127.0.0.1 update blah blah blah.org[
In Some place in the bat file i make.. please can some one help. i'm so new at bat & exe files
you can still see the puppy fat round my eyes. lol
We can't play the game with out manually editing the host a few times a day.. & we wish to just run a bat script to do it for us to save time..
Ok not sure were i'm going wrong but please can some one help me..
I modded the script above but it still don't delete the lines...
i can make the script add the lines but not delete them
here is how i modded it
@echo off TITLE Modifying your HOSTS file COLOR 85 ECHO. :LOOP SET Choice= SET /P Choice="Do you want to modify HOSTS file ? (Y/N)" IF NOT '%Choice%'=='' SET Choice=%Choice:~0,1% ECHO. IF /I '%Choice%'=='Y' GOTO ACCEPTED IF /I '%Choice%'=='N' GOTO REJECTED ECHO Please type Y (for Yes) or N (for No) to proceed! ECHO. GOTO Loop :REJECTED ECHO Your HOSTS file was left unchanged >> %systemroot%\Temp\yourinstall.log ECHO Finished. GOTO END :ACCEPTED ( HERE BELOW IS WHAT I ADDED ) ECHO Carrying out requested modifications to your HOSTS file delhost 127.0.0.1 www.etcetc.org >> %WinDir%\system32\drivers\etc\hosts << I ADDED THIS LINE delhost 127.0.0.1 etc etc.org >> %WinDir%\system32\drivers\etc\hosts << I ADDED THIS LINE delhost 127.0.0.1 update.etcetc.org >> %WinDir%\system32\drivers\etc\hosts << I ADDED THIS LINE ECHO Finished. GOTO END :END ECHO. EXIT
thank you so much people in advance
Please i'm keen to learn what i can. i know it's a simple line that should be able to be goggled.. but i always come up with power shell & Linux scripts
or scripts to add lines to hosts
Also most people scream on about why there not using a DNS server.. i don't get it, why can't they just answer the question for these people instead of telling them how to run there systems lol
Anyway Thank you ....
Merry Christmas everyone also.. i wish you all the very best.. Gary (From Blackburn)
This post has been edited by Yzöwl: 17 December 2012 - 09:45 AM



Help
This topic is locked
Back to top










