Go and check out course on Udemy for PowerShell:
https://www.udemy.com/course/powershe...
Title: BATCH SCRIPTING// IF/ELSE CONDITION // Batch Scripting Part 17 IF/ELSE CONDITION
In this lesson, you will be learning about IF/ELSE CONDITION for Batch Script.
IF/ELSE CONDITION: The next decision making statement is the If/else statement. Following is the general form of this statement.
If (condition) (do_something) ELSE (do_something_else)
The general working of this statement is that first a condition is evaluated in the ‘if’ statement. If the condition is true, it then executes the statements thereafter and stops before the else condition and exits out of the loop. If the condition is false, it then executes the statements in the else statement block and then exits the loop.
@ECHO OFF
SET /A A = 5
SET /A B = 10
SET /A C = %A% + %B%
IF %C%==15 (ECHO "VALUE IS CORRECT") ELSE (ECHO "WRONG")
IF %C%==10 (ECHO "VALUE IS CORRECT") ELSE (ECHO "WRONG")
PAUSE
The key thing to note about the above program is −
Each ‘if else’ code is placed in the brackets (). If the brackets are not placed to separate the code for the ‘if and else’ code, then the statements would not be valid proper if else statements.
In the first ‘if else’ statement, the if condition would evaluate to true.
In the second ‘if else’ statement, the else condition will be executed since the criteria would be evaluated to false.
Output
The above command produces the following output.
"VALUE IS CORRECT"
"WRONG"
=======================================================
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 // CR...
Batch file programming tutorial // Batch Scripting Part-2 - Basic Batch Commands -- • Batch file programming tutorial // Ba...
Batch file programming tutorial // COPY COMMAND // Batch Scripting Part-3 - COPY Batch Command -- • Batch file programming tutorial // CO...
Batch file programming tutorial // DEL COMMAND // Batch Scripting Part-4 - DEL Batch Command -- • Batch file programming tutorial // DE...
Batch file programming tutorial // MOVE COMMAND // Batch Scripting Part-5 - MOVE Batch Command -- • Batch file programming tutorial //MOV...
Batch file programming tutorial // ATTRIB COMMAND // Batch Scripting Part-6 - ATTRIB Batch Command -- • Batch file programming tutorial // AT...
Batch file programming tutorial // FIND COMMAND // Batch Scripting Part-7 - FIND Batch Command -- • Batch file programming tutorial // FI...
Batch file programming tutorial // VARIABLES IN BATCH SCRIPT // Batch Scripting Part- 8 - VARIABLES -- • Batch file programming tutorial // VA...
DO NOT CLICK // LOCAL AND GLOBAL VARIABLES IN BATCH SCRIPT // Part- 9 - LOCAL AND GLOBAL VARIABLES -- • DO NOT CLICK // LOCAL AND GLOBAL VARI...
BATCH SCRIPTING // STRINGS IN BATCH SCRIPT // Batch Scripting Part- 10 - STRINGS -- • BATCH SCRIPTING // STRINGS IN BATCH S...
BATCH SCRIPTING// LEFT, MID AND RIGHT STRINGS// Batch Scripting Part- 11- LEFT, MID AND RIGHT STRING -- • BATCH SCRIPTING// LEFT, MID AND RIGHT...
REMOVE AND REPLACE IN STRING // Batch Scripting Part 12 REMOVE AND REPLACE IN STRING -- • REMOVE AND REPLACE IN STRING // Batch...
BATCH SCRIPTING// ARRAYS // Batch Scripting Part 13 ARRAYS -- • BATCH SCRIPTING// ARRAYS // Batch Scr...
BATCH SCRIPTING// MODIFY AND ITERATE OVER AN ARRAYS // Batch Scripting Part 14 MODIFY AND ITERATE -- • BATCH SCRIPTING// MODIFY AND ITERATE ...
BATCH SCRIPTING// LENGTH OF AN ARRAY // Batch Scripting Part 15 LENGTH OF AN ARRAY -- • BATCH SCRIPTING// LENGTH OF AN ARRAY ...
BATCH SCRIPTING// IF CONDITION // Batch Scripting Part 16 IF CONDITION -- • BATCH SCRIPTING// IF CONDITION // Bat...
======================================================
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 Matri...
CMD: Wi-Fi Password Hack| Find WiFi Password on Windows 10/8/7/XP -- • Video