使用bat脚本更改网卡名称需要管理员权限,可以使用以下代码:

@echo off
setlocal enabledelayedexpansion

echo Searching for network adapters...
set found=0
for /f "tokens=2 delims=: " %%a in ('ipconfig /all ^| find "Adapter"') do (
    set /a found=!found!+1
    set adapter[!found!]=%%a
    echo !found!. !adapter[!found!]!
)

if !found! equ 0 (
    echo No network adapters found.
    pause
    exit /b 1
)

set /p choice=Enter the number of the adapter to rename: 

if !choice! gtr !found! (
    echo Invalid choice.
    pause
    exit /b 1
)

set /p newname=Enter the new name for the adapter: 

echo Renaming adapter !adapter[%choice%]! to !newname!...
netsh interface set interface name="!adapter[%choice%]!" newname="!newname!"

echo Done.
pause

这段代码会列出所有网络适配器的名称,然后让用户选择要更改的适配器,并输入新的名称。最后使用netsh命令来更改适配器名称。

如果运行时出现“No network adapter found.”的错误提示,可能是因为没有找到任何网络适配器。可以尝试检查一下计算机是否已经连接到网络,并确保网络适配器已经正确安装。

使用bat更改网卡名称能不能自动检测原来的名称闪退了提示No network adapter found

原文地址: https://www.cveoy.top/t/topic/b3py 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录