# cmd and startup dir

With terminal it is quite easy to specify a start-up directory as controlled thru settings.json file. While old cmd is a not that customizable really. Of course one can hack thru with registry entries link1 and link2.

Well, most of the instructions are fine, but it does not work for me at all:

• environment variables expand
• fiddling with CMDCMDLINE variable

This is what works however:

1. Open regedit
2. HKCU\Software\Microsoft\Command Processor
3. Create a new String key
4. Name it Autorun
5. Enter text verbatim without quotes IF /I x"%COMSPEC%"==x%CMDCMDLINE% (cd /D d:\tempdir)

Here, I am setting default Startup dir to be d:\tempdir, change this to whatever is suitable. Also, I think, x"%COMSPEC%"==x%CMDCMDLINE% check ensures that you are not launching just cmd (without any arguments). This typically preserves initial directory as set by script/tool.

Images for help:

Browse to HKCU\Software\Microsoft\Command Processor:

Value for Reg key:

Env-Var CMDCMDLINE is quite interesting. Details here