文件名:编辑hosts.bat
%1 mshta vbscript:CreateObject("Shell.Application").ShellExecute("cmd.exe","/c %~s0 ::","","runas",1)(window.close)&&exit
if "%1"=="hide" goto CmdBegin
start mshta vbscript:createobject("wscript.shell").run("""%~0"" hide",0)(window.close)&&exit
:CmdBegin
::去除hosts文件只读属性
attrib -R C:\windows\system32\drivers\etc\hosts
::用notepad编辑hosts文件
notepad C:\windows\system32\drivers\etc\hosts
::给hosts文件加上只读属性
attrib +R C:\windows\system32\drivers\etc\hosts
Windows使用bat脚本获取管理员权限并编辑hosts文件
最新推荐文章于 2024-03-10 20:35:16 发布