• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Testing Parameters with IF

Testing Parameters with IF

One of the most common uses of the IF command is to check the parameters that the user entered and proceed accordingly. From the previous section, the simple batch file that used GOTO can be rewritten with IF as follows:

@ECHO OFF
CLS
IF "%1"=="A" ECHO This part of the batch file runs if A is the parameter.
IF "%1"=="B" ECHO This part of the batch file runs if B is the parameter.


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint