I'm trying to use the command prompt to move some files,
I am used to the linux terminal where I use ~
to specify the my home directory
I've looked everywhere but I couldn't seem to find it for windows command prompt (Documents and Settings\[user]
)
相关问题
- Batch - Set variables in for loop
- Override yml configuration in spring-boot with com
- How can the Git command be executed on Windows thr
- RVM error with Requirements installation failed wi
- Typepref command gives no valid counters when runn
相关文章
- PowerShell Pass Named parameters to ArgumentList
- Adb install progress bar
- Bash Centos7 “which” command
- Command binding Unable to cast object of type '
- Using 'python -c' option in Windows comman
- execute file .lnk in Java
- authentication error for mifare card “6982:Securit
- How to replace already-printed text in the command
You can
%HOMEDRIVE%%HOMEPATH%
for the drive +\docs settings\username
or\users\username
.You can do almost the same yourself. Open Environment Variables and click "New" Button in the "User Variables for ..." .
Variable Name: ~
Variable Value: Click "Browse Directory..." button and choose a directory which you want.
And after this, open cmd and type this:
cd %~%
. It works.
I just tried
set ~=%userprofile%
and that works too if you want to keep using the same habitYou can then use
%~%
instead.You're going to be disappointed:
%userprofile%
You can use other terminals, though. Powershell, which I believe you can get on XP and later (and comes preinstalled with Win7), allows you to use
~
for home directory.You can use
%systemdrive%%homepath%
environment variable to accomplish this.The two command variables when concatenated gives you the desired user's home directory path as below:
Running
echo %systemdrive%
on command prompt gives:Running
echo %homepath%
on command prompt gives:When used together it becomes:
If you want a shorter version of Jay's you could try
Or you could even use %u% if you wanted to. It saves some keystrokes anyway.