I need reliable way to create %tab% (containing one tab character) for both, Windows and XP.
SET TAB=" "
Should work for Windows 7 (not tested) but not for Win XP (tested).
This
for /F "skip=4 delims=pR tokens=1,2" %%a in ( 'reg query hkcu\environment /v temp' ) do set TAB=%%b
works for Win XP only.
You should use an editor which supports TAB characters without changing them to spaces.
And you should reorder the quotes, as with set TAB=" "
you got a variable with three characters.
TAB contains then also the quotes.
set "TAB= "
Currently there seems to be no reliable way to use a program to create a TAB character in all Windows versions on all language platforms.
But you could also use an embedded Jscript snippet.
@if (@X)==(@Y) @goto :Dummy @end/* Batch part
@echo off
SETLOCAL ENABLEEXTENSIONS
for /f "delims=" %%x in ('cscript //E:JScript //nologo "%~f0"') do set TAB=%%x
echo Tab character is "%tab%"
goto :EOF
***** Now JScript begins *****/
WScript.Echo(String.fromCharCode(9));