DOS batch file commands in batches as
If you want to use the computer more easily, I should point out the batch file we recommend to most of the people that makes the batch file DOS environment easily underestimated,
Iran ▶ batch file?
If you look at the state of the operation of the computer, you know that you can always work due to the interaction with the user, there will be a When you enter a command, DOS, the operating system you want the user to analyze the results of running the DOS command.
Therefore, the user always make them on the DOS prompt with the keyboard typing commands, and the command of one floor down until the following command to issue a No Course of action is not much big matter if the process is very long and complicated, but if users feel is boredom. Also annoying is that a short course of action, even when you turn on the computer every time every time through the same process that directs
In this case, the batch file is the most obvious solution.
The features of the batch file of some sequential and repeated the same course of action, or dozens of the associated command hundreds of intensity that one of the files into one file (batch file) by running to perform the desired course of action. Batch file com, exe command the computer attached to the extension bat (batch of abbreviations) is it possible to run DOS from com, exe extension followed by an external command and is classified as an executable file. difference if there is On the other hand, interpreted by the machine code that consists of a batch file that will consist of human-readable plain text.
Users to create your document using a word processor or text editor, such as using a batch file can be created. However, a word processor, Bigger and original made for the purpose of editing and output, so to create a simple batch file would not recommend is
When you attempt to save a unique word processor format (for example, hwp extension using Hangul with data files) is not recognized if it should be saved as an ASCII file. Regular document editor (the most convenient way of DOS Edit Q editor, U editors, etc.) is to create a batch file or DOS command 'Copy Con' state is entered as follows: 'Copy con filename format that can be edited from the DOS prompt and press Enter.
-------------------------------
C: \ Bats> copy con Timedate.bat
cls
time
date
^ Z
1 File (s) copied
-------------------------------
Timely as you want to write here is simply best in the last row ^ Z to the last part of the file that tells the DOS code <Ctrl + Z> key or press the F6 key. '1 File (s) copied 'message and pressing the Enter key once more output, which means just' copy con filename 'is written in the document file was created successfully. Document file with an extension of the above. BAT external executable instructions, which, because the batch file to run the command in the order in which records are stuck because a simple batch file to set the time and date of the system When you first run the timedate.bat to clear the screen nandwi 'copy con written to filename 'can be handled quickly and easily without the help of other programs. But can not be edited from time to time, in case of change during the creation of the batch file is a little long. When you create the file 'copy con filename' may not be able to go back to the row, but it can not be modified. Therefore, when you need to create a batch file using a text editor is recommended.
▶ Create a batch file commands 9 Gang
Batch file is recorded in the file of commands are executed in the order they are most popular to boot, is a Autoexec.bat file located in the root directory of your computer. You non-sequential order of execution of the batch file for a multi-boot like you like Autoexec.bat want to specify the purpose of the batch commands in a batch file need to know.
1 CALL
Needed without shutting down the currently running batch file call another batch file and then running back to the original batch file when you try to use it.
◇ Usage: Call [drive:] \ [path] \ batch filename> [BAT]
◇ example: Call c: \ bats \ sample.bat
Return back to the original batch file and then run the file while running a batch file in the path C: \ bats sample.bat.
2 CHOICE
Placement within the program will be used to ask the user's choice. Waits for keystrokes batch file to set questions as specified authors. This command can be used only within a batch file.
◇ usage: choice [/ C [:] string] [/ N] [/ S] [/ T [:] primary key, wait time] [message]
◇ options
- / C [:] string: a list of keys that the user can select in parentheses [] ',' separated by using the / C switch if you do not basically YN is used.
- / N: Prompt output to avoid.
- / S: from user input in lowercase, uppercase, to distinguish.
- / T [:] primary key, standby time: If during the waiting time, the user's keystrokes after the specified primary key is considered to be the primary key automatically entered and progress. You can specify the wait time in seconds, and is a value between 0 and 99.
- Specifies the message to be printed message on the screen.
◇ example: choice / c: ABCD / s / t: Choose one of the following: C, 5 a, b, C, D
Description: key can be entered for a, b, C, and D with limited input from the user and distinguish between upper-and lower-case alphabetic characters, if considered as key input from the user within 5 seconds If C is entered. And screen
'Choose one of the following: a, b, C, D, [a, b, c, D]? '
The message will be printed.
3 ECHO
During the execution of the batch file command to set whether you want to display on the screen, and which displays its state to the user. On the other hand, the ECHO command followed by a message appears on the screen.
◇ Usage: echo [on / off] [string]
◇ options
On batch file during the execution of the commands in the batch file and displays it on the screen.
Off: batch file during the execution of the command output on the screen to avoid.
- String: the screen you want to print a message on the note.
- None: Displays the status of the current ECHO setting.
◇ example:
echo off
☞ currently running a batch file in the command does not appear on the screen.
echo
echo Hello?
Hello to the terms ☞ current echo setting and display the status of the output on the screen.
4 FOR
Repeat the command set of each of the elements in the specified set of processing run.
◇ usage
For%% variable IN (set of>) DO command <> [<options>] ☞ batch file.
For% variable IN (set of>) DO command> <options>] ☞ for sequential processing.
◇ options
-%> <A variable, and is used as a variable <variable>: arbitrary alphabet of conceit is allowed. Caveat if you use a batch file from the%% like two in a row to use, and available in plain DOS prompt% use only one.
Sets:%% <variable> you want to assign a value to, or separated by a space listed in order of assignment you want to.
- Specifies the command:%% <variable> value is assigned to the command you want to run repeatedly.
- <>: Sets the specified command option or options specified in the FOR command.
◇ example
for%% f in (bak tmp $ $ $) do del *.%% f / p ☞ if the batch file
for% d in (read, wh, file) do hlist% d *. ☞ DOS prompt when running
◇ Description: The first bak, tmp, $ $ $%% f assigned to the environment variable in order to sequentially
DEL *. Bak / p, DEL *. Tmp / p, DEL *. $ $ $. P running the same result as if you get.
Second order in the READ, WH, FILE, in turn, by substituting the environment variable% d
Run HLIS TWH * HLIST FILE *. * As HLIST READ *, the result will be the same.
5 GOTO
Move it to a location that is defined in the batch processing of the flow label> <
◇ usage: Goto label>
◇ example:
goto loop
: Loop
Various treatments to content
Specified in the item Description: The label loop control of batch processing by moving the loop to run to various treatments.
Note: the line with a colon (:) before the name of the batch file to display labels on the label pasted jumyeo
Change must be specified at the beginning.
6 IF
Depending on the result of the judgment of the conditions specified batch processing progress.
◇ Usage: If [NOT] <condition> <command>
◇ options
NOT: The opposite of the conditions specified conditions when running.
- Conditions
ERRORLEVEL figures: just before running the command (exit code of the program) <command> <> figures or more to become true when running.
- <String> <string> string <1> == <string 2>: the same is true only when being <command> is executed. Caveat during a string of upper-and lower-case sensitive string, and if it contains a delimiter (comma, space, semicolon, equal sign, tab).
- EXIST <filename>: <specified filename> file (including the path) exists only when the true and the command> is executed. <Filename> is possible to use a wildcard character.
◇ example:
if errorlevel 2 goto quit
if not% 1 ==% 2 goto process
if exist d: \ work \ temp. $ $ $ del d: \ work \ temp. $ $ $
◇ Description:
On the verge of the exit code of the commands executed if there is more than 2 to go to the label QUIT.
Go to the label only if the string is assigned to the environment variable environment variable% 1% 2 is not equal PROCESS.
Path to D: \ Work temp. $ $ $ If the file exists, delete the file.
7 PAUSE
Pause the batch file to run.
◇ usage: Pause [string]
◇ options
- String: string if you omit the 'press any key to continue ...' message will be displayed on the screen. 'Echo On' command followed by the PAUSE command output by specifying what kind of message the message you want to make the first.
◇ example:
echo on
Press any key to pause when you are ready to ...
Description: when I met the pause command in the batch process any other messages you want to output to the screen, as in the example echo on command must be preceded by a case when you are ready to press any key, please ... ' The message will be printed.
Note: Pause "on the screen, as shown above, the output command, as far as this case, because
echo on
echo When you are ready, press any key ...
pause> Null
When used in this way, you want to display only messages are output to the screen.
8 REM
Used within a batch file when you want to give comments.
◇ Usage: rem [string]
◇ options
Will write down what you want to write as a string: comment.
◇ For example: REM This batch file is a sample.
And paste the appropriate comment it in the proper position within the batch file, the batch processing flow glance you can see.
9 SHIFT
Corresponding to one value of a given parameter in a batch file (% 1 to% 9), and is specified at run-time by moving back.
◇ example
: Loop
if "% 1" == "" goto end
echo% 0% 1% 2% 3% 4% 5% 6% 7% 8% 9
shift
goto loop
: End
Write a batch file as above, run the batch file as follows with some role, shift command can .. I know what
C: \ bats> test.bat ABCDEFGHIJ 0 1 2 3 4 5 ☜ after running the same input and
No comments:
Post a Comment