3

I'm trying to register a shell open command via the registry and want to open more than one program, so I tried it like this:

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\myFile\Shell\Open\Command]
@="cmd /k calc & notepad & exit"

calc and notepad are just an example to demonstrate it.

If I use it like this, the calculator and Notepad are opened, but the command prompt is still open until I close Notepad. If I change it to cmd /k calc & calc & exit, I get 2 calculator instances and the command prompt is closed as I want it.

Why is it not working with Notepad?

Does anybody know another way to start multiple programs with the shell open command in the registry without having the command prompt stay open?

1

You can do this by instead using the following command:

cmd /k start calc & start notepad & exit

Therefore making your .reg file into:

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\myFile\Shell\Open\Command]
@="cmd /k start calc & start notepad & exit"

The reason why calc works fine (in Windows 10, but not in Windows 7) is that the calc.exe process starts a different process (Calculator.exe) and then exits, allowing the command to proceed.

This isn't so for notepad.exe, which means that the command gets stuck there waiting for notepad.exe to close.

The start command is used to start a process in a separate window so that cmd can continue with the next step.

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.