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-06-22 12:00
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » [Help] How to get the current path View 4,402 Replies 10
Original Poster Posted 2004-07-21 00:00 ·  中国 北京 联通
银牌会员
★★★
nre
Credits 1,210
Posts 361
Joined 2002-12-28 00:00
23-year member
UID 629
Gender Male
Status Offline
For example, I am in the c:\temp directory. How can I assign this path to a variable? Does anyone have a small program or a good method? Thanks

Teamwork !
Floor 2 Posted 2004-07-21 00:00 ·  中国 河北 石家庄 联通
铂金会员
★★★★
网络独行侠
Credits 6,962
Posts 2,753
Joined 2003-04-16 00:00
23-year member
UID 1565
Gender Male
From 河北保定
Status Offline
You need to use Horst's lmod as follows:
cd | lmod /L1 set curdir= > temp.bat
call temp.bat
del temp.bat
After execution, the current directory will be saved to the curdir environment variable.
偶只喜欢回答那些标题和描述都很清晰的帖子!
如想解决问题,请认真学习“这个帖子”和“这个帖子”并努力遵守,如果可能,请告诉更多的人!
Floor 3 Posted 2004-07-21 00:00 ·  中国 北京 联通
银牌会员
★★★
nre
Credits 1,210
Posts 361
Joined 2002-12-28 00:00
23-year member
UID 629
Gender Male
Status Offline
Where can I find the lmod small program?

Teamwork !
Floor 4 Posted 2004-07-21 00:00 ·  中国 河北 石家庄 联通
铂金会员
★★★★
网络独行侠
Credits 6,962
Posts 2,753
Joined 2003-04-16 00:00
23-year member
UID 1565
Gender Male
From 河北保定
Status Offline
偶只喜欢回答那些标题和描述都很清晰的帖子!
如想解决问题,请认真学习“这个帖子”和“这个帖子”并努力遵守,如果可能,请告诉更多的人!
Floor 5 Posted 2004-07-26 00:00 ·  中国 广东 广州 白云区 电信
金牌会员
★★★★
D◎$ Fαп
Credits 4,562
Posts 1,883
Joined 2004-01-19 00:00
22-year member
UID 15812
Gender Male
From 广东广州
Status Offline
No need to be so complicated! The %CD% variable is just the variable for the current path. If you don't believe it, you can try echo %cd% and see.
----====≡≡≡≡ 我的至爱,永远是MSDOS!≡≡≡≡====----
Floor 6 Posted 2004-07-26 00:00 ·  中国 河北 保定 联通
铂金会员
★★★★
网络独行侠
Credits 6,962
Posts 2,753
Joined 2003-04-16 00:00
23-year member
UID 1565
Gender Male
From 河北保定
Status Offline
The following is the statement made by JonePeng on 2004-7-26 22:56:12:

No need to be so complicated!
The %CD% variable is the variable for the current path. If you don't believe it, you can try echo %cd% to see.

Please try to type echo %cd% under 98!
偶只喜欢回答那些标题和描述都很清晰的帖子!
如想解决问题,请认真学习“这个帖子”和“这个帖子”并努力遵守,如果可能,请告诉更多的人!
Floor 7 Posted 2006-07-17 04:36 ·  IANA 局域网IP(Private-Use)
初级用户
★★
Credits 177
Posts 52
Joined 2006-06-04 12:00
20-year member
UID 56562
Status Offline
I want to ask, besides third - party tools, is there any other solution?
Floor 8 Posted 2006-07-17 08:10 ·  中国 福建 泉州 电信
银牌会员
★★★
Credits 1,276
Posts 469
Joined 2002-12-23 13:00
23-year member
UID 586
Gender Male
From 福建泉州
Status Offline
Search the forum.

echo exit|%comspec% /k prompt set runpath=$P$_|find "exit" /v>temp.bat
call temp.bat
del temp.bat
QQ:366840202
http://chenall.net
Floor 9 Posted 2007-12-04 18:33 ·  中国 辽宁 沈阳 联通
中级用户
★★
Credits 234
Posts 119
Joined 2007-04-22 11:09
19-year member
UID 86077
Gender Male
Status Offline
echo %cd% is quite useful~~ If it only doesn't work under 98, then it's okay. Now there are few people using 98 systems. Some things are still simpler, don't seem too professional
Floor 10 Posted 2010-03-16 21:55 ·  中国 广东 东莞 电信
新手上路
Credits 4
Posts 4
Joined 2008-11-13 10:39
17-year member
UID 130823
Gender Male
Status Offline
`%cd%` in folders with spaces, such as the desktop, doesn't seem to work
Floor 11 Posted 2010-03-16 23:34 ·  中国 天津 电信
初级用户
★★
Credits 128
Posts 122
Joined 2009-09-21 06:24
16-year member
UID 152378
Gender Male
Status Offline
The desktop can be achieved with "%cd%".
Forum Jump: