【问题标题】:.bat file to update loopback controller to external ip.bat 文件将环回控制器更新为外部 ip
【发布时间】:2011-01-06 03:49:13
【问题描述】:

好的,所以我已经知道如何使用 wget 获取我的外部 IP:

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

将 ip 输出到命令控制台。在末尾添加 > currentip.txt 会将其写入文本文件。但我想做的是使用

netsh interface ip set address name="Local Area Connection 2" source=static addr=[WHAT DO I PUT HERE]

另外,让命令提示符不闪烁的方法也很好:)

【问题讨论】:

    标签: batch-file automation command ip prompt


    【解决方案1】:

    您可以使用变量来存储 IP 地址字符串。只需创建具有以下内容的 BAT 文件:

    @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!
    

    这应该可以解决问题。

    【讨论】:

      猜你喜欢
      • 2013-07-28
      • 2022-07-23
      • 2017-04-04
      • 2013-10-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-12-16
      • 1970-01-01
      相关资源
      最近更新 更多