Fixed an error in the custom protocols

This commit is contained in:
Martin Bengtsson 2020-09-05 08:44:55 +02:00 committed by GitHub
parent fba4bccdac
commit f18c741a79
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 54 additions and 55 deletions

View file

@ -14,7 +14,7 @@
.NOTES .NOTES
Filename: New-ToastNotification.ps1 Filename: New-ToastNotification.ps1
Version: 2.0.1 Version: 2.0.2
Author: Martin Bengtsson Author: Martin Bengtsson
Blog: www.imab.dk Blog: www.imab.dk
Twitter: @mwbengtsson Twitter: @mwbengtsson
@ -109,6 +109,9 @@
Added support for getting deadline date/time dynamically for applications Added support for getting deadline date/time dynamically for applications
- Configure DynamicDeadline with the Application ID - Configure DynamicDeadline with the Application ID
2.0.2 - Fixed an error in the custom protocols
- The path to the custom scripts was incomplete
.LINK .LINK
https://www.imab.dk/windows-10-toast-notification-script/ https://www.imab.dk/windows-10-toast-notification-script/
@ -736,13 +739,12 @@ function Write-CustomActionRegistry() {
$ActionType, $ActionType,
[Parameter(Position="1")] [Parameter(Position="1")]
[string] [string]
$RegCommandPath = $global:CustomScriptPath $RegCommandPath = $global:CustomScriptsPath
) )
Write-Log -Message "Running Write-CustomActionRegistry function: $ActionType" Write-Log -Message "Running Write-CustomActionRegistry function: $ActionType"
switch ($ActionType) { switch ($ActionType) {
ToastReboot { ToastReboot {
# Build out registry for custom action for rebooting the device via the action button # Build out registry for custom action for rebooting the device via the action button
if((Test-Path -LiteralPath "HKCU:\Software\Classes\$($ActionType)\shell\open\command") -ne $true) {
try { try {
New-Item "HKCU:\Software\Classes\$($ActionType)\shell\open\command" -Force -ErrorAction SilentlyContinue | Out-Null New-Item "HKCU:\Software\Classes\$($ActionType)\shell\open\command" -Force -ErrorAction SilentlyContinue | Out-Null
New-ItemProperty -LiteralPath "HKCU:\Software\Classes\$($ActionType)" -Name 'URL Protocol' -Value '' -PropertyType String -Force -ErrorAction SilentlyContinue | Out-Null New-ItemProperty -LiteralPath "HKCU:\Software\Classes\$($ActionType)" -Name 'URL Protocol' -Value '' -PropertyType String -Force -ErrorAction SilentlyContinue | Out-Null
@ -755,11 +757,10 @@ function Write-CustomActionRegistry() {
$ErrorMessage = $_.Exception.Message $ErrorMessage = $_.Exception.Message
Write-Log -Level Error -Message "Error message: $ErrorMessage" Write-Log -Level Error -Message "Error message: $ErrorMessage"
} }
}
} }
ToastRunUpdateID { ToastRunUpdateID {
# Build out registry for custom action for running software update via the action button # Build out registry for custom action for running software update via the action button
if((Test-Path -LiteralPath "HKCU:\Software\Classes\$($ActionType)\shell\open\command") -ne $true) {
try { try {
New-Item "HKCU:\Software\Classes\$($ActionType)\shell\open\command" -Force -ErrorAction SilentlyContinue | Out-Null New-Item "HKCU:\Software\Classes\$($ActionType)\shell\open\command" -Force -ErrorAction SilentlyContinue | Out-Null
New-ItemProperty -LiteralPath "HKCU:\Software\Classes\$($ActionType)" -Name 'URL Protocol' -Value '' -PropertyType String -Force -ErrorAction SilentlyContinue | Out-Null New-ItemProperty -LiteralPath "HKCU:\Software\Classes\$($ActionType)" -Name 'URL Protocol' -Value '' -PropertyType String -Force -ErrorAction SilentlyContinue | Out-Null
@ -772,11 +773,10 @@ function Write-CustomActionRegistry() {
$ErrorMessage = $_.Exception.Message $ErrorMessage = $_.Exception.Message
Write-Log -Level Error -Message "Error message: $ErrorMessage" Write-Log -Level Error -Message "Error message: $ErrorMessage"
} }
}
} }
ToastRunPackageID { ToastRunPackageID {
# Build out registry for custom action for running packages and task sequences via the action button # Build out registry for custom action for running packages and task sequences via the action button
if((Test-Path -LiteralPath "HKCU:\Software\Classes\$($ActionType)\shell\open\command") -ne $true) {
try { try {
New-Item "HKCU:\Software\Classes\$($ActionType)\shell\open\command" -Force -ErrorAction SilentlyContinue | Out-Null New-Item "HKCU:\Software\Classes\$($ActionType)\shell\open\command" -Force -ErrorAction SilentlyContinue | Out-Null
New-ItemProperty -LiteralPath "HKCU:\Software\Classes\$($ActionType)" -Name 'URL Protocol' -Value '' -PropertyType String -Force -ErrorAction SilentlyContinue | Out-Null New-ItemProperty -LiteralPath "HKCU:\Software\Classes\$($ActionType)" -Name 'URL Protocol' -Value '' -PropertyType String -Force -ErrorAction SilentlyContinue | Out-Null
@ -789,11 +789,10 @@ function Write-CustomActionRegistry() {
$ErrorMessage = $_.Exception.Message $ErrorMessage = $_.Exception.Message
Write-Log -Level Error -Message "Error message: $ErrorMessage" Write-Log -Level Error -Message "Error message: $ErrorMessage"
} }
}
} }
ToastRunApplicationID { ToastRunApplicationID {
# Build out registry for custom action for running applications via the action button # Build out registry for custom action for running applications via the action button
if((Test-Path -LiteralPath "HKCU:\Software\Classes\$($ActionType)\shell\open\command") -ne $true) {
try { try {
New-Item "HKCU:\Software\Classes\$($ActionType)\shell\open\command" -Force -ErrorAction SilentlyContinue | Out-Null New-Item "HKCU:\Software\Classes\$($ActionType)\shell\open\command" -Force -ErrorAction SilentlyContinue | Out-Null
New-ItemProperty -LiteralPath "HKCU:\Software\Classes\$($ActionType)" -Name 'URL Protocol' -Value '' -PropertyType String -Force -ErrorAction SilentlyContinue | Out-Null New-ItemProperty -LiteralPath "HKCU:\Software\Classes\$($ActionType)" -Name 'URL Protocol' -Value '' -PropertyType String -Force -ErrorAction SilentlyContinue | Out-Null
@ -806,7 +805,7 @@ function Write-CustomActionRegistry() {
$ErrorMessage = $_.Exception.Message $ErrorMessage = $_.Exception.Message
Write-Log -Level Error -Message "Error message: $ErrorMessage" Write-Log -Level Error -Message "Error message: $ErrorMessage"
} }
}
} }
} }
} }
@ -1085,7 +1084,7 @@ exit 0
######### GENERAL VARIABLES ######### ######### GENERAL VARIABLES #########
# Global variables # Global variables
# Setting global script version # Setting global script version
$global:ScriptVersion = "2.0.1" $global:ScriptVersion = "2.0.2"
# Setting executing directory # Setting executing directory
$global:ScriptPath = Split-Path -Parent $MyInvocation.MyCommand.Definition $global:ScriptPath = Split-Path -Parent $MyInvocation.MyCommand.Definition
# Setting global custom action script location # Setting global custom action script location

Binary file not shown.