Command.RunCommand DOS command without window closing

I'm trying to call a DOS command, ffmpeg.exe to be precise, to merge some video files.

The script contains the following commands in an OnClick function. Dropped some lines for easier reading.

...
var cmd = clickData.func.command;
var fs = DOpus.FSUtil.OpenFile(clickData.func.sourcetab.path + "\\mergelist.tmp", "w");
...
var tmpfile = '"' + fs + '"';
var dos_cmd = "J:\\test\\ffmpeg.exe -y -f concat -safe 0 -i \"" + tmpfile + "\" -c copy \"Merged.mp4\"";
cmd.RunCommand(dos_cmd);

When executing this command from a Windows command prompt, it gets executed. However, when running it from the DO command editor or from a button, a new window opens for a millisecond and closes immediately, without running ffmpeg.exe.

Can I somehow debug this situation, e.g. force the window that pops up for the glimpse of a second to stay active? Or does sbdy. spot my error in above coding?

Another question: is there any script command to add double quotes to a path as in line var tmpfile = '"' + fs + '"';
Next, is there a script command to add a backslash without coding this manually, as in + "\\mergelist.tmp", "w");

If the window flashes on screen for a moment, the exe you ran probably didn't do anything and already finished. It may have displayed an error message, but Windows will close the output window automatically by default.

The command object can be set to MS-DOS Batch Function mode the same as a button. See the SetType method in the manual.

You can also use most of the @modifiers on it which work with buttons. See the SetModifier method, and use leavedoswindowopen with it if you don't want the command prompt to close.

Sorry for confusion, spotted the error myself. It was here -i \"" + tmpfile + "\"
The var tmpfile already contained double quotes that were once again doubled by this code above.

Nevertheless, still interested in :smiley:
is there any script command to add double quotes to a path as in line var tmpfile = '"' + fs + '"';
Next, is there a script command to add a backslash without coding this manually, as in + "\\mergelist.tmp", "w");

You don't need one. :slight_smile: Just add them the way you're doing it already.

FSUtil has methods for adding components to paths, but there's not usually any reason not to just do it the way you are doing. It won't make the script any simpler.

1 Like