Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create %tab% in CMD

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.

like image 362
John Boe Avatar asked Jun 04 '12 08:06

John Boe


People also ask

How do I open multiple tabs in CMD?

Open multiple command prompts in Windows 10Click Start, type cmd, and press Enter to open a command prompt window. In the Windows taskbar, right-click the command prompt window icon and select Command Prompt. A second command prompt window is opened.

How do I open a command tab?

The Command Tab comprises an edit box and allows the execution of OS commands. The output of the same is available above the edit box. To activate the Command Window edit box, press Ctrl + E or go to View > Command Window.

How do I make a new tab in Windows?

Open a new tab Windows & Linux: Ctrl + t. Mac: ⌘ + t.


2 Answers

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));
like image 161
jeb Avatar answered Oct 03 '22 13:10

jeb


With robocopy TAB can also be generated. Robocopy is not available in windows xp by Default.

for /f "delims= " %%T in ('robocopy /L . . /njh /njs') do set "TAB=%%T"
like image 20
pieh-ejdsch Avatar answered Oct 03 '22 14:10

pieh-ejdsch