MS-DOS function - How to run commands in one order?

Hi,

I don't understand why the .bat runs after the last @confirm "Backup done":

With or without @sync - no luck. :frowning:

@leavedoswindowopen
@admin
@confirm:Have you closed all open programs?
REM Call batch program
@sync:"L:\xxx\BackupSettings.bat"
@confirm:Backup done|OK
REM # END

At first the 2 confirmations run, then UAC prompt for admin, then the .bat, DOS windows stays open (as I want), type "exit", finished - finally not that what I want. :wink:

What I'm doing wrong?

Thanks

Interweaving DOS-Batch and @modifier lines is not supported; all the @modifier stuff will be processed first, then the temporary batch file is built and run.

You could do something like this, as a Standard Function (not DOS-Batch):

@admin
@confirm:Have you closed all open programs?
@sync:cmd /k "L:\xxx\BackupSettings.bat"
@confirm:Backup done|OK

But then the second confirmation won't appear until the command prompt is closed, since it will be waiting for the cmd.exe to finish.

I think the only way to do what you want (keeping the command prompt open after the external .bat file runs, but displaying a message box when that .bat completes, before the command prompt is closed) would be to display the second message box via a DOS command (either in the .bat file or in the button, going back to the DOS-Batch mode).

e.g.

DOS-Batch:
(EDIT: Better version of this in the reply below.)

@leavedoswindowopen
@admin
@confirm:Have you closed all open programs?
call "L:\xxx\BackupSettings.bat"
msg %username% Backup Done

(Or the msg command could be moved into the .bat file.)

Personally, I'd get rid of the .bat file and avoid DOS-Batch buttons entirely, and replace both with some JScript, which can display message boxes and do its own flow control. DOS-Batch is best avoided. But how suitable that advice is may depend on what's in the .bat file.

I just realised you can run @confirm from a DOS command, so the second message box can be done in the same style, and via Opus, as the first one:

DOS-Batch:

@leavedoswindowopen
@admin
@confirm:Have you closed all open programs?
call "L:\xxx\BackupSettings.bat"
{alias|home}dopusrt.exe /acmd @confirm:Backup Done^|OK

That gives you exactly what you were trying to do.

(The | needs to be escaped as ^| to prevent DOS interpreting it as a redirection pipe.)

Thanks a lot expert Leo for the various solutions.

You are right - I will move my old .bat to jscript. Time to do it. :slight_smile: