Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Windows 7: cmd.exe: setting startup directory (in a link to cmd.exe)

I am running Windows 7 and when I run cmd.exe I want it to start up in a directory named C:\foo\bar. I remember being able to create a link to this executable on the desktop and right clicking somewhere to set the startup menu of the cmd.exe command prompt by filling out a field in a transient window, but I cannot find it. I have found the following argument which however seems more complicated. I want to set the startup directory for cmd.exe via a popup window.

Changing default startup directory for command prompt in Windows 7

Any ideas?

like image 698
John Goche Avatar asked Jun 29 '12 22:06

John Goche


3 Answers

as mentioned by the other posters already: the regular approach is to edit the shortcut's properties and fill the field labled "start in". simple as that.

however, for some reason this has no effect on UAC enabled systems if at the same time you also enable the "run as administrator" checkbox in the advanced properties of the shortcut.

enter image description here

a solution is to put everything in the "target" field of the shortcut:

%windir%\System32\cmd.exe /K cd /d "E:\My Folder" & sometest.bat

when running on 64bit and you want to explicitly start the 32bit flavour of the command prompt:

%windir%\SysWOW64\cmd.exe /K cd /d "E:\My Folder" & sometest.bat



for additional information on the command line parameters used above see:
cmd.exe /?
cd.exe /?

like image 100
Opmet Avatar answered Oct 19 '22 03:10

Opmet


When you create a shortcut to cmd.exe, you can open the shortcut properties and find under Shortcut tab the Starts in option that will tell cmd.exe where to start, like here:

Command Prompt Shortcut Properties

like image 26
Luis Lavena Avatar answered Oct 19 '22 03:10

Luis Lavena


Open the properties of a shortcut to cmd and set the directory there:

enter image description here

like image 45
Joey Avatar answered Oct 19 '22 03:10

Joey