Added CustomAction and Detection

Added functionality for custom actions and detection so you can have the toast display if a script returns a $true  It can then build and run a custom protocol.

The main goal here is to be able to create flexibility to toast for any custom action.  And if desired, build a custom action protocol for that execution.

## Config XML Changes
* CustomActions element area.  This includes the DetectionScript, Action, and optional ExecutionScript
** If the ExecutionScript is enabled, a new protocol with the Action Name is created.  Note that you have to set the Action element to match the named custom action here if you want to use it.
## New Variables
* CustomActionsEnabled - Enables/Disables the custom action
* CustomDetection - The destection script.
* CustomAction - The XML that contains the action name and Script.
* CustomActionName - The name of the custom action.
## Functions
* Write-FullCustomAction - Writes the action script to the requested directory for the protocol to reference.
* Write-FullCustomProtocol - Writes the protocol information into the registry so the action can be called from there.
## New Check
* Additional Check for conflicts with custom actions being enabled.
## Misc
* Code for determining  the results of custom actions, if enabled.
* Custom action Toast display section.
* modified default toast to not display when custom actions are enabled.
This commit is contained in:
Paul Wetter 2020-10-17 01:15:25 -05:00
parent 8253af7675
commit 94625157ca
3 changed files with 286 additions and 33 deletions

View file

@ -23,11 +23,21 @@
<Option Name="CustomAudio" Enabled="False" /> <!-- Enable or disable a custom speak scenario, where the text will be read out aloud -->
<Option Name="LogoImageName" Value="ToastLogoImageDefault.jpg" /> <!-- File name of the image shown as logo in the toast notoification -->
<Option Name="HeroImageName" Value="ToastHeroImageDefault.jpg" /> <!-- File name of the image shown in the top of the toast notification -->
<Option Name="ActionButton" Enabled="True" /> <!-- Enables or disables the action button. -->
<Option Name="ActionButton" Enabled="False" /> <!-- Enables or disables the action button. -->
<Option Name="DismissButton" Enabled="True" /> <!-- Enables or disables the dismiss button. -->
<Option Name="SnoozeButton" Enabled="False" /> <!-- Enabling this option will always enable action button and dismiss button -->
<Option Name="Scenario" Type="reminder" /> <!-- Possible values are: reminder | short | long -->
<Option Name="Scenario" Type="long" /> <!-- Possible values are: reminder | short | long -->
<Option Name="Action" Value="ToastReboot:" /> <!-- Action taken when using the Action button. Can be any protocol in Windows -->
<CustomActions Enabled="True">
<Action Name="LaunchAppRepair">
<DetectionScript>
Test-Path 'C:\Windows\System32' -ErrorAction Ignore
</DetectionScript>
<!--This script should always return a boolean True or False to properly evaluate-->
<ExecutionScript>
</ExecutionScript>
</Action>
</CustomActions>
<Text Option="GreetGivenName" Enabled="True" /> <!-- Displays the toast with a personal greeting using the users given name retrieved from AD. Will try retrieval from WMI of no local AD -->
<Text Option="MultiLanguageSupport" Enabled="False" /> <!-- Enable support for multiple languages. If set to True, the toast notification will look for the users language culture within the config file -->
<en-US> <!-- Default fallback language. This language will be used if MultiLanguageSupport is set to False or if no matching language is found -->