Yuav ua li cas los tsim cov ntaub ntawv Batch hauv Windows 10

Cov txheej txheem:

Yuav ua li cas los tsim cov ntaub ntawv Batch hauv Windows 10
Yuav ua li cas los tsim cov ntaub ntawv Batch hauv Windows 10
Anonim

Yuav Paub

  • Tsim cov ntaub ntawv batch hauv Windows 10 los ntawm kev ntaus koj cov lus txib hauv daim ntawv Notepad dawb, thiab txuag nws li.bat es tsis yog.txt.
  • Commands suav nrog PAUSE, COPY, thiab CLS (paub meej).
  • Txhawm rau ntxiv cov lus pom, pib ib kab nrog ob txoj kab thiab qhov chaw. Cov lus pom muaj txiaj ntsig los faib cov ntaub ntawv batch rau hauv ntu.

Kab lus no piav qhia yuav ua li cas los tsim cov ntaub ntawv batch hauv Windows 10 siv Notepad, yuav ua li cas ntxiv cov lus, thiab suav nrog cov npe ntawm cov lus txib.

Yuav ua li cas los tsim cov ntaub ntawv Batch hauv Windows 10

Tsim cov ntaub ntawv batch hauv Windows 10 yog qhov yooj yim li kev ntaus cov lus txib uas koj xav khiav mus rau hauv ib daim ntawv sau tseg dawb, tom qab ntawd txuag cov ntaub ntawv ua ib qho.bat file es tsis txhob siv cov ntawv nyeem. Tom qab ntawd koj tuaj yeem khiav cov ntaub ntawv los ntawm txhaj rau nws, uas yuav cia li tso lub plhaub Windows hais kom ua thiab ua tiav koj cov lus txib.

Ntawm no yog yuav ua li cas los tsim cov ntaub ntawv batch yooj yim hauv Windows 10:

  1. Type Notepad rau hauv qhov kev tshawb nrhiav bar, thiab nyem lub Notepad app thaum nws tshwm hauv cov txiaj ntsig.

    Image
    Image
  2. Ntaus cov hauv qab no rau hauv daim ntawv dawb paug Notepad los tsim cov ntaub ntawv yooj yim:

    @ECHO OFF

    ECHO Yog tias koj pom cov ntawv no, koj tau ua tiav koj cov ntaub ntawv thawj zaug hauv Windows 10. Zoo siab!PAUSE

    Image
    Image
  3. Click File nyob rau sab laug sab laug ntawm lub qhov rais Notepad.

    Image
    Image
  4. Click Save as in the dropdown menu.

    Image
    Image
  5. Tau npe rau tsab ntawv, zoo li test.bat, thiab nyem Save.

    Image
    Image

    Nco ntsoov qhov chaw nyob ntawm koj lub hard drive qhov twg cov ntaub ntawv tau txais kev cawmdim, raws li qhov ntawd yog qhov chaw koj yuav tuaj yeem nrhiav thiab ua rau yav tom ntej.

  6. Nrhiav cov ntaub ntawv koj nyuam qhuav khaws tseg, thiab nyem ob npaug rau nws.

    Image
    Image
  7. Yog tias cov ntaub ntawv raug tsim raug, koj yuav pom lub qhov rai hais kom zoo li no:

    Image
    Image

Batch File Commands and Descriptions

Ib cov ntaub ntawv batch yog ib hom ntaub ntawv tshwj xeeb uas cia li qhib lub qhov rais hais kom ua thaum qhib. Yog tias koj twb paub cov lus txib uas koj xav tau koj cov ntaub ntawv los ua tiav, ces koj npaj mus. Tsuas ntaus cov lus txib rau hauv Notepad raws li tau teev tseg saum toj no, khaws cia ua cov ntaub ntawv.bat, thiab qhib cov ntaub ntawv batch kom ua tiav cov lus txib thaum twg koj xav tau.

Yog tias koj tsis paub meej tias yuav muab dab tsi rau hauv koj cov ntaub ntawv, nco ntsoov tias cov ntaub ntawv batch yog qhov tseem ceeb ntawm cov npe ntawm cov lus txib uas yuav ua tiav ntawm Windows hais kom sai. Txhua yam koj tuaj yeem ntaus ntawv manually rau hauv cov lus txib, koj tuaj yeem muab tso rau hauv cov ntaub ntawv batch. Cov ntaub ntawv yuav ua tiav txhua qhov kev hais kom ua, los ntawm sab saum toj mus rau hauv qab.

Ntawm no yog qee cov lus txib siv tau rau hauv cov ntaub ntawv batch, nrog rau cov lus piav qhia ntawm lawv ua dab tsi:

  • @ ECHO OFF: Disables zaub ntawm qhov kev ceeb toom. Qhov no feem ntau yog siv thaum pib ntawm cov ntaub ntawv batch rau cov zaub huv. Koj tsis xav tau @, tab sis suav nrog nws zais ECHO OFF hais kom ua ib yam nkaus.
  • ECHO: Sau cov ntawv hauv qab no rau lub qhov rais hais kom ua.
  • PAUSE: Ua rau lub qhov rais hais kom qhib qhib tom qab cov ntaub ntawv batch tiav, lossis tso cai rau cov ntawv hauv lub qhov rais los nyeem ua ntej pib.
  • TITLE: Muab lub npe kev cai rau hauv lub npe bar ntawm lub qhov rais hais kom ua.
  • CLS: Clears lub qhov rais hais kom ua.
  • EXIT: Tawm thiab kaw qhov rais hais kom ua.
  • COPY: Luam ib lossis ntau cov ntaub ntawv.
  • REM: Sau cov lus lossis cov lus hais.
  • IPCONFIG: Tso cov ncauj lus kom ntxaws IP rau txhua lub network adapter txuas nrog koj lub cev.
  • PING: Xa Is Taws Nem Tswj Message Protocol (ICMP) ncha thov rau tus IP chaw nyob lossis lub vev xaib.
  • TRACERT: Tshawb xyuas koj qhov kev sib txuas rau tus IP lossis lub vev xaib siv ICMP.
  • SET: Siv los teeb tsa.
  • IF: Ua lub luag haujlwm raws li tus neeg siv nkag lossis lwm qhov sib txawv.

Inserting Comments rau hauv Batch Files

Yog tias koj pib ib kab hauv koj cov ntaub ntawv batch nrog ob txoj kab thiab qhov chaw, nws yuav tsis raug tua. Qhov no tso cai rau koj yooj yim ntxig cov lus rau hauv koj cov ntaub ntawv batch. Cov lus pom muaj txiaj ntsig los faib cov ntaub ntawv batch rau hauv ntu nrog cov lus piav qhia luv luv raws li lub hom phiaj ntawm ntu.

Nov yog ib qho piv txwv ntawm cov ntaub ntawv batch nrog cov lus pom:

@ECHO OFF

:: Cov ntaub ntawv batch no tsuas yog ua piv txwv los qhia seb cov lus ua haujlwm li cas.

TITLE Tsuas yog qhov piv txwv hauv ntiaj teb nyob zoo los qhia seb cov lus ua haujlwm li cas.

ECHO Nyob zoo ntiaj teb no!

:: Nov yog lwm qhov lus, koj yuav tsis pom kuv tshwj tsis yog koj nyeem cov ntaub ntawv batch!

ECHO Goodbye!PAUSE

Yog tias koj muab cov lus txib no tso rau hauv cov ntaub ntawv batch thiab khiav nws, koj yuav pom cov txiaj ntsig zoo li no:

Image
Image

Cov lus tsis tsim nyog, tab sis nws yog qhov kev xaiv muaj txiaj ntsig uas koj yuav xav tau ntau ntxiv thaum tsim cov ntaub ntawv nyuaj nrog ntau ntu.

Ntawm no yog cov ntaub ntawv nyuaj me ntsis ntxiv uas siv ntau cov lus txib, cov lus pom, thiab ua haujlwm tau zoo:

:: Cov ntaub ntawv batch no yog tsim los kuaj xyuas kev sib txuas hauv is taws nem.

@ECHO OFF

TITLE Internet Status thiab Connectivity Checker

:: Cov lus txib no qhia koj cov ntsiab lus hauv network.

ipconfig /all

PAUSE

:: Nqe lus no kuaj xyuas seb puas muaj lub vev xaib tshwj xeeb.

ping google.com

:: Ntu no cia koj xaiv seb puas yuav khiav tracert.

set "reply=y"

set /p "reply=Run traceroute now? [y|n]:"

if /i not "%reply%"=="y" goto:eof

tracert google.comPAUSE

Cov ntaub ntawv no kuaj xyuas koj qhov kev sib txuas hauv internet siv ipconfig thiab tom qab ntawd nres kom koj tuaj yeem kuaj xyuas nws. Nws ces pings google.com. Thaum kawg, nws muab rau koj xaiv los khiav cov lus txib tracert yog tias koj xav tau. Nws tom qab ntawd ncua sijhawm zaum ob, tso cai rau koj los tshuaj xyuas cov txiaj ntsig ua ntej kaw lub qhov rais.

Qhov kawg tshwm sim zoo li no:

Image
Image

Koj tuaj yeem siv cov lus txib kom sai li sai tau koj nyiam hauv cov ntaub ntawv batch, suav nrog kev sib txawv thiab cov neeg siv kev sib cuam tshuam zoo li cov piv txwv saum toj no, sau cov ntaub ntawv rau lwm cov ntaub ntawv, thiab ntau dua.

Pom zoo: