| 1. |
Solve : How do I check if the parameter %1 exist in a batch file (IF statement)?? |
|
Answer» I tried the following batch file: Of course. Need to "define" the %1 as a string.well, not really... you could just as easily do Code: [Select]IF !%1==! EXIT It's just when it expands so there is nothing on one side, it's not a valid syntax. Quote from: viking2 on February 28, 2010, 01:27:58 PM I tried the following batch file: Quotes around "%1" worked C:\batch>type shift.bat Code: [Select]ECHO OFF :start Echo - %1 shift IF "%1"=="" exit /B pause goto start Output: C:\batch>shift.bat 1 2 3 4 - 1 Press any key to continue . . . - 2 Press any key to continue . . . - 3 Press any key to continue . . . - 4 C:\batch> p.s.: use exit /b to exit the batch and not exit the command PROMPT PAGE. |
|