用bat文件更改ip地址

@echo off
>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"
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" )
 
@echo off
:start
echo 1、公司(静态IP)
echo 2、家庭(动态IP)
set /P var="请输入你装逼的地点:"
if %var%==1 goto ip1
if %var%==2 goto ip2
:ip1
cls
netsh interface ip set address "以太网" static 192.168.1.11 255.255.255.0 192.168.1.111
netsh interface ip set dns "以太网"  static 222.222.222.1 primary
netsh interface ip add dns "以太网" 114.114.114.114
ipconfig /flushdns
echo ** 切换公司静态IP **
echo ------------------------------------------
pause
exit
goto start
:ip2
cls
netsh interface ip set address "以太网" dhcp
netsh interface ip set dns "以太网" dhcp
ipconfig /flushdns
echo ** 切换动态IP **
echo ------------------------------------------
pause
exit

转至:https://blog.csdn.net/l912943297/article/details/100552050

注意bat文件编码 UTF-8 或 ANSI

posted @ 2020-08-05 16:07  紫晶城  阅读(1065)  评论(0编辑  收藏  举报