Created
November 7, 2024 16:27
-
-
Save DerfJagged/50b740d0e10901707cb7c7468edd39ad to your computer and use it in GitHub Desktop.
Run PowerShell Script from Windows ToastNotification
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This example shows a toast with a button for each day of the week. When selected, it runs a script called WindowsUpdatePS1.ps1, passing it the day of the week as an argument. | |
You have to create a registry entry for this. | |
<toast> | |
... | |
<actions> | |
<action content="Mon" arguments="ToastUpdateWindows:,Monday" activationType="protocol" /> | |
<action content="Tues" arguments="ToastUpdateWindows:,Tuesday" activationType="protocol" /> | |
<action content="Wed" arguments="ToastUpdateWindows:,Wednesday" activationType="protocol" /> | |
<action content="Thurs" arguments="ToastUpdateWindows:,Thursday" activationType="protocol" /> | |
<action content="Fri" arguments="ToastUpdateWindows:,Friday" activationType="protocol" /> | |
</actions> | |
... | |
</toast> | |
Content of Computer\HKEY_CURRENT_USER\Software\Classes\ToastUpdateWindows\shell\open\command: | |
C:\ToastNotificationScript\Scripts\WindowsUpdatePS1.cmd %1 | |
Content of WindowsUpdatePS1.cmd: | |
powershell.exe -ExecutionPolicy Bypass -File "C:\ToastNotificationScript\Scripts\WindowsUpdatePS1.ps1 | |
Content of WindowsUpdatePS1.ps1: | |
param([string]$day="NULL") | |
"$day" > C:\ToastNotificationScript\Scripts\Output.txt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment