检查变量是否为空。
@echo off
set str= PowerOnHours="10 Days 5 Hours "
echo [%str%]
rem check variable is empty or not.
if defined str (
echo str is not null.
) else (
echo str is null.
)
检查变量值中是否存在特殊字符。
@echo off
set str= PowerOnHours="10 Days 5 Hours "
echo [%str%]
rem check for the presence of special characters in str.
echo %str% | findstr /C:"\"" /C:"$" /C:"\\">nul
if %errorlevel% equ 0 (
echo Exist specify string, such as ", $...
) else (
echo No specify string.
)