如何在CMD中创建%tab% [英] How to create %tab% in CMD

查看:148
本文介绍了如何在CMD中创建%tab%的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一种可靠的方法来为Windows和XP创建%tab%(包含一个制表符).

I need reliable way to create %tab% (containing one tab character) for both, Windows and XP.

SET TAB=" "

应该适用于Windows 7(未测试),但不适用于Win XP(已测试).

Should work for Windows 7 (not tested) but not for Win XP (tested).

for /F "skip=4 delims=pR tokens=1,2" %%a in ( 'reg query hkcu\environment /v temp' ) do set TAB=%%b

仅适用于Win XP.

works for Win XP only.

推荐答案

您应使用支持TAB字符而不将其更改为空格的编辑器.
您应该对引号重新排序,就像使用set TAB=" "一样,您得到的变量包含三个字符.
TAB然后还包含引号.

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=   "

当前,在所有语言平台上的所有Windows版本中,似乎都没有可靠的方法来使用程序来创建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.

但是您也可以使用嵌入式Jscript代码段.

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));

这篇关于如何在CMD中创建%tab%的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆