Board logo

标题: 代码中%~2是什么意思?请指教 [打印本页]

作者: jellord     时间: 2007-3-30 11:43    标题: 代码中%~2是什么意思?请指教
@echo off ::调用格式: call :select "ip address" "ip" call :select "Physical Address" "mac" call :select "Default Gateway" "gateway" call :select "DNS Servers" "dns" call :select "Description" "netcard" :: 演示效果 echo IP:%ip% echo MAC:%mac% echo DNS:%dns% echo GATEWAY:%gateway% echo NETCARD:%netcard% pause>nul goto :eof ::************************************************************** :: 解析ipconfig命令输出通用函数 ::************************************************************** :select for /f "tokens=2 delims=:" %%i in ('ipconfig /all ^| findstr /i /c:%1') do if not "!%~2!" == "" set %~2=%%i goto :eof if not "!%~2!" == "" set %~2=%%i以上代码看不懂,上面没有用延迟变量,为什么%~2要加!呢?另外%~2又是什么意思呢?请指教。

作者: flyinspace     时间: 2007-3-30 13:31
%~2 是表示把 “ip"的引号删除。。 至于为什么要加! 我也不明白。

作者: bjsh     时间: 2007-3-30 21:12
%~2代表把引号删除是什么原理呢????

作者: xycoordinate     时间: 2007-3-30 21:20
...... call :select "ip address" "ip" call :select "Physical Address" "mac" call :select "Default Gateway""gateway" call :select "DNS Servers" "dns" call :select "Description" "netcard" ...... :select for /f "tokens=2 delims=:" %%i in ('ipconfig /all ^| findstr /i /c:%1') do if not "!%~2!" == "" set %~2=%%i ...... %~1为红色 %~2为绿色 [ Last edited by xycoordinate on 2007-3-30 at 08:28 AM ]

作者: 422904z     时间: 2007-9-3 17:39
hao'a