Cov txheej txheem:

Batch Tutorial - Siv 2: 4 Cov Kauj Ruam
Batch Tutorial - Siv 2: 4 Cov Kauj Ruam

Video: Batch Tutorial - Siv 2: 4 Cov Kauj Ruam

Video: Batch Tutorial - Siv 2: 4 Cov Kauj Ruam
Video: qhia ntaus txoj nkauj - Kev hlub tim vaj loog tsua 2024, Kaum ib hlis
Anonim
Batch Tutorial - Siv 2
Batch Tutorial - Siv 2

Zoo li kuv tau hais hauv kuv qhov kev qhia yav dhau los ntawm pawg (https://www.instructables.com/id/EZ049TMM19EWPKGWKH/#CEINEJV64U3EWP86YUP), Kuv npaj yuav tsim qhov nthuav dav 3 ntu (lossis coj) qhia ntawm pawg. Uas yuav tsum npog feem ntau ntawm yam koj yuav tsum paub ua yam koj xav tau nrog cov khoom. Qhov ntawv txuas hauv qab no yog qhov sib tw.bat (batch) ua los ntawm kuv, laconix / inevitable_chaos

Kauj Ruam 1: Hloov Kuv Cov Ntawv, Npe, thiab Cls

Okay pib nrog kuv mam li qhia koj cov cai;

@echo offtitle Xaiv.. [los ntawm laconix] clsecho Koj muaj qee qhov kev xaiv los ua..echo.. ua qhov kev xaiv tsis raug tab sis raug kev txom nyem qhov tshwm sim! echo.pause: menuclsecho.echo.echo.echo.echo. ncha / ------------------------------ / ncha / Xaiv tus lej ntawm 1 thiab 3 / ncha (-1.. 2.. 3 -) ncha / Txhua qhov kev xaiv tab sis ib qho tsis zoo! /ncha / ------------------------------/ lub hauv paus teeb tsa lub npe rau qhov hais kom ua sai li ntawd lub npe instructables.com txias! cls tsuas yog tshem tawm cmd ntawm ib qho kev tawm tswv yim lossis tso tawm Koj yuav tsum paub dab tsi ncha ua los ntawm tam sim no, tab sis ncha. tsim kab ntawv tshiab uas muaj txiaj ntsig zoo rau kev teeb tsa.: cov ntawv qhia zaub mov txawm hais tias kuv tau hais txog qhov no hauv kuv qhov kev qhia yav dhau los nws tsim nyog rov mus dua, qhov tseem ceeb nws tsim cov ntsiab lus hauv qhov haujlwm uas koj tuaj yeem GOTO txhua lub sijhawm.: D

Kauj Ruam 2: Pib Pib Hloov Pauv, Tau Txais Cov Neeg Siv Khoom thiab Yog Cov Lus Qhia

Ib zaug ntxiv kuv yuav qhia koj txoj cai ces piav nws;

teeb xaiv = nadaecho?.: Dab tsi & aposll nws yog:? set /p xaiv = Huh? clsif % xaiv % == 1 GOTO oneif % xaiv % == 2 GOTO twoif % xaiv % == 3 GOTO threemsg * Tsis yog 1, 2 lossis 3 eh? Hmoov tsis zoo, bye bye..shutdown -s -f -t 00 teeb tsa xaiv = nada, qhov no ua dab tsi yog tsim lossis pib qhov txawv txav nrog tus nqi pib lossis "nada", lossis tsis muaj dab tsi.: D Qhov sib txawv yog zoo li lub thawv uas khaws cov ntaub ntawv rau koj kom txog thaum nws tsis xav tau ntxiv lossis txoj haujlwm kaw. teeb /p xaiv =, qhov no tau txais cov neeg siv cov lus qhia, los ntawm kev siv teeb tsa hais kom ua nrog kev sib cav /p uas qhia qhov hais kom ua kom muaj kab lus nrawm. Yog li pib teeb tsa /p xaiv = tus lej twg? zoo li nug ib lo lus nug thiab lawv ntaus cov lus teb. yog tias nqe lus ua haujlwm zoo li no. if condition == true dothis Yog li ntawd nws tau hais yog % xaiv % sib npaug rau 1 GOTO ib qho uas tsis yog qhov tseeb nws tsuas yog mus rau kab tom ntej. kaw -s -f -t 00 tsuas yog kaw lawv lub computer yuam kom txhua lub program kaw, tam sim ntawd.

Kauj Ruam 3: Piping Command, Asynchronous Commands thiab Environmental Variables

Ib zaug ntxiv, chaws ua ntej, piav qhia tom qab;

: onemsg * Yog li koj tau xaiv #1, xav tias koj & aposd muaj kev nyab xeeb? msg * WRONG!: netspamnet xa * laconix cov cai! GOTO netspam: twoshutdown -s -t 10pausemsg * Vam tias koj tau txais qhov no nyob rau lub sijhawm, vim tias qhov no yog qhov nyab xeeb… kaw -aGOTO ntuj raug txim: threemsg * Qhov no yog tus lej muaj kev nyab xeeb… ncua: forkstart choices.bat | msg * Nco ntsoov tshem tawm! GOTO diav rawg: hellmsg * tso dag, lawv & aposre txhua qhov phem!: textbombecho laconix cov cai! >> %systemroot %/laconix.txtGOTO: textbomb: ib qho yooj yim tsuas yog nkag mus rau hauv lub voj GOTO tsis muaj qhov kawg. Zoo ib yam li rab diav rawg piv txwv 2 hauv thawj qhov kev qhia.: Ob qho ua tiav cov lus txib kaw -s -t 10 "ncua sijhawm, yog tias lawv tsis nias tus yuam sij hauv lub sijhawm lawv lub computer kaw, yog tias lawv ua rau nws rho menyuam thiab ua rau lawv GOTO ntuj raug txim: ntuj raug txim Hais rau lawv tias tsis muaj leej twg ua tau zoo, ua li cas kuv hu xov tooj foob pob. Cov kav dej twg (>>) hais kom ua ncha laconix txoj cai! ' mus rau %systemroot %/laconix.txt hauv / n qhov kawg GOTO voj. %systemroot %yog qhov sib txawv ib puag ncig uas qhia cov ntaub ntawv kom txuag tau hauv/windows/directory tsis hais lub npe ntawm lub hauv paus tsav, piv txwv li. C;/, E:/, Z:/, thiab lwm yam: pebTricks lawv rau hauv kev xav nws tus lej nyab xeeb Mus rau hauv rab rawg zoo ib yam li ntawd hauv thawj qhov kev qhia, tab sis nrog ib qho tseem ceeb sib txawv. Asynchronous txib; pib xaiv.bat | msg * Nco tawm ! | qhia txog cov lus txib tsis sib xws, uas txhais tau tias lawv tau ua tiav tib lub sijhawm.

Kauj ruam 4: Ua Li Cas? Lo lus

Ua tsaug rau kev nyeem kuv cov lus qhia, vam tias koj nyiam cov vis dis aus. Kawm ib yam dab tsi.

Thiab kuv vam tias koj txuas ntxiv kev txaus siab hauv khoos phis tawj, thiab hauv kuv cov lus qhia. Khaws taub hau rau kuv qhov kev qhia zaum kawg hauv kab ntawv no sai!

Pom zoo: