In tip 256, we switched to the "Windows" directory before exiting the script. If that doesn't work, or is intermitant, try the following at the end of the script:

if %OS% == Windows_NT goto WNT
if exist c:\windows\*.* goto W3
if exist c:\win95\*.* goto W95
if exist c:\win98\*.* goto W98
REM you can add any other directories that you use
goto end
:WNT
cd %SystemRoot%
goto end
:W3
cd c:\windows
if exist c:\windows\lmscript.$$$ goto end
goto lms
:W95
cd c:\win95
if exist c:\win95\lmscript.$$$ goto end
goto lms
:W98
cd c:\win98
if exist c:\win98\lmscript.$$$ goto end
:lms
echo . > lmscript.$$$
:end
exit