Get IPv4 Address 1.0

 gia.bat

 1 @echo off
 2 color 0a
 3 title Get IPv4 Address 1.0
 4 
 5 SETLOCAL ENABLEEXTENSIONS
 6 SETLOCAL ENABLEDELAYEDEXPANSION
 7 
 8 set "CS_1=Wireless LAN adapter Wireless Network Connection:"
 9 set "CS_2=IPv4 Address. . . . . . . . . . . "
10 set _TMP=%TEMP%\.gia.tmp
11 
12 rem Stage. 1: 
13 :PROC_1
14 cd . > "%_TMP%"
15 for /f "tokens=*" %%i in ('ipconfig') do (
16     >> "%_TMP%" echo %%i
17 )
18 for /f "usebackq tokens=1* delims=:" %%i in (`findstr /n /c:"%CS_1%" "%_TMP%"`) do (
19     set /a POS_BEGIN=%%i
20     goto :PROC_2
21 )
22 echo Err: PROC_1
23 goto :NORMAL_EXIT
24 
25 rem Stage. 2: 
26 :PROC_2
27 set /a INDEX=0
28 for /f "usebackq tokens=1* delims=:" %%i in ("%_TMP%") do (
29     set /a INDEX+=1
30     if !INDEX! gtr %POS_BEGIN% (
31         if "%%i" equ "%CS_2%" (
32             set _IP=%%j
33             goto :PROC_3
34         )
35     )
36 )
37 echo Err: PROC_2
38 goto :NORMAL_EXIT
39 
40 rem Stage. 3: 
41 :PROC_3
42 for /f "tokens=*" %%i in ("%_IP%") do (
43     rem echo %%i| clip
44     set /p "_CLIP=%%i" < nul | clip
45     echo Paste it.
46     goto :NORMAL_EXIT
47 )
48 echo Err: PROC_3
49 goto :NORMAL_EXIT
50 
51 :NORMAL_EXIT
52 if exist "%_TMP%" del "%_TMP%"
53 pause
54 exit

附件1

posted @ 2019-05-29 18:36  RMS365  阅读(...)  评论(...编辑  收藏