360极速浏览器极速模式通过hosts文件切换兼容模式bat脚本

注意:需要获得管理员权限执行,且后缀为 .bat

@echo off
setlocal enabledelayedexpansion
set url=被替换的域名
set ip=替换的域名
set strNew=%ip% %url%
set browser= %~dp0\Application\360chrome.exe

echo 获取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

:Admin
echo 成功取得Administrator权限

echo 修改hosts文件
set file=%SystemRoot%\system32\drivers\etc\hosts
attrib -R %file%

for /f "delims=` tokens=*" %%1 in ('findstr "%url%" %file%') do (
set valueFlag=%%1
)

if not defined valueFlag (
@echo.>>%file%
@echo %ip% %url% >>%file%
) else (
for /f "tokens=*" %%j in (%file%) do (
set "tmp=%%j"
if not !tmp!.==. (
set "tmp=!tmp:%valueFlag%=%strNew%!"
echo !tmp!>>temp.txt
)
)
move /y temp.txt %file%
)
echo 修改hosts文件成功

start %browser% http://%ip%/nmcweb/portal/

posted @ 2018-11-22 20:16  步步丶惊云  阅读(751)  评论(0编辑  收藏  举报