@echo off
setlocal enabledelayedexpansion
call :COUNT "%path%"
echo Your variable is %length% characters long
pause >nul
:COUNT
set temp=%1
set length=0
:loop
if defined temp (
set temp=!temp:~1!
set /a length+=1
goto :loop
)
Usage: call :COUNT %yourvar%
and the length will be stored in %length%
.