Ngokuvamile, amathiphu wokwenza izinto nokulungiswa ku-Windows 10, 8, ne-Windows 7 kufaka izinyathelo ezinjengalezi: "dala ifayela le-.bat ngokuqukethwe okulandelayo bese uligijima." Noma kunjalo, umsebenzisi we-novice akawazi njalo ukwenza lokhu nokuthi yini ifayela elimelelayo.
Le imininingwane yokufundisa indlela yokwakha ifayela le-bat, ukugijima, nolunye ulwazi olwengeziwe olungase luzuze kumongo wesihloko embuzweni.
Ukudala ifayela le-.bat nge-notepad
Indlela yokuqala futhi elula yokwakha ifayela ye-bat ukusebenzisa uhlelo lwe-Notepad olujwayelekile, olukhona kuzo zonke izinguqulo zamanje ze-Windows.
Izinyathelo zokudala ziyoba kanje.
- Qala i-Notepad (etholakala ezinhlelweni - Izesekeli, ku-Windows 10 ngokushesha ukuqala ngokusesha kubha yomsebenzi, uma kungenayo i-notebook kwimenyu yokuqala, ungaqala ku-C: Windows notepad.exe).
- Faka ku-notepad ikhodi yefayela lakho le-bat (isibonelo, kopisha kusuka kwenye indawo, noma ubhale eyakho, mayelana neminye imiyalo - ngokuqhubekayo ngemiyalelo).
- Emenyu yezintatheli, khetha "Ifayela" - "Gcina njenge", khetha indawo ukuze ulondoloze ifayela, cacisa igama lefayela ne extension .bat futhi, nakanjani, ku "Uhlobo lwefayela" usethe "Wonke amafayela".
- Chofoza "Londoloza."
Qaphela: uma ifayela lingagcinwanga endaweni ecacisiwe, isibonelo, ku-drive C, nomlayezo "Awunayo imvume yokulondoloza amafayela kule ndawo", ulondoloze kufolda yeDokhumenti noma kwideskithophu, bese uyikopisha endaweni oyifunayo ( Isizathu senkinga ukuthi ku-Windows 10, udinga amalungelo omlawuli ukubhala kwamanye amafolda, futhi kusukela ku-Notepad ayengasebenzi njengomphathi, akakwazi ukulondoloza ifayela kwifolda ecacisiwe).
Ifayela lakho le-.bat lilungele: uma uqala, yonke imiyalo efakwe efayeleni izokwenziwa ngokuzenzekelayo (kungabikho amaphutha namalungelo okuphatha adingekayo: kwezinye izimo, kungadingeka usebenzise ifayela le-bat njengomphathi: chofoza ngakwesokudla kwifayili ye-.bat umlawuli kwimenyu yomongo).
Qaphela: esikhathini esizayo, uma ufuna ukuhlela ifayela elidaliwe, mane uchofoze kukho inkinobho yesokudla bese ukhetha "Hlela".
Kunezinye izindlela zokwenza ifayela le-bat, kodwa bonke babilise phansi ekubhaliseni imiyalo eyodwa umyalo ngamunye ngomugqa wombhalo kunoma yimuphi umhleli wombhalo (ngaphandle kokufometha), okulondolozwa nesandiso se-.bat (isibonelo, ku-Windows XP no-32-bit Windows 7, ungadala ngisho nefayela le-.bat emgqeni womyalo usebenzisa umhleli wombhalo (hlela).
Uma unesiboniso sezandiso zefayela enikwe amandla (izinguquko ku-panel control - izinketho zokuhlola - buka - zifihla izandiso zezinhlobo zefayela ezibhalisiwe), khona-ke ungakwazi ukumane udale ifayela .txt, bese uqamba kabusha ifayela ngokubeka isandiso se-.bat.
Vula izinhlelo kufayela le-bat kanye neminye imithetho eyisisekelo
Kufayela le-batch, ungagijima noma yiziphi izinhlelo kanye nemiyalo evela kulolu hlu: //technet.microsoft.com/ru-ru/library/cc772390(v=ws.10).aspx (nakuba ezinye zazo zingase zingekho ku-Windows 8 futhi Windows 10). Ngaphezu kwalokho, ulwazi oluyisisekelo nje lwabasebenzisi besikhombisi.
Imisebenzi ejwayelekile kakhulu yilezi ezilandelayo: ukuqala uhlelo noma izinhlelo eziningana ezivela efayeleni le-.bat, ukuqala umsebenzi othile (isibonelo, ukusula ibhodi lokunamathisela, ukusabalalisa i-Wi-Fi kusuka kwikhompyutha ephathekayo, ukuvala ikhompyutha nge-timer).
Ukuqalisa uhlelo noma izinhlelo sebenzisa umyalo:
qala "" indlela_to_program
Uma indlela iqukethe izikhala, thatha yonke indlela emacaphuni aphindwe kabili, isibonelo:
qala "" "C: Program Files program.exe"
Ngemuva kwendlela yohlelo, ungacacisa nemingcele okufanele iqhutshwe ngayo, isibonelo (ngokufanayo, uma imingcele yokuqaliswa iqukethe izikhala, zibeke kuzicatshulwa):
qala "" c: windows notepad.exe file.txt
Qaphela: kumacaphuno aphindwe kabili emva kokuqala, incazelo kufanele ifake igama lefayela lomyalo elikhonjisiwe kunhlokweni yomugqa womyalo. Le parameter iyakhethwa, kodwa lapho kungekho khona izingcaphuno, ukukhishwa kwamafayela we-bat aqukethe izingcaphuno emigwaqeni nemingcele kungaya ngendlela engalindelekile.
Esinye isici esiwusizo siqala elinye ifayela le-bat kusuka efayeleni yamanje, lokhu kungenziwa ngokusebenzisa umyalo wekholi:
shayela imigomo ye-path_file_bat
Amapharamitha adluliselwe ekuqaleni angafundwa ngaphakathi kwefayela elithile le-bat, isibonelo, sibiza ikhophi ngamapharamitha:
shayela ifayela i-file2.bat parameter1 ipharamitha3
Kufayela2.bat, ungafunda le mingcele bese uwasebenzisa njengezindlela, imingcele yokusebenzisa ezinye izinhlelo ngendlela elandelayo:
beka% 1 echo% 2 echo% 3 isikhashana
Yebo Ipharamitha ngayinye sisebenzisa inombolo yayo yokulandelana ngesignali yamaphesenti. Umphumela kusibonelo esingenhla uzokhipha yonke imingcele edluliselwe iwindi lomyalo (umyalo we-echo usetshenziselwa ukubonisa umbhalo efasiteleni le-console).
Ngokuzenzakalelayo, iwindi lomyalo livala ngokushesha ngemuva kokukhishwa kwayo yonke imiyalo. Uma udinga ukufunda ulwazi ngaphakathi kwewindi, sebenzisa umyalo wokumisa okwesikhashana - kuzoyeka ukukhishwa kwemilayezo (noma vala iwindi) ngaphambi kokucindezela noma yikuphi ukhiye ku-console ngumsebenzisi.
Ngezinye izikhathi, ngaphambi kokwenza umyalo olandelayo, udinga ukulinda isikhathi (isibonelo, ngaphambi kokuba uhlelo lokuqala luqaliswe ngokugcwele). Ukuze wenze lokhu, ungasebenzisa umyalo:
isikhathi sokuhamba / isikhathi_masekhondi
Uma ufisa, ungasebenzisa uhlelo olwenziwe ngendlela encishisiwe noma ividiyo enwetshiwe usebenzisa imingcele ye-MIN ne-MAX ngaphambi kokucacisa uhlelo ngokwalo, isibonelo:
qala "" / MIN c: windows notepad.exe
Ukuvala ifasitela yomyalo ngemuva kokuba yonke imilayezo isetshenziswe (nakuba ivame ukuvala uma usebenzisa ukuqala ukuqala), sebenzisa umyalo wokuphuma emgqeni wokugcina. Uma i-console ingavali ngemuva kokuqala uhlelo, zama ukusebenzisa lo myalo:
cmd / c ekuqaleni / b "" imigomo ye-path_to_programme
Qaphela: kulo myalo, uma uhlelo lwezinhlelo noma imingcele iqukethe izikhala, kungase kube nezinkinga zokuqalisa, ezingasombulula kanje:
ukuqala kwe-cmd / c "" / d "indlela_to_folder_with_spaces" / b Uhlelo_umsebenzisi_amagama "imingcele_nezikhala"
Njengoba sekuphawuliwe, lokhu kuphela ulwazi oluyisisekelo mayelana nemiyalo esetshenziswa kakhulu kakhulu kumafayela we-bat. Uma udinga ukwenza imisebenzi eyengeziwe, zama ukuthola ulwazi oludingekayo kwi-intanethi (bheka, isibonelo, "yenza into emgqeni wokulalelwayo" futhi usebenzise imiyalo efanayo kwifayili ye-.bat) noma ubuze umbuzo kumazwana, ngizame ukusiza.