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?


1 Answer 1


This is possible by providing an autorun script for cmd.exe.
This is set via registry.

Open registry with regedit

navigate to:

Computer\HKEY_CURRENT_USER\SOFTWARE\Microsoft\Command Processor

A REG_SZ registry variable Autorun should exist with value set to 0. If registry variable not exits, create variable Autorun.

Set variable to your script, i.e. "%YOUR_PATH_TO_FILE%\my_startup_script.bat"


Computer\HKEY_CURRENT_USER\SOFTWARE\Microsoft\Command Processor\Autorun="%USERPROFILE%\my_startup_script.bat"

It is also possible to use HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\AutoRun.

Further reading:
Hidden gotcha: The command processor's AutoRun setting

  • It works, magical. Note to self and others, put call before every line if the .bat file has multiple lines. Oct 27, 2022 at 1:02
  • @OtávioAugustoSilva - The CALL in a .bat file is only necessary if you are trying to invoke one .bat file from another - you don't, for example, need CALL NOTEPAD.EXE FOO.TXT or CALL DIR *.TXT. It's also used for labelled subroutines within a single .bat file; see SS64 on CALL. Oct 27, 2022 at 11:13
  • @JeffZeitlin didn't know that, thanks for the info! Oct 27, 2022 at 15:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .