bat文件获取admin权限修改IP
@echo off
setlocal enabledelayedexpansion
:start
echo 开始内外网切换,需要获取Administrator权限,请点击是
echo ===============切换到内网请输入“1”
echo ===============切换到外网请输入“0”
::获取Administrator权限
cacls.exe "%SystemDrive%\System Volume Information" >nul 2>nul
if %errorlevel%==0 goto Admin
if exist "%temp%\getadmin.vbs" del /f /q "%temp%\getadmin.vbs"
echo Set RequestUAC = CreateObject^("Shell.Application"^)>"%temp%\getadmin.vbs"
echo RequestUAC.ShellExecute "%~s0","","","runas",1 >>"%temp%\getadmin.vbs"
echo WScript.Quit >>"%temp%\getadmin.vbs"
"%temp%\getadmin.vbs" /f
if exist "%temp%\getadmin.vbs" del /f /q "%temp%\getadmin.vbs"
exit
::使用Administrator权限
:Admin
::接受输入值,清醒ip切换
set /P var="请输入操作,并点击回车键盘:"
if %var% == 1 (netsh interface ip set address name = "以太网 2" static 39.106.174.175 255.255.255.192 39.106.174.17
netsh interface ip set dns name = "以太网 2" static 39.106.174.175
echo 切换内网成功
) else (netsh interface ip set address name = "以太网 2" source = dhcp
netsh interface ip set dns name = "以太网 2" source = dhcp
echo 切换外网成功
)
pause
-----------------------------------------------------------------------
版本二,获取admin速度比版本1快
@echo off
setlocal enabledelayedexpansion
:start
echo 开始内外网切换,需要获取Administrator权限,请点击是
::获取Administrator权限
%1 %2
ver|find "5.">nul&&goto :Admin
mshta vbscript:createobject("shell.application").shellexecute("%~s0","goto :Admin","","runas",1)(window.close)&goto :eof
echo ===============切换到内网请输入“1”
echo ===============切换到外网请输入“0”
::使用Administrator权限
:Admin
::接受输入值,清醒ip切换
set /P var="请输入操作,并点击回车键盘:"
if %var% == 1 (netsh interface ip set address name = "以太网 2" static 39.106.174.175 255.255.255.192 39.106.174.17
netsh interface ip set dns name = "以太网 2" static 39.106.174.175
echo 切换内网成功
) else (netsh interface ip set address name = "以太网 2" source = dhcp
netsh interface ip set dns name = "以太网 2" source = dhcp
echo 切换外网成功
)
pause