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-07-31 22:26
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » How to get the current drive letter and save it in a text file? View 7,017 Replies 18
Floor 16 Posted 2006-11-25 23:44 ·  中国 甘肃 兰州 电信
金牌会员
★★★★
Credits 4,103
Posts 1,744
Joined 2006-01-20 13:00
20-year member
UID 49241
Gender Male
From 甘肃.临泽
Status Offline
First heard of it
Floor 17 Posted 2006-11-25 23:50 ·  中国 河北 廊坊 三河市 移动
金牌会员
★★★★
Credits 2,725
Posts 1,160
Joined 2006-09-23 12:00
19-year member
UID 63486
From 河北廊坊
Status Offline
Change the Cmd.exe prompt. If used without parameters, prompt resets the command prompt to the default setting, which is the current drive letter followed by the current directory and a greater-than sign (>).

Syntax
prompt

Parameters
text
Specifies any text and information to include in the system prompt.
/?
Displays help at the command prompt.
Remarks
You can customize the command prompt to display any desired text, including the current directory name, time and date, and the Windows XP version number, etc.
The following table lists the character combinations that can be included in the text command-line option instead of (or in addition to) one or more strings. The list includes a brief description of the text or information added to the command prompt for each character combination. Character Description
$q = (equal sign)
$$ $ (dollar sign)
$t Current time
$d Current date
$p Current drive and path
$v Windows XP version number
$n Current drive
$g > (greater-than sign)
$l < (less-than sign)
$b | (pipe)
$_ Carriage return - line feed
$e ANSI escape code (code 27)
$h Backspace key (deletes a character written to the prompt command line)
$a & (ampersand)
$c ( (left parenthesis)
$F ) (right parenthesis)
$s space

When command extensions are enabled (which is the default), the prompt command supports the formatting characters listed in the following table. Character Description
$+ Zero or more plus (+) characters, depending on the depth of the pushd directory stack, one character for each level pushed.
$m The remote name associated with the current drive letter, or an empty string if the current drive is not a network drive.

If the $p character is included in the text parameter, the system reads the disk after each command is entered to determine the current drive and path. This takes extra time, especially for floppy drives.
Examples
The following example sets the command prompt to display the current drive and path, followed by a greater-than sign (>):

prompt $p$g

The following command displays a two-line prompt, with the first line showing the current time and the second line showing the current date:

prompt time is:$t$_date is$d

[ Last edited by ccwan on 2006-11-25 at 11:52 PM ]
Recent Ratings for This Post ( 1 in total) Click for details
RaterScoreTime
redtek +3 2006-11-26 00:02
三人行,必有吾师焉。 学然后知不足,教然后知困,然后能自强也。
Floor 18 Posted 2006-12-02 09:16 ·  中国 四川 成都 电信
初级用户
Credits 105
Posts 44
Joined 2006-10-05 13:57
19-year member
UID 64618
Status Offline
Wow... I haven't been here for a few days and there are already so many answers. It seems I'm stupid
Floor 19 Posted 2010-06-09 13:44 ·  美国 戴尔电脑公司
新手上路
Credits 3
Posts 2
Joined 2009-08-27 10:14
16-year member
UID 151058
Gender Male
Status Offline
set a=%0
echo %a:~0,2%>temp.txt

How to borrow reading?
Forum Jump: