In a similar way to .bashrc
on WSL2, I want to add custom commands to run when I open the Command Prompt in Windows Terminal, like winfetch
for example. Is there any way to configure the Command Prompt profile so that it executes custom commands at startup?
Windows Terminal – Adding Launch Commands to Command Prompt
cmd.exewindowswindows-11windows-terminal
Best Answer
This is possible by providing an autorun script for cmd.exe.
This is set via registry.
Open registry with
regedit
navigate to:
A REG_SZ registry variable
Autorun
should exist with value set to 0. If registry variable not exits, create variableAutorun
.Set variable to your script, i.e.
"%YOUR_PATH_TO_FILE%\my_startup_script.bat"
Example:
It is also possible to use
HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\AutoRun
.Further reading:
Hidden gotcha: The command processor's AutoRun setting