1. Lệnh Ping : Cú pháp: Code: ping ip/host [/t][/a][/l][/n]



tải về 1.67 Mb.
Chế độ xem pdf
trang33/92
Chuyển đổi dữ liệu18.05.2022
Kích1.67 Mb.
#52014
1   ...   29   30   31   32   33   34   35   36   ...   92
Cac lenh co ban trong DOS

 
Echo
text into a FILE
The general syntax is 
Echo This is some Text > FileName.txt
or if you want to avoid extra spaces:
Echo Some more text>FileName.txt
Echo a Variable
To display a department variable: 
ECHO %_department%
An alternative is to separate with

instead of a space, this has some 
performance benefits

ECHO:%_department%
If the variable does not exist - ECHO will simply return the text "%_department%" 
This can be extended to search and 
replace
 parts of a variable or display 
substrings
 of a 
variable. 
Echo a file
Use the 
TYPE
 command. 


Echo a sound
The following command in a batch file will trigger the default beep on most PC's 
ECHO (^G) 
To type the 
BELL
 character use Ctrl-G or 'Alt' key, and 7 on the numeric keypad. (
ascii
 7) 
Alternatively using Sound Recorder or Media Player: 
START/min sndrec32 /play /close %windir%\media\ding.wav 
START/min mplay32 /play /close %windir%\media\ding.wav
 
Echo a blank line
The following in a batch file will produce an empty line: 
Echo.
or 
Echo(
The second option is better, because 
Echo.
will search for a file named "echo" if this file does 
not exist the command does work, but this makes it slower than
echo(
To ECHO text 
without
including a CR/LF (
source

 
Echo
text into a stream 
Streams allow one file to contain several separate forks of information (like the macintosh 
resource fork)
The general syntax is 
Echo Text_String > FileName:StreamName 
Only the following commands support the File:Stream syntax - ECHO, MORE, FOR 
Creating streams: 
Echo This is stream1 > myfile.dat:stream1
Echo This is stream2 > myfile.dat:stream2
Displaying streams: 
More < myfile.dat:stream1
More < myfile.dat:stream2 
FOR /f "delims=*" %%G in (myfile.dat:stream1) DO echo %%G 
FOR /f "delims=*" %%G in (myfile.dat:stream2) DO echo %%G 
A data stream file can be successfully copied and renamed despite the fact that most 
applications and commands will report a zero length file. The file size can be calculated from 
remaining free space. The file must always reside on an NTFS volume. 
ECHO is an 
internal
 command. 
“The only thing that helps me pass the time away; is knowing I'll be back at Echo Beach some 
day” ~ Martha and the Muffins 
ENDLOCAL
 
End localisation of environment changes in a batch file. Pass variables from one batch file to 
another. 
Syntax 
ENDLOCAL 
If 
SETLOCAL
 is used to make variables 'local' to one batch script, then those variables will be 
invisible to all other batch scripts unless explicitly passed using an 
ENDLOCAL & 
SET...
command. 


If SETLOCAL is used without a corresponding ENDLOCAL then local environment variables will 
be discarded when the batch file ends. Ending the cmd.exe session will discard all Environment 
Variables both local and global. 
If a batch script does not use SETLOCAL or ENDLOCAL then all variables will be Global, i.e. 
visible and modifiable from other calling scripts or on the command line after the script has 
completed.
"A good place to visit, but a poor place to stay" - Josh Billings 
EXIT
 
Quit the current batch script, quit the current subroutine or quit the command processor 
(CMD.EXE) optionally setting an errorlevel code. 
Syntax 
EXIT [/B] [exitCode
Key 
/B When used in a batch script, this option will exit
only the script (or subroutine) but not CMD.EXE 
exitCode Sets the %ERRORLEVEL% to a numeric number. 
If quitting CMD.EXE, set the process exit code no. 
You should never attempt to directly write to the %er
rorlevel% variable, (i.e. don’t try anything 
like SET errorlevel...) using the EXIT command provides a safe way to alter the value of the 
built-in errorlevel variable. Unlike 
goto:eof
 the Exit /b command allows you to set a specific 
errorlevel. 
 “Making music is not about a place you go. It‟s about a place you get out of. I‟m underwater 
most of the time, and music is like a tube to the surface that I can breathe through. It‟s my air 
hole up to the world. If I didn‟t have the music I‟d be under water, dead” - Fiona Apple 
EXPAND
 
Uncompress one or more compressed files. 
Syntax 
EXPAND Source Destination 
EXPAND -r Source Destination 
EXPAND -r Source 
Options 
Source : Source filename or a wildcard 
Destination : Destination filename or folder 
-r : Rename the files 
EXPAND
 
Uncompress one or more compressed files. 
Syntax 
EXTRACT [optionsCAB_file [filenames
Key 
CAB_file : Cabinet file 


filenames : Name of the file to extract from the cabinet 
Wild cards (*.*) (.) and multiple files are valid 
options 
/A Process ALL cabinets. (where CABs are linked) 
/C If the CAB contains one file then /C will 
copy from DMF disks 
/D Display CAB directory 
/E Extract all (use instead of *.* to extract all files) 
/L dir Location to place extracted files (default is current 
folder) 
/Y Overwrite files without any prompt 
FC.exe
 
Compare the contents of two files or sets of files. Display any lines which do NOT match. 
Syntax 
FC /B pathname1 pathname2 
FC [optionspathname1 pathname2 
Key 
/B : Perform a binary comparison. 
options 
/C : Do a case insensitive string comparison 
/A : Displays only first and last lines for each set of 
differences. 
/U : Compare files as UNICODE text files. 
/L : Compares files as ASCII text. (default) 
/N : Display line numbers (ASCII only) 
/LBn: Limit the number of lines that will be read, "n" sets a 
maximum number 
of mismatches after which the File Comparison will abort 
(resync failed) 
When FC aborts (resync failed) then "n" number of mismatches 
will be shown.
/nnnn : Specify a number of consecutive lines that must match after 
a mismatch. 
This can be used to prevent the display of the two files 
from getting
too out of sync 
/T : Do not expand tabs to spaces. 
/W : Compress white space (tabs and spaces) for comparison. 
To compare sets of files, use wildcards in pathname1 and pathname2 parameters. 
Powershell also has an Alias 
FC
for the 
Format-Custom
 cmdlet, therefore to run the 'old' FC 
under powershell you need to explicitly run C:\windows\system32\fc.exe 
To identify 2 identical files use this syntax: 
FC file1.txt file2.txt | FIND "FC: no dif" > nul
IF ERRORLEVEL 1 goto :s_files_are_different 

tải về 1.67 Mb.

Chia sẻ với bạn bè của bạn:
1   ...   29   30   31   32   33   34   35   36   ...   92




Cơ sở dữ liệu được bảo vệ bởi bản quyền ©hocday.com 2024
được sử dụng cho việc quản lý

    Quê hương