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-10 16:40
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » [Closed] How to set the output of a command as the content of an environment variable View 1,554 Replies 7
Original Poster Posted 2006-08-03 11:45 ·  中国 上海 静安区 电信
高级用户
★★
Credits 653
Posts 252
Joined 2006-04-16 19:48
20-year member
UID 53939
Status Offline
For example, set the output of `pwd` as the value of the environment variable `CurrentDir`. Is there a way that doesn't generate temporary files?

[ Last edited by HAT on 2008-11-18 at 17:44 ]
Floor 2 Posted 2006-08-03 12:56 ·  中国 四川 成都 鹏博士宽带
荣誉版主
★★★★
batch fan
Credits 5,226
Posts 1,737
Joined 2006-03-10 00:38
20-year member
UID 51697
From 成都
Status Offline
I searched online and found that pwd is the command to print the current directory in the Linux system. Shouldn't all those who use this command be using non-Windows operating systems? Why is it related to batch processing under Windows?

I haven't used the Linux system and don't quite understand if bat batch processing can be used under Linux. Can someone explain it?

[ Last edited by namejm on 2006-8-3 at 13:18 ]
尺有所短,寸有所长,学好CMD没商量。
考虑问题复杂化,解决问题简洁化。
Floor 3 Posted 2006-08-03 14:25
新手上路
Credits 8
Posts 3
Joined 2006-07-28 09:43
20-year member
UID 59412
Gender Male
Status Offline
for /F "tokens=1*" %i in ('pwd') do set curdir = %i
Floor 4 Posted 2006-08-18 04:36 ·  中国 上海 杨浦区 电信
高级用户
★★
Credits 653
Posts 252
Joined 2006-04-16 19:48
20-year member
UID 53939
Status Offline
Originally posted by namejm at 2006-8-3 12:56:
  After searching online, I found that pwd is the command to print the current directory in the Linux system. Shouldn't all those who use this command be using non-Windows operating systems? How does it get related to batch processing under Windows...


Hehe, buddy, just type pwd in your own Win32 command line and you'll understand, no need for google? :P The method of the upstairs buddy seems不错, thanks for the tip!
Floor 5 Posted 2006-08-18 07:37 ·  中国 四川 成都 鹏博士宽带
荣誉版主
★★★★
batch fan
Credits 5,226
Posts 1,737
Joined 2006-03-10 00:38
20-year member
UID 51697
From 成都
Status Offline
May I would like to ask about the system version?

Mine is WinXP + SP2. After entering the pwd command, it prompts that it is neither an internal or external command, nor an executable program or batch file.
尺有所短,寸有所长,学好CMD没商量。
考虑问题复杂化,解决问题简洁化。
Floor 6 Posted 2006-08-18 14:14 ·  中国 四川 成都 教育网
铂金会员
★★★★
Credits 7,493
Posts 2,672
Joined 2005-09-02 00:00
20-year member
UID 42173
Gender Male
Status Offline
The 'cd' command under cmd = 'pwd' command under Linux's shell

for /F "tokens=1*" %i in ( 'cd' ) do set curdir %i

[ Last edited by electronixtar on 2006-8-18 at 14:18 ]

C:\>BLOG http://initiative.yo2.cn/
C:\>hh.exe ntcmds.chm::/ntcmds.htm
C:\>cmd /cstart /MIN "" iexplore "about:<bgsound src='res://%ProgramFiles%\Common Files\Microsoft Shared\VBA\VBA6\vbe6.dll/10/5432'>"
Floor 7 Posted 2006-08-21 16:39 ·  中国 上海 杨浦区 电信
高级用户
★★
Credits 653
Posts 252
Joined 2006-04-16 19:48
20-year member
UID 53939
Status Offline
Originally posted by namejm at 2006-8-18 07:37:
  What is the version of your system?

  Mine is WinXP + SP2. After entering the pwd command, it prompts that it is neither an internal or external command, nor an executable program or batch file.


Apologize to Brother namejm, I made a mistake. I installed the posix shell environment on my Win32, so I often unconsciously use unix commands and thought Win32 also came with it, heh heh.

But the original intention of my first floor is to say that assign the standard output of any command to an environment variable. pwd is just an example here . If you just want to complete the effect of pwd to the variable, for %%I in (.) do set PWD=%%~fnI is enough.
Floor 8 Posted 2008-11-18 17:36 ·  中国 上海 华为云
初级用户
★★
Credits 76
Posts 64
Joined 2008-04-24 23:56
18-year member
UID 116884
Gender Male
Status Offline
Same request, I am in the win98 environment, how should I write?
Forum Jump: