How to make Windows10 CMD to run a certain command each time I bootstrap it?

There is a certain command I want to run each time I open a new CMD window in Windows10 home.

How could this be done?

In Ubuntu for example, I would just type this command in /etc/bash.bashrc, but how can this be done in Windows10?



The shortcut to the command line literally runs cmd.exe and nothing else.

If you want to run a batchfile file when you open cmd, find the Command Prompt shortcut in the start menu, and right click / properties.

You'll see


Change this to

%windir%\system32\cmd.exe /k c:\path\to\batch\file.bat

Replace the file location with your file.

When you run CMD, it will run the batch file. Normally the process exits once the batch file is complete, but the /k switch keeps it open for use.

  • @Benia The single command can be appended instead of the batch file, it will work the same way. You can use this approach to add cmd.exe to your menu as a proper short cut, superuser.com/questions/948088/… then pin the result to your taskbar. – Paul Jul 13 '17 at 2:24
  • Hmm this seems to work but I need this solution for the taskbar icon. I went to the original file location instead editing the shortcut but there I didn't have any field to insert /k MyCommad... – JohnDoea Jul 13 '17 at 2:32
  • After changing the CMD shortcut as you said, I had to replace it with the taskbar shorcut that already existed in taskbar and referenced the original file. So, now it works fine. Thanks. – JohnDoea Jul 13 '17 at 3:04

Based on Paul's answer that I accepted, this is what I did:

  1. Search for CMD in Windows search.
  2. Left click the icon and right click "Open file location".
  3. Left click the shortcut and go to properties.
  4. In properties, under target, enter:

    %windir%\system32\cmd.exe /k bash
  5. Open CMD and drag the CMD window itself to the taskbar.

Note: You might want to delete any non bash-oriented taskbar shortcuts you might have had. (You can always access CMD quickly by executing exit.)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.