MS-DOS batch function - don't wait till end of execution

How do I make MS-DOS batch function not wait till end of command execution?
If I create such command that executes a bat file, I can't run any other commands (including changing current dir, as Go is also a command) till the script execution is finished. How do I workaround this?

What I'm trying to do is this command for BAT files so I can run them silently in the background using ctrl+enter:

@runmode:hide
{file}

Unfortunately it waits for the script to finish.

By the way, I'm also working on a command like @leavedoswindowopen {file}, so it never closes the window automatically but here I have the same issue). I tried with DOpus function (rather than ms-dos) with cmd /c but it doesn't work with @leavedswindowopen.

I can't run any other commands till the script execution is finished.

This doesn't sound right. Opus is multi-threaded, so it might slow down, but it shouldn't lock up or stall, especially when running an external batch file. Can you provide more context?

Example bat file:

pause

If I shift+enter on this file:

Until I close the cmd window, I can't:

  • hit shift+enter to open another instance of the bat script
  • change directory by double clicking it or hitting enter on a folder
  • open an image by double click (it executes show command for me)

What works fine:

  • delete button on toolbar
  • delete by file context menu
  • go to parent via double clicking on empty lister area

all the commands above are stack so they are executed when I close cmd window. This affects all tabs within a window but only one window is affected.

Shift+Enter opens a path field at the bottom of the lister by default.

If you've changed your Shift+Enter hotkey, what does it run for you?

@leavedoswindowopen affects the command prompt which Opus opens. It doesn't affect any additional command prompts or similar which anything else (including the commands you tell Opus to run) opens.

If you want cmd.exe to run a command and then not exit, you should use the /k argument instead of /c:

C:\>cmd /?
Starts a new instance of the Windows command interpreter

CMD [/A | /U] [/Q] [/D] [/E:ON | /E:OFF] [/F:ON | /F:OFF] [/V:ON | /V:OFF]
    [[/S] [/C | /K] string]

/C      Carries out the command specified by string and then terminates
/K      Carries out the command specified by string but remains
...
1 Like

Thanks for explaining leavedoswindowopen, I'll try with cmd /k.

In Customize dialog I disabled Shift+Enter shortcut so I guess it does nothing.

I think I understand what's going on now.

Double-clicks are run on a separate thread, but it will wait for the previous one to complete before allowing a new one to be run. This usually isn't something you notice, since most programs detach themselves as soon as they start, but with DOS functions it's different.

You can use @async to explicitly run something without waiting for it, but that isn't needed here.

If you want to run a .bat file and keep the command prompt open afterwards, via a double-click event, I would use this:

Standard Function: (not MS-DOS Batch)

cd {sourcepath}
/system/cmd.exe /k {filepath$}

That also takes care of setting up the current directory, and avoids any issues with a cmd.exe existing in it and hijacking the command.

1 Like

Thanks, now it works fine.

Final results, for future reference:

Ctrl+Enter for me runs BAT file hidden (I assume it will result in success so I don't need to see errors):

@runmode:hide
cd {sourcepath} 
/system/cmd.exe /c {filepath$} 

Shift+Enter runs BAT and doesn't close the window so I can always see the output/errors:

cd {sourcepath} 
/system/cmd.exe /k {filepath$} 
2 Likes