Windows Batch processing small note

Source: Internet
Author: User
Tags clear screen

Tag:windows    batch processing    

@echo  off &setlocal enabledelayedexpansionecho  Modify the Hosts file:: type c:\windows\ system32\drivers\etc\hosts^ | findstr /n  ". *": mainecho  ======================== =======echo    Select the action echo  ===============================echo.echo  1 you want to make.   Add hosts       2.  Modify hostsecho.echo  3.  empty hosts        4.  Show current hosts content echo.echo  5.  exit              6.  Clear Screen  choice /c:123456 /m: Please enter a number: 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= Please enter the domain name: echo  -------------------------------set /p ip= Please enter ip:echo  -------------------------- -----echo %ip% %domain% >>c:\windows\system32\drivers\etc\hostsif errorlevel 0   (echo  modified successfully)  else  (echo  modification failed) choice /c:123 /m:1 back, 2ping test, 3 exit:if  Errorlevel 3 goto endif errorlevel 2 goto pingif errorlevel 1  goto main:pingecho ----------------Start the ping test----------------for /f  "delims=[]  tokens=2  " %%i in  (' ping -n 1 %domain%^|findstr [')  do  (if  %ip% == %%i  (echo ----------------Ping Test successfully----------------)  else  (Echo  ----------------Ping test failed, please re-modify----------------)) goto choice:typeecho  Current hosts content: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  cleared successfully)  else  (echo  cleanup failed) type  nul >c:\windows\system32\drivers\etc\hostsgoto choice:choicechoice /c:12 /m: Continue, press 1 , exit please press 2rem  should first determine the highest value error code If errorlevel 2 goto endif errorlevel 1 goto  main:endexit


This article from "Day Up" blog, please be sure to keep this source http://bshark.blog.51cto.com/10309374/1934401

Windows Batch processing small note

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.