中国DOS联盟论坛

China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --
Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
Guest | Log in | Register | Members | Search | China DOS Union
中国DOS联盟论坛
The time now is 2026-08-10 17:34
47,811 topics / 349,897 posts / today 0 new / 48,256 members
DOS批处理 & 脚本技术(批处理室) » [Closed] How to set the output of a command as the content of an environment variable
Printable Version  1,555 / 7
Floor1 asbai Posted 2006-08-03 11:45
高级用户 Posts 252 Credits 653
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 ]
Floor2 namejm Posted 2006-08-03 12:56
荣誉版主 Posts 1,737 Credits 5,226 From 成都
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 ]
Floor3 FelixYang Posted 2006-08-03 14:25
新手上路 Posts 3 Credits 8
for /F "tokens=1*" %i in ('pwd') do set curdir = %i
Floor4 asbai Posted 2006-08-18 04:36
高级用户 Posts 252 Credits 653
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!
Floor5 namejm Posted 2006-08-18 07:37
荣誉版主 Posts 1,737 Credits 5,226 From 成都
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.
Floor6 electronixtar Posted 2006-08-18 14:14
铂金会员 Posts 2,672 Credits 7,493
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 ]
Floor7 asbai Posted 2006-08-21 16:39
高级用户 Posts 252 Credits 653
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.
Floor8 dejoy Posted 2008-11-18 17:36
初级用户 Posts 64 Credits 76
Same request, I am in the win98 environment, how should I write?
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023