How do I make a Command Prompt shortcut to open a different directory?

Currently, to navigate to the directory I want, I must open Command Prompt and type

C:\Users\me>cd ..\..\repos\RepoSet\UnfortunatelyLongNameAndSimilarToOtherRepos

I use this repo all the time, so I would like Command Prompt to open to this directory right away.

Note that I don't want to open a file, or execute any command other than cd. I just want to open the directory to my repo.

I am using Windows 10 if that makes a difference.

Problem with command line in windows has an answer by @Dave that seems to be what I want, but I don't know where to place the file he mentions.


2 Answers 2



  1. Create a .bat file called mydir.bat
  2. Place the file here: C:\Users\me\CmdFiles
  3. The contents of the file should read
@cd C:\repos\RepoSet\UnfortunatelyLongNameAndSimilarToOtherRepos
  1. Edit the Path environment variable by navigating here Start -> Edit the system environment variables -> Environment Variables -> System variables -> click on Path -> Edit -> Add the path C:\Users\me\CmdFiles under the list of paths.

  2. Now you can type mydir into the command line to access your repo quickly and easily!


Batch files (those ending in .bat) can be used to store command line instructions. When you type a command into to the CLI, it will look in your PATH to see if the appropriate batch file exists. Then it will run the commands within.

  1. Pin the Command Prompt to your TaskBar
  2. Right-click the icon > Right-click Command Prompt > Properties > Shortcut tab:
  3. To have it start in C:\LocationIWantToStart\:
    Target: %windir%\system32\cmd.exe /k cd C:\LocationToStartIn\
  • Pin the Command Prompt to your taskbar, right click the icon, right click Command Prompt, and click on Properties - Start in: C:\LocationIWantToStart\
    – somebadhat
    May 13, 2020 at 12:08
  • This doesn’t answer the question, but it works. Thank you!
    – Super Jade
    May 20, 2020 at 20:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.