本帖最后由 lihui612ld 于 2022-4-19 16:47 编辑
- @echo off&setlocal enabledelayedexpansion
- del 123.txt
- set flag1=0
- set flag2=0
- for /f "tokens=2 delims=:" %%i in ('ipconfig ^|find "IPv4 地址"') do (
- for /f "tokens=3,4 delims=." %%a in ('echo %%i') do (echo %%a %%b
- set flag1=%%a
- set flag2=%%b
- )
- )
- set str=!flag1!
- set StrMAX=1000
- for /l %%a in (0,1,%StrMAX%) do if "!str:~%%a,1!"=="" set num=%%a&goto :ok
- :ok
- if !num!==1 (set var=00!flag1!)
- if !num!==2 (set var=0!flag1!)
- if !num!==3 (set var=!flag1!)
- set str=!flag2!
- set StrMAX=1000
- for /l %%a in (0,1,%StrMAX%) do if "!str:~%%a,1!"=="" set num=%%a&goto :ok1
- :ok1
- if !num!==1 (set var1=00!flag2!)
- if !num!==2 (set var1=0!flag2!)
- if !num!==3 (set var1=!flag2!)
-
- set pp=!var!!var1!
- echo "ID":"!pp!">123.txt
- echo "Host":"abc">>123.txt
- pause
复制代码 试下这个 |