The script above does take into account quotes(except for the "set"). Strangely enough the space does kill it.... Well, we both know there's a better way anyhow.
Here's another way of doing it(thanks to Razor2.3)....
set var="c:\program files\abc\test1"
for /f "delims=" %%a in (%var%) do (
for %%b in ("%%~a\..") do set startvar=%%~dpb
Batch Variable how to