Here is another option. Pass the string as a parameter:
LEN "this is a long string"
Here is the code:
@echo off
echo.%~1>len
for %%a in (len) do set /a len=%%~za -2
echo %len%
Copy and paste the code into Notepad and save it as LEN.BAT.
. ECHO , NUL. -2, ECHO CR LF .