Go and check out course on Udemy for PowerShell:
https://www.udemy.com/course/powershe...
****************************************************************************************
UDEMY : https://www.udemy.com/course/learn-ba...
Title: Batch file programming tutorial // VARIABLES IN BATCH SCRIPT // Batch Scripting Part- 8 - VARIABLES
In this lesson, you will be learning about Variables in Batch Script.
There are two types of variables in batch files. One is for parameters which can be passed when the batch file is called and the other is done via the set command.
Command Line Arguments
Batch scripts support the concept of command line arguments wherein arguments can be passed to the batch file when invoked. The arguments can be called from the batch files through the variables %1, %2, %3, and so on.
The following example shows a batch file which accepts 3 command line arguments and echo’s them to the command line screen.
@echo off
echo %1
echo %2
echo %3
If the above batch script is stored in a file called script.bat and we were to run the batch as
script.bat 4 5 6
The above command produces the following output.
4
5
6
If we were to run the batch as
script.bat 4 5 6 7
The output would still remain the same as above. However, the fourth parameter would be ignored..
The other way in which variables can be initialized is via the ‘set’ command. Following is the syntax of the set command.
Syntax
set /A variableName=value
where,
variableName is the name of the variable you want to set.
value is the value which needs to be set against the variable.
/A – This switch is used if the value needs to be numeric in nature.
The following example shows a simple way the set command can be used.
Example
@echo off
set message=HelloWorld
echo %message%
In the above code snippet, a variable called message is defined and set with the value of "HelloWorld".
To display the value of the variable, note that the variable needs to be enclosed in the % sign.
Output
The above command produces the following output.
HelloWorld
=======================================================
If you have any questions, please post them. Don't forget to comment, like, rate and subscribe
=====================================================
Batch file programming tutorial // CREATE BATCH FILE // Batch Scripting Part-1 -- • Batch file programming tutorial // CREATE ...
Batch file programming tutorial // Batch Scripting Part-2 - Basic Batch Commands -- • Batch file programming tutorial // Batch S...
Batch file programming tutorial // COPY COMMAND // Batch Scripting Part-3 - COPY Batch Command -- • Batch file programming tutorial // COPY CO...
Batch file programming tutorial // DEL COMMAND // Batch Scripting Part-4 - DEL Batch Command -- • Batch file programming tutorial // DEL COM...
Batch file programming tutorial // MOVE COMMAND // Batch Scripting Part-5 - MOVE Batch Command -- • Batch file programming tutorial //MOVE COM...
Batch file programming tutorial // ATTRIB COMMAND // Batch Scripting Part-6 - ATTRIB Batch Command -- • Batch file programming tutorial // ATTRIB ...
Batch file programming tutorial // FIND COMMAND // Batch Scripting Part-7 - FIND Batch Command -- • Batch file programming tutorial // FIND CO...
======================================================
Check out other videos
WEAPONS THAT CAN DEFEAT THANOS -- https://www.youtube.com/watch?v=nvlez
MS PAINT TRICK -- https://www.youtube.com/watch?v=4IvBC
Matrix Effect -- • Matrix Rain Best Trick// Create Matrix Rai...