本帖最后由 pcl_test 于 2016-11-10 12:39 编辑
- @echo off
- call :select "ip address" "ip"
- call :select "host name" "hostname"
-
- echo.
- echo ===========================
- echo IP地址: %ip%
- echo.
- echo 机器名: %hostname%
- echo ===========================
- pause>nul
- goto :eof
-
- :select
- for /f "tokens=2 delims=:" %%i in ('ipconfig /all ^| findstr /i /c:%1') do if not %2 == "" set %~2=%%i
- goto :eof
复制代码 for这里这一段,('ipconfig /all ^| findstr /i /c:%1') 用^是指什么呢?为何不是('ipconfig /all | findstr /i /c:%1'),
就像ipconfig /all | findstr /i /c:"ip address" 这样
set %~2=%%i这里的~又是指什么?为何不是set %2=%%i
[ 本帖最后由 robinher 于 2010-10-26 23:43 编辑 ] |