标签:win10批处理修改ip
因为经常出差,每次修改IP都觉得特别麻烦。然后就想到可以用批处理的方式修改IP地址,通过查资料、测试,终于找到了可以在win10下修改IP的批处理(需要以管理员权限运行),不过还不是很完善。
ECHO OFFREM QBFC Project Options BeginREM HasVersionInfo: NoREM Companyname: REM Productname: REM Filedescription: REM Copyrights: REM Trademarks: REM Originalname: REM Comments: REM Productversion: 0. 0. 0. 0REM Fileversion: 0. 0. 0. 0REM Internalname: REM Appicon: 2.icoREM QBFC Project Options EndECHO ON@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‘ ( echo Requesting administrative privileges... 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" :--------------------------------------
color 1
set /p choice= 1.设置公司IP 2.IP自动获取 3.结束 4.测试 您的选择:
echo.
if "%choice%"=="1" goto ip1
if "%choice%"=="2" goto ip2
if "%choice%"=="3" goto end
if "%choice%"=="4" goto test
goto main
:ip1
echo IP自动设置开始....
echo.
echo 正在设置IP及子网掩码
cmd /c netsh interface ip set address name="以太网" source=static addr=192.168.62.178 mask=255.255.255.0 gateway=192.168.62.1 gwmetric=1
echo 正在设置DNS服务器
cmd /c netsh interface ip set dnsservers "以太网" static 114.114.114.114 primary
netsh interface ip add dnsservers "以太网" 8.8.8.8 index=2
echo 设置完成
pause
exit
if errorlevel 2 goto main
if errorlevel 1 goto end
:ip2
color 2
echo IP自动设置开始....
echo.
echo 自动获取IP地址....
netsh interface ip set address name = "以太网" source = dhcp
echo 自动获取DNS服务器....
netsh interface ip set dns name = "以太网" source = dhcp
@rem 设置自动获取IP
echo 设置完成
pause
exit
if errorlevel 2 goto main
if errorlevel 1 goto end
:test
netsh inte***ce ip set address name = "以太网" source = dhcp
netsh inte***ce ip set dns name = "以太网" source = dhcp
netsh inte***ce ip set wins name = "以太网" source = dhcp
CHOICE /C YN /M "退出请按 Y,返回菜单请按 N。"
if errorlevel 2 goto main
if errorlevel 1 goto end
:end
标签:win10批处理修改ip
原文地址:http://tannar.blog.51cto.com/9498622/1958882