Вы находитесь на странице: 1из 16

BAT- Windows

command.com
Ms Dos Windows
command.com.
, ().
:

BREAK

CALL

CHCP

CHDIR

CLS

COPY

CTTY
, ..
DATE

DEL

DIR

ECHO

EXIT
command.com
FOR
bat-
GOTO
bat-
IF
bat-
LOADHIGH
MKDIR

PATH

PAUSE

PROMPT

REM

RENAME

RMDIR

SET

SHIFT

TIME

TYPE

VER

VERIFY

VOL

C:\Windows\Command.
Windows // Ms-Dos,
command.com FAR, Norton Commander. cmmand.com
(, SHELL config.sys).
/P ( ) /E ( ) /Y (
), /C ( ), /K (
). /C, , .
Windows.
[:] [\]_. \,
. , c:123.txt 123.txt
, c:\123.txt , DOC\123.txt DOC .
( .) ( .. , - , , . - ). ,
C:\Windows\Media\Office97 autoexec.bat C:
.\autoexec.bat.
* ( - ) ? (
). ,
.
- >
(PRN, COM1 .) . , DIR /? > helpdir.txt DIR
. >> , . <
, ., DATE < date.txt .
, : 1 | 2,
. , MORE
, . TYPE _ | MORE
.

Windows .. (environment
variables). Windows ,
- .
(PATH), Windows (WINDIR),
(TEMP).

SET [=[]]
SET . ( )
%, : %TEMP%.

: ATTRIB, CD, COPY, XCOPY, DIR, MKDIR, RMDIR,
DEL, DELTREE, REN, MOVE, SUBST, VOL, LABEL.
ATTRIB [+R | -R] [+A | -A] [+S | -S] [+H | -H] [[:][]_] [/S]
. Windows 9x 4 :

Read-Onl (R) ;

System (S) ;

Archive (A) ;

Hidden (H) .
+, -. /S
. , Word-
: ATTRIB +R C:\ \*.doc. /
( ).
CHDIR (CD) [:] [\]
CD. , CD \,
CD .., - CD \ . Windows NT /D
, , : CD /D D:\Texts. , Windows NT
CD .\ .
COPY [/A | /B] [/A | /B] [+ [/A | /B] [+ ]]
[ [/A | /B]] [/V] [/Y | /-Y]
.
:


/A
ASCII ( <CTRL>+<Z> )
/B

/
/V

/Y

/-Y

/B , /A ,
.
, :

PRN ,

LPT1-LPT3 ;

AUX , 1;

COM1-COM3 - ;

CON ( , );

NUL ( ).
, COPY abc.txt PRN, COPY CON
my.txt ( <CTRL>+<Z>).
COPY () * ?
(COPY /B *.dat all.dt) + (COPY /B 1.txt+2.txt 3.txt). /B
, .. .
COPY ,
Read Only, () (
). XCOPY.
XCOPY [/A | /M] [/D[:]] [/P] [/S [/E]] [/W] [/C] [/I] [/Q] [/F] [/L] [/H] [/R] [/T] [/U] [/K] [/Y | /-Y]
XCOPY ( ).
:

/A
XCOPY :\A\*.* D:\B
. .
/A
/M

. .
/D
, XCOPY
C:\MY\*.*
. D:\BACKUP /D

.
( ), /EXCOPY C:\A\*.* D:\B

/S /E
/W

/C

/I
, XCOPY *.txt TEXT /I
. ,
..
/V (9x)

/P

/Q, /F, /L
, /L
, /F
/G (2000)
,

/H
( )
/R
,

/T
( )
.
- /T /E.
/U
,

/K
" " (
)
/N

/O (NT)
ACL
/X (NT)
( /O)
/Y /-Y
()

/Z (NT)

/EXCLUDE:1[+2]

XCOPY *.txt D:\TeXT


(NT)

/EXCLUDE:1.xtx
XCOPY ERRORLEVEL (. . )
() (0 , 1 , 2 <CTRL>+<C>, 4
, , 5 ).
DIR [:][][_] [/A[[:]]] [/B] [/C] [/D] [/L] [/N] [/O[[:]]] [/P] [/Q] [/S] [/T[[:]]] [/W] [/X]
[/4]
. , (
) , ,
. ,
. DIR ,
:

/A
(D-, A, R, S, H .DIR C:\ /A:HS
- .
/B
( /W)
/C

(
). /-C.
/D (NT)
/L

/N

/O
( "-" ):
DIR /O:N

N - ()

S - ( )

E - ()

D - ( )

G -

A ( )
,
.
/P

/Q (NT)
/V (9x)

/S

/T
:

C
/S


A -

W -
/W

/X
,

8.3
/4 (9x)

DIRCMD.
"-", : /-W. DIR ( ) -
( > >>), :
DIR C:\ /W/O:N > PRN
.
MKDIR (MD) [:]
RMDIR (RD) [:]
. MKDIR
, , RMDIR .
Windows NT (RD /S), MD \A\B\C\D.
DEL [:][]_ [/P]
ERASE [:][]_ [/P]
. /P ( DEL
*.* DEL . ). Windows NT
(/F), (/S), (/Q), ,
(/A:).
DELTREE [/Y] [:]
. /Y
.
RENAME (REN) [:][][1 |1] [2 | 2]
. DEL * ?,
: REN *.txt *.doc.
MOVE.
MOVE [/Y | /-Y] [:][]_1[,] _
MOVE [/Y | /-Y] [:][]1 2
.
SUBST [1: [2:]]
. (
CD). : SUBST F: C:\INSTALL\DELPHI5. /D
: SUBST F: /D. SUBST (
).
VOL [:]
LABEL [:][]
.
bat-
() Windows 9x bat,
, ( ) .
, deltmp.bat Windows\Temp:
C: \
CD %TEMP%
ATTRIB R *.tmp
DEL *.TMP
:
ECHO []
(, ..). , ECHO !
> hi.txt .
, .
ECHO OFF . ECHO ON
. , , @. ,
, ECHO. ( ).
@ECHO OFF
ECHO !
ECHO.
ECHO
,
.
%0 , %1-%9
. , copier.bat :
@ECHO oFF
CLS
ECHO %0 %1 %2

XCOPY %1 %2 /S
2 :
copier.bat C:\Programs D:\Backup
copier.bat C:\Programs D:\Backup
.
SHIFT,
%0 %9, . %1
%0, %2 %1 .., 10 %9. , SHIFT, ,
.
,
SET. Windows 9x
( NT), ( 2 +). ,
:
SET A=
SET B=
SET C=%A%%B%
ECHO =%%
=.
, , ,
.
, , <CTRL> +<C> <CTRL>+<Break> ( Windows
NT EXIT /B). PAUSE,
. :
ECHO C:\
ECHO Ctrl-C
PAUSE
DEL C:\ \*.*
:
FOR %% IN () DO []
, ,
. ,
, . :
@ECHO OFF
FOR %%i IN (, , ) DO ECHO %%i
:

, .
( begin end), , .
. ,
*.doc *.txt:
FOR %%f IN(C:\TEXT\*.doc C:\TEXT\*.prn) DO ECHO %%f >> list.txt
.
, CALL,
. , proc.bat:
@ECHO OFF
ECHO %1.txt
ECHO : %1 > %1.txt
:
FOR %%i IN (, , ) DO CALL proc.bat %%i
proc.bat 3 3 . txt, . txt .txt .
, (:) GOTO .
, . :
@ECHO OFF
GOTO Label1
ECHO
:Label1
REM
DIR
C IF 3 :
1) IF [NOT] 1==2
( 2 ) (
). ( ) .
:
IF %1%== ECHO , !
,
- , :

IF -%MyVar%==-C:\ ECHO OK !
IF [NOT] EXIST
( , ). :
IF NOT EXIST C:\autoexec.bat ECHO !
IF EXIST C:\ \.doc ECHO !
3) IF [NOT] ERRORLEVEL
, ,
. :
xcopy my.txt c:\ > nul
IF errorlevel 1 goto ErrOccurred
echo .
goto EndBatch
:ErrOccurred
echo !
:EndBatch

. CHOICE,
.
CHOICE [/C[:]] [/N] [/S] [/T[:]c,nn] []
, .
:


/
, YN
CHOICE /C:ync ? Yes, No, Cancel [Y, N, C] ?
/N
(CHOICE /N

)
/S
(
)
/T
c , CHOICE /c:ync /t:N,10
[Y, N, C] ?
nn
( 10 N)
CHOICE ERRORLEVEL , ,
IF . , CHOICE 255,
<CTRL>+<C> < CTRL >+<Break> - 0. :
@ECHO OFF
ECHO
ECHO 1 -
ECHO 2 -
ECHO.
CHOICE /c:12
IF ERRORLEVEL 2 goto Choice2
IF ERRORLEVEL 1 goto Choice 1
ECHO
GOTO Done
:Choice1
ECHO 1
GOTO Done
:Choice2
ECHO 2
GOTO Done
:Done
2)

Windows NT-XP
Windows NT command.com
MS-Dos ( ) Windows NT
cmd.exe (%SytemRoot%\System32).
// ,
FAR cmd.exe . cmd.exe ,
command.com /C, /K, . /X /Y
( ).
, Windows 9x, SET.
, , , .
, , SET .
.
/:
SET / =
/ , ,
.
,

SET / =1+2
M .
, SET, ,
:

();

(*), (/), (%);

(+) (-);

(<<) (>>);

(&);

();

(|);

=*, =/, =%, =+, =-, =, &=, ^=, |=, <<= >>=;

(,).
.
0x -16, 0b - 2, 0 - 8.
, .
, . ,
X ,
SET /A N=X+5
N .
, /
, % . ,
( ).
Windows NT, Windows 9x, ,
, : bat cmd.
SETLOCAL, ENDLOCAL, PUSHD, POPD, a GOTO, CALL, IF, FOR.
Windows NT , . .
, .
SETLOCAL , .. ,
SETLOCAL, .
SETLOCAL ENDLOCAL
.
%*,
:

%~Fn
%~F1=C:\TEXT\.doc
%~Dn

%~D1=C:
%~Pn

%~P1=\TEXT\
%~Nn

%~N1=
%~Xn
%~X1=doc
:EOF,
. - (GOTO :EOF).
CALL (
).
, .
( ,
CALL, ).
IF:
1) IF [/I] 1 _ 2
_ : EQL , NEQ , LSS , GTR , LEQ
, GEQ . /I .
2) IF CMDEXTVERSION
( 2000 XP - ?)
3) IF DEFINED
, .
Windows NT FOR, :
1) FOR /D % IN () DO []
,
C:
FOR /D %%f IN (C:\) DO ECHO %%f
2) FOR /R [[:]] % IN () DO []
, .
, *.txt:
FOR /R %%f IN (*.txt) DO PRINT %%f
3) FOR /L % IN (,,) DO []
( , ). :

FOR /L %%f IN (1,1,5) DO ECHO %%f


FOR /F [] % IN () DO []
. ()
(DELIMS) .
5) FOR /F [] % IN () DO []
(
). , :
FOR /F DELIMS== %%i IN (SET) DO ECHO %%i
, FOR ( , , . ).
PUSHD POPD .
:
PUSHD [ | ..]
, PUSHD, POPD.
4)

1. protokol.txt, :
< > <> <>
.
, (. .
) () () -.txt,
. .
:
FIND SORT:
@ OFF
R
IF -%1==- GOTO NoParam
IF -%2==- GOTO NoParam
REM protokol.txt
FIND "%1.%2" protokol.txt | SORT /+26 > %l%2.txt
GOTO End
:NoParam
ECHO He !
PAUSE
:End
2. , txt,
, , , .
, , ,
.
:
txt,
:
@ OFF
REM
IF -%!==- GOTO NoDir
R
FOR %%f IN (*.txt) DO IF NOT -%%f==-%2 COPY %%f %1
GOTO End
:NoDir
ECHO He !
PAUSE
:End
3. . :
) , - ,
) ,
) logcopy.txt .
, logcopy.txt :
: .txt
: b.txt
: .txt
:
. FOR,
, COPY
3_1. bat:

@ OFF
REM
IF -%1==- GOTO NoDir
REM 3_l.bat
FOR %%f IN (*.txt) DO IF NOT -%%f=-%2 CALL 3_l.bat %%f %1
GOTO End
:NoDir
ECHO He !
PAUSE
:End
3_1.bat :
@ OFF
REM
XCOPY %1 %2 /D / > NUL
REM
IF ERRORLEVEL 0 GOTO Success
REM
ECHO : % 1 >> logcopy.log
GOTO End
:Success
REM
ECHO : %1 >> logcopy.log
:End
4. , , ,
:

), c:\catalog.txt .
:
:
@ OFF
CLS
IF -%1==- GOTO NoDir
R
ECHO A -
ECHO - C:\catalog.txt
ECHO -

CHOICE /:A %1
CLS

IF ERRORLEVEL 3 GOTO DirToPrn
IF ERRORLEVEL 2 GOTO DirToFile
IF ERRORLEVEL 1 GOTO DirToCon
ECHO .
GOTO End
:DirToCon
DIR %1 | MORE
GOTO End
:DirToFile
DIR %1 > C:\catalog.txt
GOTO End
:DirToPrn
DIR %1 > prn
GOTO End
:NoDir
ECHO He !
PAUSE
:End

bat- (. ).
, , (
/?), ,
. , . , ,
. ,
, .

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15

. .
.
.
() . .
- (drwebw.exe).
(notepad, ncedit .)
. .
( )
. - .

, . -
.
. ,

( )
: *.BAK, *.TMP .
.
( , , ) . , - .
,
.
.
(*.doc, *.txt)
(*.doc, *.txt)

(*.doc, *.txt) (
).

1. Ms-Dos: , -, 2001, 382 .


2. MS-DOS 6.22: , , 2001, 224 .
3. . Ms-Dos : , , 1993, 160 .
4. ., . MS-DOS 6.2 , , BHV, 1994, , , 1994.
5. . IBM PC , ., , 1993.
6. MS DOS:. ./ ., .-., .;
. ..-.: ,1995.-544.

bat
- .

:test
if exist c:\1.txt goto go
sleep 10
goto test
:go
notepad
10 1.txt 1.txt

, , go, .. .
1.txt -, ,
, . , -
1.txt .

:test
if exist c:\1.txt goto go
sleep 10
goto test
:go
rename c:\1.txt 1.txt
if not errorlevel 0 goto go
del c:\1.txt
1.txt , ,
, .
, rename c:\1.txt 1.txt (.. ),
. .
MS DOS
(*.bat-)
(Batch-) ,
MS DOS , .
- MS DOS.
(ASCII-) , ASCII-.
- , IBM PC (,
COMMAND.COM).
- .BAT.
. , -
:
- , ,
- , ,
- (, )
, , :
E:
CD E:\ZARPEXE
MAINZR CreatDir
, ,
- ( , ) ,
, C:\Zarp.bat.
- . ,
MS DOS Zarp.bat( Zarp). MS DOS
, .
. .
, :
- 5.25( 1.2 ) 360
- MS DOS
- A:\NC
- C:\NC
,, , , - ,
.
(C:\MyWrk.bat) :
echo A: Enter
pause
format A: /t:40/n:9
sys A:
md A:\NC
copy c:\nc\*.* a:\nc
.
, .
:

echo A: Enter
echo - , , .
:
pause
pause - , :
Press any key to continue ...
( - ...) -
.
- (format), MS DOS(sys), (md),
(copy).
- , . MS DOS,
,
.
, :
% - ,
: -
CALL - ,
CLS - ,
ECHO - ,
EXIT - ,
EXIST- ,
FOR .. IN .. DO - MS DOS,
GOTO - ,
IF - ,
PAUSE- ,
REM - ,
SHIFT- ( 10 ).

! SHIFT - .
:
1. , :
- 1.44 ( B: 1.44)
- : B:\ARC
- - ARJ.exe - C:\TEMP\ZZZ.arj,
F:\LIBRARY
- B:\ARC - C:\TEMP\ZZZ.arj
CLS
echo
echo .
echo B: Enter
pause
format B:
md B:\ARC
F:
CD F:\LIBRARY
rem -
ARJ A -R C:\TEMP\ZZZ.arj
copy c:\temp\zzz.arj b:\arc
del c:\temp\zzz.arj
2. , :
- C:\LEX\F1.txt
- 2 C:\LEX\F1.txt : 1 : A:\RRR 2 : B:\RRR
- C:\LEX\F1.txt
- C:\LEX\F1.txt
CLS
echo A:,B: Enter
pause
rem C:\LEX

MD C:\LEX
C:
CD C:\LEX
rem C:\LEX\F1.txt
del C:\LEX\F1.txt
rem
LEX C:\LEX\F1.txt
md A:\RRR
md B:\RRR
rem
copy c:\lex\f1.txt a:\rrr
copy c:\lex\f1.txt b:\rrr
rem
copy c:\lex\f1.txt PRN
rem c:\lex\f1.txt
del c:\lex\f1.txt
:
3. , :
5.25( 1.2 ) 360 1.2 , ,
.
, : FFF.bat
, , :
FFF
1.2
, , :
FFF X
360
- :


echo A: Enter
pause
rem , 1 ?
if %1.==. GOTO L12
GOTO L360
:L12
rem 1.2 .
format A:
GOTO L_EXIT
:L360
rem 360 .
format A: /F:360

:L_EXIT
rem ()
4. , :
, ( ) .
.
- :


echo off
echo : %1
if EXIST %1 goto L1
GOTO L2
:L1
echo %1
GoTo LE
:L2
echo %1
:LE
pause
5. , :
, 2 . :
?
- .
- :


echo off
echo : %1
if %1.==. goto LERR
GOTO LSTART
:LERR
echo : !!!
GOTO LE
:LSTART
if EXIST %1 goto L1
GOTO L2
:L1
echo %1
GoTo LE
:L2
echo %1
:LE
pause
6. , :
,
.
:
- ,
- .
- , -
.
, (A1.bat). A2.bat
A1.bat
N 2
( : A2.bat)
if EXIST %1 goto L1
GOTO L2
:L1
echo %1
GoTo LE1
:L2
echo %1
:LE1
N 1
( : A1.bat)

echo off
CLS
echo : %1
if %1.==. goto LERR
GOTO LSTART
:LERR
echo : !!!
GOTO LE
:LSTART
CALL A2 %1
:LE
pause
7. , :
TYPE , TXT, PAS, ASM.
:
FOR .. IN .. DO

CLS
for %%A in (*.txt *.pas *.asm) do type %%A
pause

1. , "MS-DOS 6.2 ... ", , BHV, 1994, , , 1994.
2. "DOS 3.3. ". .
3. .. IBM PC ., , 1993 .
4. IBM PC. . 1 2. . . 1991 .
5. .. . . , 1990 .
6. .., .., .. " ". 1. ., , 1991
.