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

20,249

Solution 1

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 /?

Solution 2

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

Solution 3

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

enter image description here

Share:
20,249
John Goche
Author by

John Goche

Updated on July 09, 2022

Comments

  • John Goche
    John Goche almost 2 years

    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?