I need the .bat file variables explanation? How to use the variables in bat file, How to pass variables between batch files? Thanks in advance for help.
I need the .bat file variables explanation? How to use the variables in bat file, How to pass variables between batch files? Thanks in advance for help.
By using the below code you can output as many many variables as you like:
CProgram]
#include
main() {
printf("BatchFile.bat %d",ReturnValue);
}
[End CProgram][BatchFile.bat]
@echo off
if not (%1)==() goto Var
echo @echo off >tmp.bat
CProgram.exe >> tmp.bat
tmp.bat
:Var
set XVar=%1;
del tmp.bat
[End BatchFile.bat]
Special variables in Windows Batch files
rem special variables for batch files
@echo off
echo fully qualified name of this batch file:
echo %~fn0
echo path to here:
echo %~dp0
echo arguments passed (if any):
echo %*
In DOS batch files, you can create and use variables. The variables are expressed using the percentage symbol followed by a number. For example, look at the following batch file, which I will call test.bat:
This is a very simple batch file, but here is how you can use. At the prompt, type (I'm assuming you are working in the folder C: \ DOSTEMP \ working directory):@Echo off
dir% 1
If you have done correctly, you should see a complete directory listing in the root directory of C: What is the batch file to take the command DIR and its application to any specified directory. If you neglect to specify a directory, you will get a listing of the current working directory (C: \ DOSTEMP \), as if he had given a DIR command, without specifying the destination directory. If you specify a directory on the command line, which is the directory variable 1, or 1%. Now, I suppose, that had issued the command:c:\dostemp\>test.bat c:\
If you try this, you will see that you still get the list of the root directory of C:, but only that. After all, your batch file is looking for a variable, and the DIR command can have only one directory.c:\dostemp\>test.bat c:\ c:\windows\
Bookmarks