You need to use the /I
flag with find
. Alternatively, you need to search for the string "LICENSE STATUS". Right now, you're doing a case-sensitive search for "License Status," which doesn't appear with that exact capitalization anywhere in the output of OSPP.vbs.
Also, you need to get rid of the spaces in "--- LICENSED ---" because the actual output has no spaces.
@echo off
:: The below directory is for users with a 64-bit operating system
:: 32-bit users can find the script in "%ProgramFiles%"Microsoft OfficeOffice15OSPP.vbs"
for /f "tokens=3 delims= " %%a in ('cscript "%ProgramFiles(x86)%Microsoft OfficeOffice15OSPP.VBS" /dstatus ^| find /i "License Status:"') do (
set "licenseStatus=%%a"
)
if /i "%licenseStatus%"=="---LICENSED---" (
Echo I am Licensed
) Else (
Echo I am NOT Licensed
)
pause
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…