質問

I'm trying to build bat file for my uncle who needs once click solution to change ip as I advised him not to fidget with fragile modem power button. How can I achieve also some option will be attractive.

I tried this but didn't work.

ipconfig/release
[some 1 min interval]
ipconfig/renew

For a wifi modem we were not able to achieve such thing, we had to switch it off and on manually

役に立ちましたか?

解決 2

Update 11/11/13: the question is still open. ipconfig was not strong enough to fix it... still you can make use of choice options incase you are building a tool for anyother purpose. Choice command won't work in Win XP and Win 2000 replace them by set command and accordingly goto statements too

xsl help is appreciated but after much googling I found ping 1.1.1.1 is not cool instead we have to use ping 127.0.0.0, here is what I have done. And here is where I found the choice commands details http://www.torgersens.net/wordpress/?p=273 long before Rock cud answer just that I was fine tuning my answer.

@echo off
:Menu
echo.
echo C for Change IP  or Q to Quit
echo.
:Choice
choice /C CQ /M "Enter Choice"
goto ERR%errorlevel%
:ERR1
ipconfig /release 
ping localhost -n 10 -w 1000 > nul
ipconfig /renew
echo Done
goto END
:ERR2
echo Bye
goto END
:END
pause

他のヒント

On Windows 7 and later it's pretty simple:

ipconfig /release 
timeout 60 
ipconfig /renew

Earlier systems:

ipconfig /release
ping -n 60 localhost > nul
ipconfig /renew

I got the ping/sleep hack from this answer.

Adding to what xsl has answered.

@echo off
choice /C YN /M "Are you sure you want to change your ip?" 
ipconfig /release 
timeout 60 
ipconfig /renew

You can add timeout to the choice.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top