In 2000 & XP, the environment variable %CD% contains the current
directory.

SET varname=%CD%

Varname's value is not updated as you change directories:

CD \WINDOWS
SET startdir=%CD%
ECHO %startdir%          (output=C:\WINDOWS)
CD  \program files
ECHO %startdir%          (output=C:\WINDOWS)
SET startdir=%CD%
ECHO %startdir%          (output=C:\Program Files)

Also, the %CD% value is set to the long filename that Windows stores;
C:\program files or c:\PROGRAM FILES would both have a %CD% value of
C:\Program Files.

I don't know if other versions of Windows support %CD% as 2000 & XP are
all I have access to.

John A. Jones, CISSP
Americas Information Security Officer
Jones Lang LaSalle, Inc.
V: +1-630-455-2787  F: +1-312-601-1782
john.jones@xxxxxxxxxx

-----Original Message-----
From: David Gibbs [mailto:david@xxxxxxxxxxxx] 
Sent: Thursday, November 04, 2004 11:11 AM
To: pctech@xxxxxxxxxxxx
Subject: [PCTECH] Determine current directory in DOS?

Anyone know of a way to set an environment variable to the current
directory name in a DOS batch file?

Thanks!

david


This email is for the use of the intended recipient(s) only.  If you have 
received this email in error, please notify the sender immediately and then 
delete it.  If you are not the intended recipient, you must not keep, use, 
disclose, copy or distribute this email without the author's prior permission.  
We have taken precautions to minimize the risk of transmitting software 
viruses, but we advise you to carry out your own virus checks on any attachment 
to this message.  We cannot accept liability for any loss or damage caused by 
software viruses.  The information contained in this communication may be 
confidential and may be subject to the attorney-client privilege. If you are 
the intended recipient and you do not wish to receive similar electronic 
messages from us in future then please respond to the sender to this effect.


As an Amazon Associate we earn from qualifying purchases.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.