Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In Linux, we can go to the user home by entering the tilde (~) character after cd:

cd ~

How to do the same in Windows?

Each time, I need to type:

cd C:\Document and Settings\freewind

That's too boring.

share|improve this question

migrated from Sep 7 '11 at 13:13

This question came from our site for professional and enthusiast programmers.

Consider using cygwin ? – Paul R Sep 7 '11 at 12:29
actually, '~' is the default for 'cd' under most Linux shells, so just 'cd' would suffice to go to your homedir – Arnout Engelen Sep 7 '11 at 12:44
@Arnout: See… – abatishchev Sep 7 '11 at 13:11
The answer is simply "cd ~".. means, you can use the same command in Windows too. But, you shouldn't try this command in CMD because its out-dated now & its development is discontinued by Microsoft. Use "Windows PowerShell" and the same command will work smoothly. – Evil Angel Sep 14 '11 at 4:03
PowerShell ships with Win7+ – Isaac Dontje Lindell Jan 16 '13 at 21:11
up vote 30 down vote accepted

cd /d "%HOMEDRIVE%%HOMEPATH%" would do it -- but I 'm not sure if you consider it an improvement.

You can also define an alias for the above command:

doskey cdhome=cd /d "%HOMEDRIVE%%HOMEPATH%"

After this, it's simply cdhome.

share|improve this answer
@Freewind: You gotta love the default Windows shell. – Jon Sep 7 '11 at 12:33
@abatishchev: Good question. This question on SF seems to indicate that %USERPROFILE% is preferable. – Jon Sep 7 '11 at 12:50
You can also use cd~ as the macro name, instead if cdhome. – jftuga Sep 7 '11 at 14:16
@abatishchev: Windows NT accounts can have a "home directory" path attached which is separate from the "profile directory". The profile keeps your settings (Registry), application data, and such. The home directory, on the other hand, is for your own files -- when a program displays the "Open/Save" dialog for the first time, it will start at the home directory. (Windows 95/98 used it somewhat differently; can't remember the specifics.) This is useful in Active Directory environments, for storing files on a network share but keeping the profile local. – grawity Sep 7 '11 at 14:41
@jftuga: Or even ~. – grawity Sep 7 '11 at 14:43

You can use cd /d %USERPROFILE% if you use the normal command shell

or you can use cd ~ if you use PowerShell.

share|improve this answer
+1 But add the /d – xanatos Sep 7 '11 at 12:36
+1 but also add quotes around the variable (maybe it's c:\documents and settings\..., the spaces will break it unless it's quoted) – Jon Sep 7 '11 at 12:47
@Jon: cd is an exception. Since it always takes a single argument, quoting is not necessary. (On Windows, programs and built-ins must parse their command line themselves, the shell does not do it.) Always quoting paths is a good practice, however. – grawity Sep 7 '11 at 14:45
@grawity what do you think they tend to use for parsing it? – barlop Nov 7 '11 at 15:28
@barlop: usually CommandLineToArgvW(); the CLR/MinGW/Cygwin runtimes also use their own equivalent automatically before calling main(). Some programs, however, have parsers written entirely from scratch, for example, cmd.exe itself and its wacky /c. – grawity Nov 8 '11 at 23:18

One possibility is to use the subst command from a command prompt:

subst z: C:\Document and Settings\freewind

Any time you navigate to drive Z:, you'll be looking at your user folder.

The downside is that you need to run it every time you log in. I used a batch file and just put it in my startup folder, but there are probably more elegant solutions to this.

The benefit is that unlike a doskey alias, it works universally (windows explorer, browse dialog, etc.), not just when changing directories at the command prompt. It's especially helpful for old programs with old browse dialogs that have drive letters at the topmost level, rather than "desktop".

share|improve this answer
+1 for creative solution - I had no idea it was so easy to mount folders as drives in windows! – Caspar Sep 13 '11 at 0:53
You can map a drive and make it automatically remap after login. No need to use subst – Lưu Vĩnh Phúc Jun 29 '15 at 8:32
@LưuVĩnhPhúc It may not be entirely logical, but I tend to avoid windows network share things unless I really have to use them. I feel like performance and reliability is... unpredictable? By all means if you have an alternative, nay better, way of doing it, please post it in its own answer for the benefit of everyone :) – mo. Jun 29 '15 at 13:38

You can do this:

cd %homepath%
share|improve this answer
This will break if you're on a different drive - e.g. you're on E: and your homedir is on C: – Piskvor Sep 7 '11 at 13:40

You can create a batch file called ~.bat containing

@echo off

And add it to your PATH variable (Start->[right-click on "Computer"]->Properties->"Advanced System Settings"[in left column]->"Environment Variables"

From there, just edit your PATH variable to include the folder containing your ~.bat file. (This allows you to invoke your script from anywhere using just the filename--not the absolute path to the file)

Also, make sure your PATHEXT environment variable contains .BAT somewhere (this allows you to type ~ instead of ~.bat).

When you need to use it, simply enter ~ at the command prompt. This solution is persistent--you won't have to set it up every time you launch a shell, and you won't need to hack your registry.

share|improve this answer
This still will fail if the prompt is on a different drive – TheLQ Jan 17 '13 at 2:33
You're right. I entered the wrong one by mistake. I made an edit; it should work now. – weberc2 Jan 17 '13 at 14:26
I think @TheLQ is referring to /d missing: cd /d %userprofile%. This changes not only the folder, but the drive if you're on a different drive from your user folder when you execute the command. – eisb Jan 17 '13 at 15:32
@eisb Gotcha, I wasn't aware (after a decade and a half of daily Windows use, I still haven't become as proficient with Windows as I have with Linux in only two years). I'll fix. Thanks for the tips! :) – weberc2 Jan 17 '13 at 16:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .