1

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?

Thanks,

2 Answers2

3

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

%windir%\system32\cmd.exe

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.

Paul
  • 61,193
1

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.)

phuclv
  • 30,396
  • 15
  • 136
  • 260