2

I have a shortcut on my desktop for a command that runs cmd.exe /k <myscript.cmd>. I assigned it the keyboard shortcut of Ctrl+Alt+R.

This works to open one window, but the problem is that pressing the shortcut a second time switches focus to the window that's already open. I would like a new window to be created each time I press the shortcut instead of switching focus to the existing window.

Is there a way to do this?

1
  • Try using start - Start a program, command or batch script (opens in a new window).
    – DavidPostill
    Commented Apr 11, 2016 at 22:26

2 Answers 2

1

Change your shortcut to

start myscript.cmd

From the Microsoft Documentation: The start command will start a separate Command Prompt window to run a specified program or command.


If your command name contains space(s) (e.g., C:\Program Files\mystuff\myscript.cmd), you need to put it into quotes, of course.  Because of a quirk in the user interface design for the start command, if you do this, you need to provide another quoted string first.  This is intended to set the title of the new window, so you could say,

start "This is mine!" "C:\Program Files\mystuff\myscript.cmd"

or you can just leave it blank:

start "" "C:\Program Files\mystuff\myscript.cmd"
2
  • Tried this and thought it didn't work, but it turned out I had to close the other window previously opened with the shortcut. After that, opening multiple new windows works.
    – Fred
    Commented Apr 12, 2016 at 1:01
  • Hi @Fred, I see your edit here, did you need to use the full path to cmd.exe? It should be on your path by default and not needed.
    – Matt Clark
    Commented Apr 12, 2016 at 1:06
0

The exact shortcut target reads:

C:\Windows\System32\cmd.exe /c "start myscript.cmd arg1 arg2"

It did not work with quotes around the "myscript.cmd...".

You must log in to answer this question.

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