The key is to pick-up the -quiet
flag and not display a UI, and instead just execute the action being requested.
This is exposed via the Bootstrapper base class using the DisplayMode
property, which uses a Display
enum value. Options are
public enum Display
{
Unknown,
Embedded,
None,
Passive,
Full,
}
You can then determine which action to execute via the Command.Action
value (again, in the Bootstrapper base class) which uses a LaunchAction
enum. Options are:
public enum LaunchAction
{
Unknown,
Help,
Layout,
Uninstall,
Install,
Modify,
Repair,
}
So, I've used a custom property I named RunningSilent
to detect the modes where I should not display a UI, then utilize that as shown below:
/// <summary>
/// True if running in silent display mode (ie: no UI).
/// </summary>
public virtual bool RunningSilent
{
get
{
return (DisplayMode != Display.Full && DisplayMode != Display.Passive);
}
}
protected override void Run()
{
if (RunningSilent)
{
Log("Running without UI");
LaunchAction requestedAction = Command.Action;
//... this is an async call, so handle it accordingly.
Engine.Plan(requestedAction);
//... followed by Engine.Apply();
}
else
{
Log("Showing UI window");
//.. Run your Managed UI
}
}