
[分享]批處理根據(jù)用戶輸入數(shù)字輸出對(duì)應(yīng)的網(wǎng)卡名稱【問(wèn)題描述】我之前遇到一個(gè)難題 煩請(qǐng)幫忙看下 如何才能輸出對(duì)應(yīng)的網(wǎng)卡
nload="thumbImg(this)" alt="" />nclick="copycode($('code0'));">復(fù)制代碼
- @echo off
- echo 獲取所有在線網(wǎng)卡名稱
- echo.
- setlocal enabledelayedexpansion
- set interfaces=
- set count=1
- for /f tokens=4,* skip=3 delims= %%i in ('netsh interface show interface') do (
- echo !count!. %%i %%j
- set interface=%%i %%j
- REM 將在線網(wǎng)卡添加到列表中
- set interfaces=!interfaces! !count!.!interface!
- set /a count+=1
- )
- echo.
- ::選擇要修改的網(wǎng)卡編號(hào)
- set /p selected_number=請(qǐng)選擇要修改的網(wǎng)卡編號(hào):
- echo.
- ::查找選擇的網(wǎng)卡
- for %%i in (%interfaces%) do (
- if %%i==%selected_number% (
- set selected_interface=%%i
- )
- )
- ::從選擇的網(wǎng)卡中提取網(wǎng)卡名稱
- echo 選擇的網(wǎng)卡名稱:%selected_interface%
- echo.
- pause

