1

Regardless of what directory I am at, for instance, when type in cd ~/Documents/project in git bash, it works. Whereas, it will not work doing the same in the cmd. It says: the system cannot find the path specified.

I have searched for how to get the $Home variable in the cmd to work but there are many different answers and all of them quite old. Any ideas how to fix it?

Helio
  • 21

2 Answers2

4

If your "HOME" environment variable is not set (or if you don't know what this is):

  1. Open command prompt (Open Start Menu, then type cmd and press [Enter]) Type the following line into the command prompt window exactly as shown:

    setx HOME "%USERPROFILE%"

  2. Press [Enter], you should see "SUCCESS: Specified value was saved."

2

Doing the same in the cmd. It says: the system cannot find the path specified.

cd ~/Documents/project

cmd does not understand ~ expansion as it is not bash compatible.

cmd also does not use $HOME. Instead it uses %HOMEDRIVE% and %HOMEPATH%

You can set a new environment variable %HOME% as appropriate for your needs and then use:

cd %HOME%

Further Reading

DavidPostill
  • 162,382