Run command in minimized window

I'm trying to use the Command Editor to create a menu item for quickly archiving folders for backup. My code looks like this:

@set p = {dlgstring|Enter password} 
cd {sourcepath}
"c:\Program Files\7-Zip\7z.exe" a -p"{$p}" -mhe -mx0 "{file|noext}.7z" {filepath}

This works but opens a new command line window for every execution of 7z.exe, which pops up in front of other windows. I want those windows to be minimized. Even better would be to use 7zG.exe, which gives you a graphical progress bar, minimized.

I checked the documentation here: https://www.gpsoft.com.au/help/opus12/index.html#!Documents/Advanced_Command_Editor.htm

Can't see any way of doing this. I know you can use cmd.exe to launch 7z.exe, but I want each process to run serially and cmd.exe returns immediately.

Even better would be to use the 7z support in DOpus itself, but you can't pass many parameters to it. In particular I need the password, the option to encrypt file names, and to set the compression level.

Try adding

@runmode:hide

https://www.gpsoft.com.au/help/opus12/index.html#!Documents/Command_modifier_reference.htm

1 Like

If you're using a command-line tool like 7z.exe, change the command type to MS-DOS Batch Function and it will only open a single window for the entire operation even if the tool is run multiple times.

Add @runmode:min if you want it to open minimised. (@runmode:hide will hide it completely so there's no way to see what's going on and no easy way to cancel it, which you probably don't want.)

There's no reason to involve cmd.exe if you're using 7zG.exe. It should work without it. Whether it runs in serial or in parallel is largely up to 7zG.exe but you can sometimes do things to make GUI tools wait even if they don't by default. I suspect 7zG.exe waits by default though, unless my memory is mistaken.

2 Likes

Thanks, that worked.

As for 7zG.exe, what I mean is that it opens its own window which always appears on top of everything else, and which steals focus. There doesn't seem to be a way to force it to be minimized or prevent it from stealing focus. Not a big issue if the command line version works.

By the way, when looking for a solution I found this page: Command Editor

It seems to be out of date, the Command Editor doesn't look like that in Opus 12.

What’s different? It looks like that here.

Be aware editing different buttons pull up different command editors. The Command Editor is context-aware.