if: add page (#7443)

feature/windows-fix-syntax-2
Emily Grace Seville 2021-12-11 14:30:29 +10:00 committed by GitHub
parent 69047681ab
commit 2f636d094e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 32 additions and 0 deletions

32
pages/windows/if.md Normal file
View File

@ -0,0 +1,32 @@
# if
> Performs conditional processing in batch scripts.
> More information: <https://docs.microsoft.com/windows-server/administration/windows-commands/if>.
- Execute the specified commands if the condition is true:
`if {{condition}} ({{echo Condition is true}})`
- Execute the specified commands if the condition is false:
`if not {{condition}} ({{echo Condition is true}})`
- Execute the first specified commands if the condition is true otherwise execute the second specified commands:
`if {{condition}} ({{echo Condition is true}}) else ({{echo Condition is false}})`
- Check whether `%errorlevel%` is greater than or equal to the specified exit code:
`if errorlevel {{exit_code}} ({{echo Condition is true}})`
- Check whether two strings are equal:
`if {{string}} == {{string}} ({{echo Condition is true}})`
- Check whether two strings are equal without respecting letter case:
`if /i {{string}} == {{string}} ({{echo Condition is true}})`
- Check whether a file exist:
`if exist {{path/to/file}} ({{echo Condition is true}})`