@echo off
if defined MYVAR (
echo ERROR: MYVAR is defined
) else (
echo ERROR: MYVAR is not defined
)
if not defined MYVAR (
echo MYVAR is not defined
) else (
echo MYVAR is defined
)
运行:
C:\> set MYVAR=<avalue>
C:\> test.bat
MYVAR is defined
MYVAR is defined
C:\> set MYVAR=
C:\> test.bat
MYVAR is defined
MYVAR is defined
网友评论