批处理脚本中创建空字符串及空字符串检查

创建空字符串

SET a=

空字符串检查,需要在方括号包裹进行比较

@echo off
SET a=
SET b=HuangBaoKang
if [%a%]==[] echo "String A is empty"
if [%b%]==[] echo "String B is empty"

运行输出

D:\bat_test>test.bat
"String A is empty"

猜你喜欢

转载自blog.csdn.net/huangbaokang/article/details/88963896