开发者

.bat file to update loopback controller to external ip

Okay, so I've figured out how to get my external ip using wget:

wget -q -O - http://whatismyip.com/automation/n09230945.asp

that outputs the ip to the command console. adding > currentip.txt to the end will write it to a text file. But what I want to do is use

netsh interface ip set address name="Local Area Connection 2" source开发者_StackOverflow社区=static addr=[WHAT DO I PUT HERE]

Also, a way to make the command prompt not flash would be nice too :)


You can use variable to store IP address string. Just create BAT file with following content:

@echo off
SetLocal EnableExtensions EnableDelayedExpansion
For /F "Delims=" %%I In ('wget -q -O - http://automation.whatismyip.com/n09230945.asp') Do Set EXTERNAL_IP=%%~I
netsh interface ip set address name="Local Area Connection 2" source=static addr=!EXTERNAL_IP!

That should do the trick.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜