国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 編程 > BAT > 正文

script_tool_for_windows.bat Windows 環(huán)境下的 hosts 一鍵部署腳本

2020-03-29 19:53:24
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友

我們提供了一系列工具讓您除了手動(dòng)以 復(fù)制/粘貼 的方式部署和更新 hosts 之外,有一種方便、一鍵式的方式來(lái)應(yīng)用我們的 hosts 。

我們現(xiàn)有的工具可以在下列平臺(tái)上工作:
Microsoft Windows (.bat script; Qt GUI tool; console (service type) tool)

另外,我們還推薦使用跨平臺(tái)的 Hozz 來(lái)管理、自動(dòng)更新 hosts 。

目前,我們共有:

Hozz: 跨平臺(tái)的 hosts 自動(dòng) 管理/更新 工具。是 @ppoffice 的項(xiàng)目。

項(xiàng)目主頁(yè)
項(xiàng)目Github主頁(yè) https://github.com/racaljk/hosts/tree/master/hosts_tools
HostTool: Windows 環(huán)境下的 hosts 自動(dòng)更新應(yīng)用,使用 C++ 構(gòu)建, GUI 基于 Qt 。由 @racaljk 貢獻(xiàn)。
HostToolforMac: Mac 環(huán)境下的 hosts 自動(dòng)部署更新應(yīng)用(適用于 OS X 10.10 或以上),基于 Swift 開發(fā)。由 @ZzzM 貢獻(xiàn)。
HostsToolforWindows: Windows console環(huán)境下的 hosts 自動(dòng)更新應(yīng)用(作為系統(tǒng)服務(wù)),使用 C++ 構(gòu)建。由 @Too-Naive 貢獻(xiàn)。
script_tool_for_windows.bat: Windows 環(huán)境下的 hosts 一鍵部署腳本,由 @redapple0204 與 @lizongzeshunshun 貢獻(xiàn)。以及 @lideming 提供的重要更新。

@echo offif defined converted goto :convertedset ConverterPath=%temp%/HostsGeter_CodeConverter.vbsset ConverterOutput=%temp%/HostsGeter_GBK.batecho inputpath="%~0" >%ConverterPath%echo outputpath="%ConverterOutput%" >>%ConverterPath%echo set stm2=createobject("ADODB.Stream") >>%ConverterPath%echo stm2.Charset ="utf-8" >>%ConverterPath%echo stm2.Open >>%ConverterPath%echo stm2.LoadFromFile inputpath >>%ConverterPath%echo readfile = stm2.ReadText >>%ConverterPath%echo stm2.Close >>%ConverterPath%echo Set Stm1 =CreateObject("ADODB.Stream") >>%ConverterPath%echo Stm1.Type = 2 >>%ConverterPath%echo Stm1.Open >>%ConverterPath%echo Stm1.Charset ="GBK" >>%ConverterPath%echo Stm1.Position = Stm1.Size >>%ConverterPath%echo Stm1.WriteText "set converted=y" ^& vbcrlf >>%ConverterPath%echo Stm1.WriteText readfile >>%ConverterPath%echo Stm1.SaveToFile outputpath,2 >>%ConverterPath%echo Stm1.Close >>%ConverterPath%%ConverterPath% && %ConverterOutput%goto :eof:convertedchcp 936:: 更改cmd窗口代碼頁(yè)至 936(GBK)cls%1 %2ver|find " 5.">nul &&goto :stecho 正在進(jìn)行 UAC 提權(quán)...mshta vbscript:createobject("shell.application").shellexecute("%~s0","goto :st","","runas",1)(window.close)&goto :eof:stcls@REM HostsGet Version0.4cd /d %~dp0set LogFilePath=%temp%/HostsGeter_log.txtset DLScriptPath=%temp%/downloadhosts.vbsset DLPath=%windir%/system32/drivers/etc/hosts_downloadedset BackupDir=%windir%/system32/drivers/etcset HostsPath=%windir%/system32/drivers/etc/hostsset LogToFile=^>^>%LogFilePath% 2^>^&1set EchoAndLog=call :echoandlogecho. %LogToFile%echo ==========[%date% %time%]========== %LogToFile%echo 日志文件:echo %LogFilePath%echo.echo iLocal=LCase("%DLPath%") > %DLScriptPath% ||( call :error downloadhosts.vbs 文件創(chuàng)建/寫入失敗.)echo iRemote=LCase("https://raw.githubusercontent.com/racaljk/hosts/master/hosts") >> %DLScriptPath%echo Set xPost=createObject("Microsoft.XMLHTTP") 'Set Post = CreateObject("Msxml2.XMLHTTP") >> %DLScriptPath%echo xPost.Open "GET",iRemote,0 >> %DLScriptPath%echo xPost.Send() >> %DLScriptPath%echo set sGet=createObject("ADODB.Stream") >> %DLScriptPath%echo sGet.Mode=3 >> %DLScriptPath%echo sGet.Type=1 >> %DLScriptPath%echo sGet.Open() >> %DLScriptPath%echo sGet.Write xPost.ResponseBody >> %DLScriptPath%echo sGet.SaveToFile iLocal,2 >> %DLScriptPath%%EchoAndLog% 開始從 GitHub 中下載 hosts 文件...if exist %DLPath% del %DLPath% /s /q %LogToFile%%DLScriptPath% || call :error hosts 文件下載失敗.del %DLScriptPath% /s /q %LogToFile%if not exist %DLPath% call :error hosts 文件下載失敗.%EchoAndLog% 下載完成.echo.if exist %HostsPath% (  call :backuphosts) else (  %EchoAndLog% (原 hosts 文件不存在,跳過(guò)備份))%EchoAndLog% 正在替換 hosts 文件...move %DLPath% %HostsPath% %LogToFile% || call :error hosts 文件替換失敗.%EchoAndLog% hosts 文件已替換.echo.%EchoAndLog% 正在刷新系統(tǒng) DNS 緩存...ipconfig /flushdns %LogToFile% || call :error DNS 緩存刷新失敗.%EchoAndLog% DNS 緩存已刷新.echo.%EchoAndLog% 【操作全部完成!】echo.echo 按任意鍵訪問(wèn) google.com.hk 進(jìn)行測(cè)試,如取消,請(qǐng)直接關(guān)閉本窗口pause >nulstart https://www.google.com.hkecho 已經(jīng)幫你訪問(wèn) google.com.hk 如可以訪問(wèn)則替換成功.echo.goto :end:backuphosts%EchoAndLog% 正在備份原 hosts 文件...set "bakfilename=hosts_%date%_%time:~0,8%.bak"set bakfilename=%bakfilename:/=-%set bakfilename=%bakfilename:/=-%set bakfilename=%bakfilename::=-%set bakfilename=%bakfilename: =_%copy %HostsPath% %BackupDir%/%bakfilename% %LogToFile% || call :error hosts 文件備份失敗.%EchoAndLog% 原 hosts 文件已備份到 %BackupDir%/%bakfilename%.echo.goto :eof:errorecho ======================%EchoAndLog% 錯(cuò)誤:%*start %LogFilePath%echo 已打開日志文件goto :end:echoandlogecho %*echo %* %LogToFile%goto :eof:endecho 按任意鍵關(guān)閉pause >nulexit

發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 志丹县| 连平县| 固镇县| 永修县| 会同县| 宜君县| 巴彦县| 多伦县| 嘉祥县| 凭祥市| 志丹县| 大悟县| 新邵县| 含山县| 高雄市| 加查县| 得荣县| 化州市| 扎赉特旗| 安丘市| 新巴尔虎右旗| 庄河市| 龙门县| 渭源县| 九台市| 桐柏县| 万山特区| 万州区| 阿鲁科尔沁旗| 黎川县| 玛沁县| 乌兰县| 镇坪县| 宝山区| 宣威市| 乌什县| 庐江县| 武强县| 清原| 乐昌市| 七台河市|