1.

Solve : Ip Config Batch File Help?

Answer»

I am trying to make a batch file that will re-configure my IP address but It gets stuck in a LOOP on the first command. Im running Vista Home Premium on an HP laptop. Here's my file so far:
IPconfig.bat
==========================

Echo Preparing to Reconfigure IP/DNS...
pause
ipconfig /flushdns
pause
ipconfig /release
pause
ipconfig /renew
pause
echo IP/DNS Configured successfully... Thank you come again!
echo time
exit


=========================

If I could even get it without requiring user input that would be fantastical. I know I could just remove the pause and the echo comments., but it still gets stuck so *censored*>What does the script do when you try to FLUSH the dns?it loops the first command. it seems to flush the dns but it just keeps doing it over and over etc. never going to the next command?!Do the commands at the command line and not in a batch. Do only one command at a time.

C:\>ipconfig /release

C:\>ipconfig /flushdns

C:\>ipconfig /renewthe cause is actually pretty simple:

Quote

Here's my file so far:
IPconfig.bat

if the file is called "IPConfig" then calling "IPConfig" within that batch will simply execute the same batch. Rename the batch file, and it should work fine with or without the pause statements.

As a sort of sidebar, when you type something without a extension (such as for commands, batches, etc) windows (or DOS in the case of an older PC) has to search all path folders for a executable. Executables on DOS were COM, EXE, and BAT files, and were searched in that order. Windows has more extensions, and extensions can be added (and the order changed) but it follows the same basic ruleset, and batch files come last in the search pattern.

So- why is ipconfig.exe not being chosen? well, it searches the current directory first, so it finds your batch file first. OH uh yeah the bat file doesnt include the ipconfig.bat. it only has the text between the hash marks in my orig post. ie: file name xxx.exe contains this
------------------------------------------

hi i am xxx.exe

over

------------------------------------------

see? so it cant be looping itself from its own callout because i do not call to the file within itself. whew. Quote from: BillRichardson on January 03, 2010, 06:43:21 AM
Do the commands at the command line and not in a batch. Do only one command at a time.

C:\>ipconfig /release

C:\>ipconfig /flushdns

C:\>ipconfig /renew

but... that takes the point (and fun) out of making the bat!your batch file is called "ipconfig.bat"

Quote
Here's my file so far:
IPconfig.bat

your subsequent lines that use ipconfig are now simply reentering your batch file.

consider if you have a batch file called "find.bat"

CODE: [Select]echo this is find.bat. how are things.
find /i %1 %2

what HAPPENS here? find .bat calls itself on the second line, because windows searches in the current directory first- the location of your batch file; for any file that has a "pathext" extension; defaults are exe,com,pif,vbs,js, and bat. so the find.bat that is currently executed is run instead of the intended find.exe that is in the system folder.

This is what you are doing, but with ipconfig. rename the batch file to something else and the PROBLEM will probably go away.



Discussion

No Comment Found