Win10 Toast Notification with Schedule buttton to pick a time #179
Replies: 1 comment
-
Not task scheduler, but you can get a visual time picker (easy to add date too) Add-Type -AssemblyName System.Windows.Forms #DateTimePicker control with UpDown style for hour and minute Create a button to confirm selected time$button = New-Object System.Windows.Forms.Button Add controls to the form$form.Controls.Add($dateTimePicker) Display the form and wait for user input$result = $form.ShowDialog() Process the user's choiceif ($result -eq [System.Windows.Forms.DialogResult]::OK) {
} |
Beta Was this translation helpful? Give feedback.
-
Function of Script: 1) It displays Notification with 2 buttions (Snooze & Install Now).
-> Snooze button - is for snoozing notification for specified time.
-> Install Now Button - will trigger a Powershell Script to run in background to install a patch.
Question: How do we add schedule button to pick a time & date(calender) and pass it to Script to run at scheduled time using Task Scheduler.
``
Install-Module -Name BurntToast
Install-module -Name RunAsUser
#Checking if ToastReboot:// protocol handler is present
New-PSDrive -Name HKCR -PSProvider Registry -Root HKEY_CLASSES_ROOT -erroraction silentlycontinue | out-null
$ProtocolHandler = get-item 'HKCR:\ToastReboot' -erroraction 'silentlycontinue'
if (!$ProtocolHandler) {
#create handler for reboot
New-item 'HKCR:\ToastReboot' -force
set-itemproperty 'HKCR:\ToastReboot' -name '(DEFAULT)' -value 'url:ToastReboot' -force
set-itemproperty 'HKCR:\ToastReboot' -name 'URL Protocol' -value '' -force
new-itemproperty -path 'HKCR:\ToastReboot' -propertytype dword -name 'EditFlags' -value 2162688
New-item 'HKCR:\ToastReboot\Shell\Open\command' -force
#set-itemproperty 'HKCR:\ToastReboot\Shell\Open\command' -name '(DEFAULT)' -value 'C:\Windows\System32\shutdown.exe -r -t 00' -force
set-itemproperty 'HKCR:\ToastReboot\Shell\Open\command' -name '(DEFAULT)' -value 'c:\windows\system32\WindowsPowerShell\v1.0\powershell.exe C:\Patching_Automation\Install_AvailableUpdate.ps1' -force
}
``
Beta Was this translation helpful? Give feedback.
All reactions