Windows批處理一鍵添加hosts文件


批處理一鍵添加hosts文件

此腳本主要用於安裝一些學習軟件時需屏弊一些網站,雙擊一鍵修改。

@echo off 
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權限
SET NEWLINE=^& echo.

::FIND /C /I "輸入你要查詢內容" %windir%\system32\drivers\etc\hosts
FIND /C /I "test.com" %windir%\system32\drivers\etc\hosts

::IF %ERRORLEVEL% NEQ 0 ECHO %NEWLINE%^127.0.0.1		輸入你要屏弊的域名>>%WINDIR%\system32\drivers\etc\hosts
IF %ERRORLEVEL% NEQ 0 ECHO %NEWLINE%^127.0.0.1		test.com>>%WINDIR%\system32\drivers\etc\hosts
::查看修改結果
type %windir%\system32\drivers\etc\hosts
pause


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM