Location variables for Windows systems
The Windows system location variable is%0%1......%9%*
Example, Test.bat saves this batch to D disk
@echo off
Echo%1%2%3%4
Echo%1
Echo%2
echo%3
Echo%4
Enter D-Disk execution
Test.bat I'm the first argument I'm the second argument I'm the third argument I'm the fourth argument
Output:
I'm the first argument I'm the second argument I'm the third argument I'm the fourth argument
I'm the first parameter.
I'm the second parameter.
I'm the third parameter.
I'm the fourth parameter.
2. There is also a%*
Example
Test.bat
@echo off
Echo%*
Execute Test.bat I'm the first argument I'm the second argument I'm the third argument I'm the fourth argument
Output:
I'm the first argument I'm the second argument I'm the third argument I'm the fourth argument
3. There is also a special%0
%0 This does not return the value of the parameter, he has two layers of meaning
First layer meaning: Returns the right path of the batch processing
Example:
Test.bat
@echo off
Echo%0
Pause
After execution output, the Test.bat path where the
The second layer of meaning: infinite loop execution bat
Example:
@echo off
NET user
%0
After execution, he will loop indefinitely to execute net user This command until you manually stop
Add: In fact,%0 is the argument before the first parameter%1, which is, of course, the batch file name (including the path)