China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-08-07 19:00
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » How can echo output [%windir%]? View 821 Replies 7
Original Poster Posted 2008-03-11 18:55 ·  中国 广西 南宁 电信
初级用户
Credits 115
Posts 45
Joined 2007-03-03 10:09
19-year member
UID 80655
Gender Male
Status Offline
There are the following three statements:

@echo [%windir%]
@echo [%%windir%%]
@echo [%%windir%%]|sort

The result output by the first statement is: [C:\WINDOWS]
The result output by the second statement is: [%windir%]
The result output by the third statement is: [C:\WINDOWS]

I want the third statement to also output: [%windir%]. How should I modify it?
(In my actual use, the piped output is not sort, but a third-party tool tr.exe)
Floor 2 Posted 2008-03-11 19:01 ·  中国 湖北 武汉 电信
版主
★★★★★
Credits 11,386
Posts 4,938
Joined 2006-07-23 17:10
20-year member
UID 59080
Status Offline
Floor 3 Posted 2008-03-11 19:02 ·  中国 福建 福州 连江县 联通
高级用户
★★
Credits 581
Posts 277
Joined 2006-12-23 05:10
19-year member
UID 74328
Gender Male
Status Offline
Floor 4 Posted 2008-03-11 19:03 ·  中国 上海 黄浦区 电信
中级用户
★★
Credits 484
Posts 250
Joined 2007-06-05 23:33
19-year member
UID 90372
Gender Male
Status Offline
Floor 5 Posted 2008-03-11 19:23 ·  中国 广西 南宁 电信
初级用户
Credits 115
Posts 45
Joined 2007-03-03 10:09
19-year member
UID 80655
Gender Male
Status Offline
Thanks, everyone.
The output result in reply #2 is also [%C:\WINDOWS%], not what I want.
Although the result in reply #3 is correct, it doesn't go through a pipe.
There are really a lot of methods in reply #4; I'll have to try them slowly.
Floor 6 Posted 2008-03-11 23:57 ·  中国 浙江 杭州 中移铁通
银牌会员
★★★
Credits 1,436
Posts 739
Joined 2007-10-11 17:44
18-year member
UID 99469
Gender Male
Status Offline
Floor 7 Posted 2008-03-12 10:31 ·  中国 广东 韶关 电信
初级用户
Credits 114
Posts 36
Joined 2007-12-22 17:42
18-year member
UID 106486
Gender Male
Status Offline
Do you need to make it that complicated?

echo [^%windir^%]

Completely works
Floor 8 Posted 2008-03-12 11:03 ·  中国 浙江 杭州 中移铁通
银牌会员
★★★
Credits 1,436
Posts 739
Joined 2007-10-11 17:44
18-year member
UID 99469
Gender Male
Status Offline
Originally posted by zcnvnv at 2008-3-12 10:31 AM:
Do you need to make it that complicated?

echo

Completely works

What the OP wants is that it must go through sort.

Not simply just to display %windir%
Forum Jump: