I have to create a batch file but before entering a command it should display like:
C:\user\nameofuser AND the current date>
I can only display the date with echo %date%
, but cannot make it stay on the left.
How to reach my aim?
I have to create a batch file but before entering a command it should display like:
C:\user\nameofuser AND the current date>
I can only display the date with echo %date%
, but cannot make it stay on the left.
How to reach my aim?
If you want that, then it so easy with the prompt
command, which defines the cmd.exe command prompt. The default is $P
$G
. You should change to $P
(Current drive and path ) $S
(space) $D
(current date) $G
(greater-than sign) and optionally a space with $S
.
Changing command prompt requires the use of prompt
command. Use prompt $P$S$D$G$S
. The $S
is optional.
Also, if you don't want to continuously change your prompt with the newest drive and path (not recommended), include %userprofile%
environment variable instead of $P
.
If you don't want the name of the date this can be done, hard of course, you may want a continuous loop, take a look at
If you don't want the date name you can see How do I get current datetime on the Windows command line, in a suitable format for using in a filename?, but you may want a continuous loop.
Take a look below:
$A
& (Ampersand)
$B
| (pipe)
$C
( (Left parenthesis)
$D
Current date
$E
Escape code (ASCII code 27)
$F
) (Right parenthesis)
$G
> (greater-than sign)
$H
Backspace (erases previous character)
$L
< (less-than sign)
$N
Current drive
$P
Current drive and path
$Q
= (equal sign)
$S
(space)
$T
Current time
$V
Windows version number
$_
Carriage return and linefeed
$$
$ (dollar sign)
From prompt /?
in cmd