8

The ~ character is a universal alias in the Unix word for referencing the home directory of the user. It is a special character that will be parsed and replaced by the full path of the current user's home directory. Is there an equivalent of this in cmd.exe ? (not Powershell)

adamency
  • 503

1 Answers1

18

No.

You can use commands like cd /D %homedrive%\%homepath% or cd /D %userprofile% but typing them is just not the same even if end result is. The closest to the simplicity of cd ~ I've ever seen is Señor CMasMas's elegant solution below.

Create a new bat file with one single line:

@cd /d %UserProfile% –

Save it with name cd~.bat into any folder in your %PATH%. After that you can get from anywhere in the system back to home directory by typing command

cd~
phuclv
  • 30,396
  • 15
  • 136
  • 260
Peregrino69
  • 5,004