TA的每日心情 | 开心 2024-7-27 16:28 |
---|
签到天数: 155 天 [LV.7]常住居民III
管理员
- 积分
- 34003
|
新建文本文档,复制粘贴,修改好之后,另存为.bat文件。当然也可以直接下载成品bat文件进行修改~
参数说明
set networkName=WLAN 你要改的网卡名称
addr=IP
mask=掩码
gateway=网关
netsh interface ip set dns name=%networkName% source=static addr=你要改的主DNS validate=no
netsh interface ip add dns name=%networkName% addr=你要改的副DNS validate=no
bat脚本代码(懒得操作可以直接回复下载成品脚本修改)
@Echo off
:: BatchGotAdmin
:-------------------------------------
REM --> Check for permissions
>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"
REM --> If error flag set, we do not have admin.
if '%errorlevel%' NEQ '0' (
goto UACPrompt
) else ( goto gotAdmin )
:UACPrompt
echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
echo UAC.ShellExecute "%~s0", "", "", "runas", 1 >> "%temp%\getadmin.vbs"
"%temp%\getadmin.vbs"
exit /B
:gotAdmin
if exist "%temp%\getadmin.vbs" ( del "%temp%\getadmin.vbs" )
pushd "%CD%"
CD /D "%~dp0"
:home
mode con cols=25 lines=7
echo --------------
echo 设置ip88请按1
echo 设置ip89请按2
echo 退出程序请按3
set /p shu= 请输入:
set networkName=WLAN
if "%shu%"=="1" cls&goto ONE
if "%shu%"=="2" cls&goto TWO
if "%shu%"=="3" cls&goto EXIT
:ONE
echo 正在设置网络[%networkName%]
netsh interface ip set address name=%networkName% source=static addr=10.0.0.88 mask=255.255.255.0 gateway=10.0.0.1 gwmetric=1
netsh interface ip set dns name=%networkName% source=static addr=114.114.114.114 validate=no
netsh interface ip add dns name=%networkName% addr=114.114.115.115 validate=no
for /f "tokens=16" %%i in ('ipconfig ^|find /i "ipv4"') do set ip=%%i
echo 当前IP地址:%ip%
set /p wait= 设置成功,按任意键返回
goto home
:TWO
echo 正在设置网络[%networkName%]
netsh interface ip set address name=%networkName% source=static addr=10.0.0.89 mask=255.255.255.0 gateway=10.0.0.1 gwmetric=1
netsh interface ip set dns name=%networkName% source=static addr=114.114.114.114 validate=no
netsh interface ip add dns name=%networkName% addr=114.114.115.115 validate=no
for /f "tokens=16" %%i in ('ipconfig ^|find /i "ipv4"') do set ip=%%i
echo 当前IP地址:%ip%
set /p wait= 设置成功,按任意键返回
goto home
:EXIT
exit
|
|