I want to change the CMD startup directory when I launch it via Start+R
Currently, it points to my users folder. I need it to point to C:\Windows\System32\
When I navigate using explorer to C:\Windows\System32\ and run CMD from there (Shift+RightClick on an empty area), it starts in the desired path.
When I run from Win+R, it starts from the users folder.
I suspect I need to change the registry or an environment variable. Anyone knows how to ?
THIS QUESTION IS DIFFERENT FROM THE OTHERS FOR THE REASON EXPLAINED BY @KARAN (READ THE THIRD COMMENT FROM THE ANSWERS BELOW)
DIFFERENT ANSWERS ONLY WORK FOR SHORTCUTS
Edit: Found the right answer hidden on the pit of the provided links, kilometers away from the supposed "right answer"
[HKEY_CURRENT_USER\Software\Microsoft\Command Processor] "Autorun"="cd C:\Windows\System32\"
cmd.exe) is started. It won't work in many cases such as if%homedrive%is notc:ascdwould require/dswitch to change into another drive, or%windir%is notc:\windows:) – May 18 '15 at 22:04cmd /d:) – May 18 '15 at 22:12cmd /k "cd /d %windir%\sytstem32"for the same purpose. – May 18 '15 at 22:15Autorunregistry value is that the command line specified there is executed every timecmd.exeis started by any application.cmd.exestartscmd.exeon running afor /Floop with a command line enclosed in'. Many applications startcmd.exeas it is the default shell processor on Windows via the environment variableComSpec. The usage ofcd C:\Windows\System32\will cause lots of troubles as most applications runningcmd.exein background expect that the current directory of the process is also the current directory forcmd. – Mofi Sep 28 '20 at 16:52cd /D %SystemRoot% & for /F "eol=| delims=" %I in ('dir *.exe /A-D /B') do @if not exist "%~fI" echo Missing file: "%~fI"It can be seen thatdirdoes not output the .exe files in directoryC:\Windowswhich is the current directory aftercd /D %SystemRoot%, but the file names of all .exe files in%SystemRoot%\System32. The current cmd process searches because of%~fIfor the executable in%SystemRoot%, can't find it there, concatenates thereforeC:\Windowswith the file name output bydirandifcan't find the files. – Mofi Sep 28 '20 at 17:01%ComSpec%or%SystemRoot%\System32\cmd.exe, define as Start in the directory path%SystemRoot%\System32and define also a Shortcut key for this shortcut file. Then a command prompt window can be opened from within any running application by pressing the defined shortcut key andcmdis started withC:\Windows\System32as current directory. – Mofi Sep 28 '20 at 17:06cmdexecution environment. – Mofi Sep 28 '20 at 17:08