Ami*_*ein 2 windows-7 command-line batch-file
我想将我的 ip 添加到 bat 文件中的系统/用户环境。
这是bat文件的代码
curl http://httpbin.org/ip
Run Code Online (Sandbox Code Playgroud)
这是输出:
{
"origin": "1.2.3.4"
}
Run Code Online (Sandbox Code Playgroud)
我要设置环境 set ip=1.2.3.4
我该怎么做?
curl http://httpbin.org/ip
Run Code Online (Sandbox Code Playgroud)
这是输出:
{
"origin": "1.2.3.4"
}
Run Code Online (Sandbox Code Playgroud)
使用以下批处理文件 (test.cmd):
rem @echo off
setlocal enableDelayedExpansion
for /f "usebackq skip=1 tokens=2" %%i in (`curl http://httpbin.org/ip`) do (
setx ip %%~i
goto :done
)
:done
endlocal
Run Code Online (Sandbox Code Playgroud)
笔记:
skip=1用于跳过第一行{。goto :done用于跳过最后一行}。~ 用于从 IP 地址中删除引号。| 归档时间: |
|
| 查看次数: |
1730 次 |
| 最近记录: |