How to Use Batch Actions |
.bat
) file and then run that batch file. However, AeTrayMenu gives you a way to include those batches in the configration file, in order to keep your configuration centralized: multi
actions.
multi
action to a menu item, like this:
[Menu.Left]
Type: item; Caption: "Run Multiple Commands"; Action: multi; Actions: MultiActions
This tells AeTrayMenu to look in a section called [MultiActions]
for the actions that have to be performed when the user chooses the menu item.
In such a batch actions section, you list the actions. It is like listing a menu, but without the Type
, Caption
and Glyph
parameters. For example:
[MultiActions]
Action: run; FileName: "%Windows%\Notepad.exe"
Action: run; FileName: "%Windows%\Calc.exe"
This example opens both Notepad and Calculator.
For those situations, the actions run
, shellexecute
and service
have the waituntilterminated
flag. You could for example enter:
[MultiActions]
Action: run; FileName: "%Windows%\Notepad.exe"; Flags: waituntilterminated
Action: run; FileName: "%Windows%\Calc.exe"
in the configuration file, so that Calculator will be run after Notepad has closed.
Another flag, waituntilinputidle
, is supported only by run
and shellexecute
. It suspends execution of the batch actions until the program/document that is executed is ready for user input.
ignoreerrors
flag. An example:
[MultiActions]
Action: service; Service: apache2; ServiceAction: startresume; Flags: ignoreerrors
Action: service; Service: mysql; ServiceAction: startresume; Flags: ignoreerrors
A good example of where this may be useful is a service controller. Suppose you can't be sure that all services exist, but you want to be able to start all existing services. You'd have to somehow dynamically adapt the above section depending on which services exist and which don't. However, by using the ignoreerrors
flag, you can just attempt starting them all, without bothering about error messages.
-quit
command-line parameter, but what to do when attempting to uninstall a service from within the traymenu itself?
For this purpose, two special actions are available: closeservices
and resetservices
. closeservices
will let the traymenu close its handles, while resetservices
will re-open them (if possible). An example of their usage:
[MultiActions]
Action: closeservices
Action: run; FileName: "%Apache%\bin\Apache.exe"; Parameters: "-k uninstall"
Action: resetservices
Always be sure to call resetservices
as well, otherwise the user won't be able to control any of the services!