windows 批處理小記

來源:互聯網
上載者:User

標籤:windows   批處理   

@echo off &setlocal enabledelayedexpansionecho 修改hosts檔案::type c:\windows\system32\drivers\etc\hosts^ | findstr /n ".*":mainecho  ===============================echo   請選擇需要進行的操作echo  ===============================echo.echo  1. 添加hosts       2. 修改hostsecho.echo  3. 清空hosts       4. 顯示當前hosts內容echo.echo  5. 退出            6. 清屏 choice /c:123456 /m:請輸入數字:if errorlevel 6 goto clearif errorlevel 5 goto endif errorlevel 4 goto typeif errorlevel 3 goto delif errorlevel 2 goto changeif errorlevel 1 goto add:addecho  -------------------------------set /p domain=請輸入欄位名:echo  -------------------------------set /p ip=請輸入IP:echo  -------------------------------echo %ip% %domain% >>c:\windows\system32\drivers\etc\hostsif errorlevel 0 (echo 修改成功) else (echo 修改失敗)choice /c:123 /m:1返回,2ping測試,3退出:if errorlevel 3 goto endif errorlevel 2 goto pingif errorlevel 1 goto main:pingecho ----------------開始進行ping測試----------------for /f "delims=[] tokens=2 " %%i in (‘ping -n 1 %domain%^|findstr [‘) do (if %ip% == %%i (echo ----------------ping測試成功----------------) else (echo ----------------ping測試失敗,請重新修改----------------))goto choice:typeecho 當前hosts內容:echo  -------------------------------type c:\windows\system32\drivers\etc\hosts^ | findstr /n ".*"echo  -------------------------------echo.goto choice:clearclsgoto main:deldel /Q c:\windows\system32\drivers\etc\hostsif errorlevel 0 (echo 清除成功) else (echo 清除失敗)type nul >c:\windows\system32\drivers\etc\hostsgoto choice:choicechoice /c:12 /m:繼續請按1,退出請按2REM 應先判斷數值最高的錯誤碼if errorlevel 2 goto endif errorlevel 1 goto main:endexit


本文出自 “天天向上” 部落格,請務必保留此出處http://bshark.blog.51cto.com/10309374/1934401

windows 批處理小記

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.