Yuav ua li cas los tsim cov ntaub ntawv roj hauv qhov rais

Feem ntau, cov tswv yim rau kev ua haujlwm thiab kho hauv qhov rais 10, 8, thiab Windows 7 muaj xws li cov kauj ruam xws li: "tsim ib cov ntaub ntawv .bat nrog cov lus hauv qab no thiab khiav." Txawm li cas los xij, cov neeg siv novice yeej tsis paub tias yuav ua qhov no li cas thiab seb cov ntaub ntawv puas muaj tseeb.

Cov ntaub ntawv nyeem no yuav ua li cas los tsim cov lus sib dhos puav, nws khiav, thiab qee cov ntaub ntawv ntxiv uas yuav pab tau rau lub ntsiab lus ntawm nqe lus nug.

Tsim cov ntaub ntawv .bat nrog notepad

Txoj kev thawj thiab yooj yim tshaj plaws los tsim cov ntaub ntawv roj yog siv Tus Txheej Txheem Qhia Ntawv, uas yog tam sim no nyob rau hauv tag nrho versions tam sim no hauv Windows.

Cov kauj ruam creation yuav ua raws li nram no.

  1. Pib hauv Cov Kev Pab Cuam - Hauv Xws Li, Qhov Khoos Kas Hauv Xws Li 10 yog pib ceev los ntawm kev tshawb fawb hauv lub kaspivtaw, yog tias tsis muaj phau ntawv sau rau hauv Start menu, koj tuaj yeem pib ntawm C: Windows notepad.exe).
  2. Nkag mus rau hauv daim ntawv teev cov cim ntawm koj cov ntaub ntawv roj (piv txwv, luam ntawm qhov chaw, lossis sau koj tus kheej, txog qee cov lus txib - ntxiv hauv cov lus qhia).
  3. Nyob rau hauv cov ntawv qhia zaub mov, xaiv "File" - "Txuag Li", xaiv qhov chaw khaws cov ntaub ntawv, hais kom meej rau cov ntaub ntawv lub npe nrog tus extension .bat thiab, ntawm chav kawm, "File type" set "All files".
  4. Nyem "Txuag."

Ceebtoom: Yog tias cov ntaub ntawv tsis raug cawm mus rau qhov chaw uas tau teev tseg, piv txwv li, ntawm tsav C, nrog cov lus "Koj tsis muaj cai tso tseg cov ntaub ntawv hauv qhov chaw no", muab khaws cia rau cov ntaub ntawv ceev lossis hauv lub desktop, thiab muab luam mus rau qhov chaw txaus siab ( Vim li cas rau qhov teeb meem ntawd yog nyob rau hauv lub Xya 10, koj xav tau tus neeg khiav dej num txoj cai sau rau ib co folders, thiab txij thaum Notepad tsis khiav raws li ib tug neeg khiav dej num, nws yuav tsis txuag tau cov ntaub ntawv mus rau qhov sau tseg kev ceev).

Koj cov ntaub ntawv .bat yog npaj txhij: Yog tias koj pib, txhua nqe lus txib teev hauv cov ntaub ntawv yuav raug cia tseg (piv txwv tias tsis muaj kev yuam cai thiab kev tswj hwm cov cai: qee zaus, koj yuav tsum khiav ntaub ntawv raws li tus neeg khiav dej num: txoj cai-nias rau ntawm .bat ntaub ntawv - khiav raws li tus neeg khiav dej num hauv cov ntawv qhia zaub mov).

Lus Cim: nyob rau hauv lub neej yav tom ntej, yog tias koj xav hloov cov ntaub ntawv tsim, cia li nyem rau ntawm nws txoj kev nas khawm thiab xaiv "Hloov".

Muaj lwm txoj hau kev ua rau cov ntaub ntawv roj, tab sis lawv tag nrho yuav rhuav kom sau cov lus txib ib kab rau ib phau ntawv sau rau hauv cov ntawv nyeem (tsis muaj formatting), uas yog tom qab ntawd tau txais kev cawmdim nrog .bat ncua (piv txwv, hauv Windows XP thiab 32-ntsis qhov rais 7, koj muaj peev xwm txawm tsim ib cov ntaub ntawv .bat rau ntawm kab hais kom siv cov ntawv nyeem (hloov).

Yog hais tias koj muaj cov zaub ntawm extensions cov ntaub ntawv enabled (hloov rau cov tswj vaj huam sib luag - explorer xaiv - saib - nkaum qhov extensions ntawm cov ntaub ntawv hom ntaub ntawv), ces koj tuaj yeem tsim cov ntaub ntawv .txt, ces rename cov ntaub ntawv los ntawm qhov chaw.

Khiav cov kev pab cuam hauv cov ntaub ntawv roj thiab lwm cov lus txib yooj yim

Nyob rau hauv cov ntaub ntawv batch, koj tuaj yeem khiav cov kev pab cuam thiab cov lus txib ntawm daim ntawv: //technet.microsoft.com/ru-ru/library/cc772390(v=ws.10).aspx (tab sis qee qhov no yuav ploj mus hauv qhov rais 8 thiab Qhov rai 10). Tsis tas li ntawd xwb, tsuas qee cov lus qhia yooj yim rau cov neeg siv novice.

Cov haujlwm tseem ceeb tshaj plaws yog cov hauv qab no: pib tsim ib qho kev pab cuam los yog ntau qhov kev zov me nyuam los ntawm ib qho ntaub ntawv .bat, tso qee cov kev ua haujlwm (piv txwv, tshem cov ntawv teev cia, faib Wi-Fi ntawm lub laptop, kaw lub computer thaum timer).

Txhawm rau ib qho kev pab cuam los yog cov kev pab cuam siv qhov lus txib:

pib "" path_to_program

Yog tias txoj kev muaj qhov chaw, coj tag nrho cov kev hauv ob chav quotes, piv txwv li:

pib "" "C:  Program Files  program.exe"

Tom qab qhov kev pab cuam, koj tuaj yeem qhia qhov tsis nrog qhov uas nws yuav tsum tau khiav, piv txwv (piv txwv li, yog qhov kev tshaj tawm tsis muaj chaw, muab tso rau hauv nqe lus):

pib "" c:  windows  notepad.exe file.txt

Lus Cim: hauv ob chav quotes tom qab pib, qhov kev qhia tshwj xeeb yuav tsum muaj lub npe ntawm cov ntaub ntawv hais kom ua nyob hauv kab lus hais kom ua. Qhov no parameter yog xaiv tau, tab sis thaum tsis muaj cov quotes, kev tua cov ntaub ntawv roj muaj quotes hauv paths thiab tsis tuaj yeem mus ua ib qho kev npaj txhij txog.

Lwm tus feature feature yog pav tua lwm cov ntaub ntawv roj los ntawm cov ntaub ntawv tam sim no, qhov no yuav ua tau siv cov lus txib hu:

hu rau path_file_bat tsis

Cov kev tsis dhau ntawm pib yuav nyeem tau hauv lwm cov ntaub ntawv roj, piv txwv li, peb hu rau cov ntaub ntawv nrog tsis:

hu rau file2.bat parameter1 parameter2 parameter3

Nyob rau hauv file2.bat, koj tuaj yeem nyeem cov cwj pwm no thiab siv lawv li cov paths, tsis tau khiav lwm cov kev pab cuam hauv qab no:

Noog% 1 ncha% 2 ncha% 3 pause

Ie rau txhua tus parameter peb siv nws cov lej sib lawv liag nrog ib qho feem pua. Qhov tshwm sim nyob rau hauv qhov piv txwv saum toj no yuav ua rau tag nrho cov kev tsis dhau rau qhov kev hais kom ua rau lub qhov rais (qhov hais kom ua echo siv los tso saib cov ntawv hauv lub qhov rais).

Yog vim li cas, qhov kev hais kom ua qhov rai kaw tam sim ntawd tom qab kev tua ntawm tag nrho cov lus txib. Yog tias koj xav nyeem cov ntawv hauv lub qhov rai, siv qhov kev hais kom nres - nws yuav nres qhov kev ua tiav ntawm cov lus txib (los yog kaw qhov rais) ua ntej nias txhua qhov tseem ceeb hauv tus neeg siv.

Qee lub sij hawm, ua ntej ua raws li cov lus txib tom ntej, koj yuav tsum tau tos qee lub sijhawm (piv txwv li, ua ntej thawj qhov kev kawm pib tag nrho). Ua li no, koj tuaj yeem siv qhov kev hais kom ua:

timeout / t time_in seconds

Yog tias koj xav, koj tuaj yeem khiav cov kev pab cuam hauv daim ntawv qis dua lossis ntxiv cov duab siv MIN thiab MAX cov kev ntsuas ua ntej los qhia meej txog qhov kev pab cuam, xws li:

pib "" / MIN c:  windows  notepad.exe

Txhawm rau kaw cov lus txib tom qab tag nrho cov lus txib raug tua (txawm tias nws tau kaw thaum siv pib pib), siv qhov kev tawm hauv qhov kawg. Yog tias lub console tseem tsis kaw tom qab pib qhov program, sim siv cov lus txib no:

cmd / c pib / b "" path_to_programme tsis

Lus Cim: hauv qhov kev hais kom ua no, yog tias qhov kev zov me nyuam paths los sis tsis muaj qhov chaw, yuav muaj teeb meem tawm, uas tuaj yeem daws tau li no:

cmd / c pib "" / d "path_to_folder_with_spaces" / b program_file_name "parameters_with_spaces"

Raws li tau hais lawm, qhov no tsuas yog cov ntaub ntawv yooj yim heev txog kev siv ntau tshaj plaws hauv cov ntaub ntawv roj. Yog tias koj xav tau kev pabcuam ntxiv, sim nrhiav cov ntaub ntawv tsim nyog rau hauv Internet (saib, piv txwv, "ua ib yam dab tsi ntawm kab lus qhia" thiab siv tib cov lus txib hauv file .bat) lossis nug cov lus hauv cov lus, Kuv yuav sim pab.