Remove the "Remaining Deferrals" on the welcome screen (but still use Deferrals)

Hello,

Is there a way to remove the Remaining Deferrals on the initial welcome screen?
And to keep the Defer button to click on.

Thanks

Yes there is a way. Check this line from Deploy-Application.ps1

try removing the command -DeferTimes and the number beside it.

let me know how you go.

Hello,

I have tried their answer but now the installation starts all without you defer it the installation.

I tried this with the version PSAppDeployToolkit_v3.9.0 and PSAppDeployToolkit_v3.8.4 and with both the same thing happens the download now starts alone.

Had in the AppDeployToolkitMain.ps1 in the Function Show-InstallationWelcome still found a command but do not know if that has to do with why the Welcome page does not show up with defer or accept.
-AllowDefer -DeferTimes $deferTimes

Script:

 While ((Get-RunningProcesses -ProcessObjects $processObjects -OutVariable 'runningProcesses') -or (($promptResult -ne 'Defer') -and ($promptResult -ne 'Close'))) {
                [String]$runningProcessDescriptions = ($runningProcesses | Where-Object { $_.ProcessDescription } | Select-Object -ExpandProperty 'ProcessDescription' | Sort-Object -Unique) -join ','
                #  Check if we need to prompt the user to defer, to defer and close apps, or not to prompt them at all
                If ($allowDefer) {
                    #  If there is deferral and closing apps is allowed but there are no apps to be closed, break the while loop
                    If ($AllowDeferCloseApps -and (-not $runningProcessDescriptions)) {
                        Break
                    }
                    #  Otherwise, as long as the user has not selected to close the apps or the processes are still running and the user has not selected to continue, prompt user to close running processes with deferral
                    ElseIf (($promptResult -ne 'Close') -or (($runningProcessDescriptions) -and ($promptResult -ne 'Continue'))) {
                        [String]$promptResult = Show-WelcomePrompt -ProcessDescriptions $runningProcessDescriptions -CloseAppsCountdown $closeAppsCountdownGlobal -ForceCloseAppsCountdown $forceCloseAppsCountdown -ForceCountdown $forceCountdown -PersistPrompt $PersistPrompt -AllowDefer -DeferTimes $deferTimes -DeferDeadline $deferDeadlineUniversal -MinimizeWindows $MinimizeWindows -CustomText:$CustomText -TopMost $TopMost
                    }
                }

I’m not sure what you want here.

If you do not want the user to have deferrals or see a Deferral counter on the screen, then do not use the -DeferTimes parameter.

If you want the user to have deferrals but not see the Deferral counter on the screen, then you will have to edit the function in AppDeployToolkitMain.ps1

If you want the user to have deferrals but not see the Deferral counter on the screen, then you will have to edit the function in AppDeployToolkitMain.ps1

That’s what I want, but where exactly do I need to set the function in AppDeployToolkitMain.ps1 so that the user has deferrals but doesn’t see a deferral counter on the screen.

In AppDeployToolkitMain.ps1 Locate the Show-WelcomePrompt function

Locate this block of code:

		If (($allowDefer) -and (($deferTimes -ge 0) -or ($deferDeadline))) {
			Write-Log -Message 'User has the option to defer.' -Source ${CmdletName}
			$showDefer = $true
			If ($deferDeadline) {
				#  Remove the Z from universal sortable date time format, otherwise it could be converted to a different time zone
				$deferDeadline = $deferDeadline -replace 'Z',''
				#  Convert the deadline date to a string
				[string]$deferDeadline = (Get-Date -Date $deferDeadline).ToString()
			}
		}

Below this block, add the following lines:

#Hide the Deferral counter
$showDefer = $false

Thank you.

Now the defer button is missing.

image

Script:
Function Show-WelcomePrompt {

[CmdletBinding()]
Param (
    [Parameter(Mandatory = $false)]
    [String]$ProcessDescriptions,
    [Parameter(Mandatory = $false)]
    [Int32]$CloseAppsCountdown,
    [Parameter(Mandatory = $false)]
    [ValidateNotNullorEmpty()]
    [Boolean]$ForceCloseAppsCountdown,
    [Parameter(Mandatory = $false)]
    [ValidateNotNullorEmpty()]
    [Boolean]$PersistPrompt = $false,
    [Parameter(Mandatory = $false)]
    [Switch]$AllowDefer = $false,
    [Parameter(Mandatory = $false)]
    [String]$DeferTimes,
    [Parameter(Mandatory = $false)]
    [String]$DeferDeadline,
    [Parameter(Mandatory = $false)]
    [ValidateNotNullorEmpty()]
    [Boolean]$MinimizeWindows = $true,
    [Parameter(Mandatory = $false)]
    [ValidateNotNullorEmpty()]
    [Boolean]$TopMost = $true,
    [Parameter(Mandatory = $false)]
    [ValidateNotNullorEmpty()]
    [Int32]$ForceCountdown = 0,
    [Parameter(Mandatory = $false)]
    [Switch]$CustomText = $false
)

Begin {
    ## Get the name of this function and write header
    [String]${CmdletName} = $PSCmdlet.MyInvocation.MyCommand.Name
    Write-FunctionHeaderOrFooter -CmdletName ${CmdletName} -CmdletBoundParameters $PSBoundParameters -Header
}
Process {
    ## Reset switches
    [Boolean]$showCloseApps = $false
    [Boolean]$showDefer = $false
    [Boolean]$persistWindow = $false

    ## Reset times
    [DateTime]$startTime = Get-Date
    [DateTime]$countdownTime = $startTime

    ## Check if the countdown was specified
    If ($CloseAppsCountdown -and ($CloseAppsCountdown -gt $configInstallationUITimeout)) {
        Throw 'The close applications countdown time cannot be longer than the timeout specified in the XML configuration for installation UI dialogs to timeout.'
    }

   ## Initial form layout: Close Applications / Allow Deferral
    If ($processDescriptions) {
        Write-Log -Message "Prompting the user to close application(s) [$processDescriptions]..." -Source ${CmdletName}
        $showCloseApps = $true
    }
    If (($allowDefer) -and (($deferTimes -ge 0) -or ($deferDeadline))) {
        Write-Log -Message 'The user has the option to defer.' -Source ${CmdletName}
        $showDefer = $true
        If ($deferDeadline) {
            #  Remove the Z from universal sortable date time format, otherwise it could be converted to a different time zone
            $deferDeadline = $deferDeadline -replace 'Z', ''
            #  Convert the deadline date to a string
            [String]$deferDeadline = (Get-Date -Date $deferDeadline).ToString()
        }
    }
	#Hide the Deferral counter
	$showDefer = $false


    ## If deferral is being shown and 'close apps countdown' or 'persist prompt' was specified, enable those features.
    If (-not $showDefer) {
        If ($closeAppsCountdown -gt 0) {
            Write-Log -Message "Close applications countdown has [$closeAppsCountdown] seconds remaining." -Source ${CmdletName}
            $showCountdown = $true
        }
    }
    Else {
        If ($persistPrompt) {
            $persistWindow = $true
        }
    }
    ## If 'force close apps countdown' was specified, enable that feature.
    If ($forceCloseAppsCountdown -eq $true) {
        Write-Log -Message "Close applications countdown has [$closeAppsCountdown] seconds remaining." -Source ${CmdletName}
        $showCountdown = $true
    }
    ## If 'force countdown' was specified, enable that feature.
    If ($forceCountdown -eq $true) {
        Write-Log -Message "Countdown has [$closeAppsCountdown] seconds remaining." -Source ${CmdletName}
        $showCountdown = $true
    }

    [String[]]$processDescriptions = $processDescriptions -split ','
    [Windows.Forms.Application]::EnableVisualStyles()

    $formWelcome = New-Object -TypeName 'System.Windows.Forms.Form'
    $pictureBanner = New-Object -TypeName 'System.Windows.Forms.PictureBox'
    $labelWelcomeMessage = New-Object -TypeName 'System.Windows.Forms.Label'
    $labelAppName = New-Object -TypeName 'System.Windows.Forms.Label'
    $labelCustomMessage = New-Object -TypeName 'System.Windows.Forms.Label'
    $labelCloseAppsMessage = New-Object -TypeName 'System.Windows.Forms.Label'
    $labelCountdownMessage = New-Object -TypeName 'System.Windows.Forms.Label'
    $labelCountdown = New-Object -TypeName 'System.Windows.Forms.Label'
    $labelDefer = New-Object -TypeName 'System.Windows.Forms.Label'
    $listBoxCloseApps = New-Object -TypeName 'System.Windows.Forms.ListBox'
    $buttonContinue = New-Object -TypeName 'System.Windows.Forms.Button'
    $buttonDefer = New-Object -TypeName 'System.Windows.Forms.Button'
    $buttonCloseApps = New-Object -TypeName 'System.Windows.Forms.Button'
    $buttonAbort = New-Object -TypeName 'System.Windows.Forms.Button'
    $flowLayoutPanel = New-Object -TypeName 'System.Windows.Forms.FlowLayoutPanel'
    $panelButtons = New-Object -TypeName 'System.Windows.Forms.Panel'
    $toolTip = New-Object -TypeName 'System.Windows.Forms.ToolTip'

    ## Remove all event handlers from the controls
    [ScriptBlock]$Welcome_Form_Cleanup_FormClosed = {
        Try {
            $labelWelcomeMessage.remove_Click($handler_labelWelcomeMessage_Click)
            $labelAppName.remove_Click($handler_labelAppName_Click)
            $labelCustomMessage.remove_Click($handler_labelCustomMessage_Click)
            $labelCloseAppsMessage.remove_Click($handler_labelCloseAppsMessage_Click)
            $labelDefer.remove_Click($handler_labelDefer_Click)
            $labelCountdownMessage.remove_Click($handler_labelCountdownMessage_Click)
            $buttonCloseApps.remove_Click($buttonCloseApps_OnClick)
            $buttonContinue.remove_Click($buttonContinue_OnClick)
            $buttonDefer.remove_Click($buttonDefer_OnClick)
            $buttonAbort.remove_Click($buttonAbort_OnClick)
            $script:welcomeTimer.remove_Tick($welcomeTimer_Tick)
            $welcomeTimerPersist.remove_Tick($welcomeTimerPersist_Tick)
            $timerRunningProcesses.remove_Tick($timerRunningProcesses_Tick)
            $formWelcome.remove_Load($Welcome_Form_StateCorrection_Load)
            $formWelcome.remove_FormClosed($Welcome_Form_Cleanup_FormClosed)
        }
        Catch {
        }
    }

    [ScriptBlock]$Welcome_Form_StateCorrection_Load = {
        # Disable the X button
        Try {
            $windowHandle = $formWelcome.Handle
            If ($windowHandle -and ($windowHandle -ne [IntPtr]::Zero)) {
                $menuHandle = [PSADT.UiAutomation]::GetSystemMenu($windowHandle, $false)
                If ($menuHandle -and ($menuHandle -ne [IntPtr]::Zero)) {
                    [PSADT.UiAutomation]::EnableMenuItem($menuHandle, 0xF060, 0x00000001)
                    [PSADT.UiAutomation]::DestroyMenu($menuHandle)
                }
            }
        }
        Catch {
            # Not a terminating error if we can't disable the button. Just disable the Control Box instead
            Write-Log 'Failed to disable the Close button. Disabling the Control Box instead.' -Severity 2 -Source ${CmdletName}
            $formWelcome.ControlBox = $false
        }
        ## Correct the initial state of the form to prevent the .NET maximized form issue
        $formWelcome.WindowState = 'Normal'
        $formWelcome.AutoSize = $true
        $formWelcome.AutoScaleMode = 'Font'
        $formWelcome.AutoScaleDimensions = New-Object System.Drawing.SizeF(6, 13) #Set as if using 96 DPI
        $formWelcome.TopMost = $TopMost
        $formWelcome.BringToFront()
        #  Get the start position of the form so we can return the form to this position if PersistPrompt is enabled
        Set-Variable -Name 'formWelcomeStartPosition' -Value $formWelcome.Location -Scope 'Script'

        ## Initialize the countdown timer
        [DateTime]$currentTime = Get-Date
        [DateTime]$countdownTime = $startTime.AddSeconds($CloseAppsCountdown)
        $script:welcomeTimer.Start()

        ## Set up the form
        [Timespan]$remainingTime = $countdownTime.Subtract($currentTime)
        $labelCountdown.Text = [String]::Format('{0}:{1:d2}:{2:d2}', $remainingTime.Days * 24 + $remainingTime.Hours, $remainingTime.Minutes, $remainingTime.Seconds)
    }

    ## Add the timer if it doesn't already exist - this avoids the timer being reset if the continue button is clicked
    If (-not $script:welcomeTimer) {
        $script:welcomeTimer = New-Object -TypeName 'System.Windows.Forms.Timer'
    }

    If ($showCountdown) {
        [ScriptBlock]$welcomeTimer_Tick = {
            ## Get the time information
            [DateTime]$currentTime = Get-Date
            [DateTime]$countdownTime = $startTime.AddSeconds($CloseAppsCountdown)
            [Timespan]$remainingTime = $countdownTime.Subtract($currentTime)
            Set-Variable -Name 'closeAppsCountdownGlobal' -Value $remainingTime.TotalSeconds -Scope 'Script'

            ## If the countdown is complete, close the application(s) or continue
            If ($countdownTime -le $currentTime) {
                If ($forceCountdown -eq $true) {
                    Write-Log -Message 'Countdown timer has elapsed. Force continue.' -Source ${CmdletName}
                    $buttonContinue.PerformClick()
                }
                Else {
                    Write-Log -Message 'Close application(s) countdown timer has elapsed. Force closing application(s).' -Source ${CmdletName}
                    If ($buttonCloseApps.CanFocus) {
                        $buttonCloseApps.PerformClick()
                    }
                    Else {
                        $buttonContinue.PerformClick()
                    }
                }
            }
            Else {
                #  Update the form
                $labelCountdown.Text = [String]::Format('{0}:{1:d2}:{2:d2}', $remainingTime.Days * 24 + $remainingTime.Hours, $remainingTime.Minutes, $remainingTime.Seconds)
            }
        }
    }
    Else {
        $script:welcomeTimer.Interval = ($configInstallationUITimeout * 1000)
        [ScriptBlock]$welcomeTimer_Tick = { $buttonAbort.PerformClick() }
    }

    $script:welcomeTimer.add_Tick($welcomeTimer_Tick)

    ## Persistence Timer
    If ($persistWindow) {
        $welcomeTimerPersist = New-Object -TypeName 'System.Windows.Forms.Timer'
        $welcomeTimerPersist.Interval = ($configInstallationPersistInterval * 1000)
        [ScriptBlock]$welcomeTimerPersist_Tick = {
            $formWelcome.WindowState = 'Normal'
            $formWelcome.TopMost = $TopMost
            $formWelcome.BringToFront()
            $formWelcome.Location = "$($formWelcomeStartPosition.X),$($formWelcomeStartPosition.Y)"
        }
        $welcomeTimerPersist.add_Tick($welcomeTimerPersist_Tick)
        $welcomeTimerPersist.Start()
    }

    ## Process Re-Enumeration Timer
    If ($configInstallationWelcomePromptDynamicRunningProcessEvaluation) {
        $timerRunningProcesses = New-Object -TypeName 'System.Windows.Forms.Timer'
        $timerRunningProcesses.Interval = ($configInstallationWelcomePromptDynamicRunningProcessEvaluationInterval * 1000)
        [ScriptBlock]$timerRunningProcesses_Tick = {
            Try {
                $dynamicRunningProcesses = $null
                $dynamicRunningProcesses = Get-RunningProcesses -ProcessObjects $processObjects -DisableLogging
                [String]$dynamicRunningProcessDescriptions = ($dynamicRunningProcesses | Where-Object { $_.ProcessDescription } | Select-Object -ExpandProperty 'ProcessDescription' | Sort-Object -Unique) -join ','
                If ($dynamicRunningProcessDescriptions -ne $script:runningProcessDescriptions) {
                    # Update the runningProcessDescriptions variable for the next time this function runs
                    Set-Variable -Name 'runningProcessDescriptions' -Value $dynamicRunningProcessDescriptions -Force -Scope 'Script'
                    If ($dynamicRunningProcesses) {
                        Write-Log -Message "The running processes have changed. Updating the apps to close: [$script:runningProcessDescriptions]..." -Source ${CmdletName}
                    }
                    # Update the list box with the processes to close
                    $listboxCloseApps.Items.Clear()
                    $script:runningProcessDescriptions -split ',' | ForEach-Object { $null = $listboxCloseApps.Items.Add($_) }
                }
                # If CloseApps processes were running when the prompt was shown, and they are subsequently detected to be closed while the form is showing, then close the form. The deferral and CloseApps conditions will be re-evaluated.
                If ($ProcessDescriptions) {
                    If (-not $dynamicRunningProcesses) {
                        Write-Log -Message 'Previously detected running processes are no longer running.' -Source ${CmdletName}
                        $formWelcome.Dispose()
                    }
                }
                # If CloseApps processes were not running when the prompt was shown, and they are subsequently detected to be running while the form is showing, then close the form for relaunch. The deferral and CloseApps conditions will be re-evaluated.
                Else {
                    If ($dynamicRunningProcesses) {
                        Write-Log -Message 'New running processes detected. Updating the form to prompt to close the running applications.' -Source ${CmdletName}
                        $formWelcome.Dispose()
                    }
                }
            }
            Catch {
            }
        }
        $timerRunningProcesses.add_Tick($timerRunningProcesses_Tick)
        $timerRunningProcesses.Start()
    }

    ## Form

    ##----------------------------------------------
    ## Create zero px padding object
    $paddingNone = New-Object -TypeName 'System.Windows.Forms.Padding' -ArgumentList (0, 0, 0, 0)
    ## Create basic control size
    $defaultControlSize = New-Object -TypeName 'System.Drawing.Size' -ArgumentList (450, 0)

    ## Generic Button properties
    $buttonSize = New-Object -TypeName 'System.Drawing.Size' -ArgumentList (130, 24)

    ## Picture Banner
    $pictureBanner.DataBindings.DefaultDataSourceUpdateMode = 0
    $pictureBanner.ImageLocation = $appDeployLogoBanner
    $System_Drawing_Point = New-Object -TypeName 'System.Drawing.Point' -ArgumentList (0, 0)
    $pictureBanner.Location = $System_Drawing_Point
    $pictureBanner.Name = 'pictureBanner'
    $System_Drawing_Size = New-Object -TypeName 'System.Drawing.Size' -ArgumentList (450, $appDeployLogoBannerHeight)
    $pictureBanner.Size = $System_Drawing_Size
    $pictureBanner.SizeMode = 'CenterImage'
    $pictureBanner.Margin = $paddingNone
    $pictureBanner.TabStop = $false

    ## Label Welcome Message
    $labelWelcomeMessage.DataBindings.DefaultDataSourceUpdateMode = 0
    $labelWelcomeMessage.Font = $defaultFont
    $labelWelcomeMessage.Name = 'labelWelcomeMessage'
    $labelWelcomeMessage.Size = $defaultControlSize
    $labelWelcomeMessage.MinimumSize = $defaultControlSize
    $labelWelcomeMessage.MaximumSize = $defaultControlSize
    $labelWelcomeMessage.Margin = New-Object -TypeName 'System.Windows.Forms.Padding' -ArgumentList (0, 10, 0, 0)
    $labelWelcomeMessage.Padding = New-Object -TypeName 'System.Windows.Forms.Padding' -ArgumentList (10, 0, 10, 0)
    $labelWelcomeMessage.TabStop = $false
    $labelWelcomeMessage.Text = $configDeferPromptWelcomeMessage
    $labelWelcomeMessage.TextAlign = 'MiddleCenter'
    $labelWelcomeMessage.Anchor = 'Top'
    $labelWelcomeMessage.AutoSize = $true
    $labelWelcomeMessage.add_Click($handler_labelWelcomeMessage_Click)

    ## Label App Name
    $labelAppName.DataBindings.DefaultDataSourceUpdateMode = 0
    $labelAppName.Font = "$($defaultFont.Name), $($defaultFont.Size + 2), style=Bold"
    $labelAppName.Name = 'labelAppName'
    $labelAppName.Size = $defaultControlSize
    $labelAppName.MinimumSize = $defaultControlSize
    $labelAppName.MaximumSize = $defaultControlSize
    $labelAppName.Margin = New-Object -TypeName 'System.Windows.Forms.Padding' -ArgumentList (0, 5, 0, 5)
    $labelAppName.Padding = New-Object -TypeName 'System.Windows.Forms.Padding' -ArgumentList (10, 0, 10, 0)
    $labelAppName.TabStop = $false
    $labelAppName.Text = $installTitle
    $labelAppName.TextAlign = 'MiddleCenter'
    $labelAppName.Anchor = 'Top'
    $labelAppName.AutoSize = $true
    $labelAppName.add_Click($handler_labelAppName_Click)

    ## Label CustomMessage
    $labelCustomMessage.DataBindings.DefaultDataSourceUpdateMode = 0
    $labelCustomMessage.Font = $defaultFont
    $labelCustomMessage.Name = 'labelCustomMessage'
    $labelCustomMessage.Size = $defaultControlSize
    $labelCustomMessage.MinimumSize = $defaultControlSize
    $labelCustomMessage.MaximumSize = $defaultControlSize
    $labelCustomMessage.Margin = New-Object -TypeName 'System.Windows.Forms.Padding' -ArgumentList (0, 0, 0, 5)
    $labelCustomMessage.Padding = New-Object -TypeName 'System.Windows.Forms.Padding' -ArgumentList (10, 0, 10, 0)
    $labelCustomMessage.TabStop = $false
    $labelCustomMessage.Text = $configClosePromptMessage
    $labelCustomMessage.TextAlign = 'MiddleCenter'
    $labelCustomMessage.Anchor = 'Top'
    $labelCustomMessage.AutoSize = $true
    $labelCustomMessage.add_Click($handler_labelCustomMessage_Click)

    ## Label CloseAppsMessage
    $labelCloseAppsMessage.DataBindings.DefaultDataSourceUpdateMode = 0
    $labelCloseAppsMessage.Font = $defaultFont
    $labelCloseAppsMessage.Name = 'labelCloseAppsMessage'
    $labelCloseAppsMessage.Size = $defaultControlSize
    $labelCloseAppsMessage.MinimumSize = $defaultControlSize
    $labelCloseAppsMessage.MaximumSize = $defaultControlSize
    $labelCloseAppsMessage.Margin = New-Object -TypeName 'System.Windows.Forms.Padding' -ArgumentList (0, 0, 0, 5)
    $labelCloseAppsMessage.Padding = New-Object -TypeName 'System.Windows.Forms.Padding' -ArgumentList (10, 0, 10, 0)
    $labelCloseAppsMessage.TabStop = $false
    $labelCloseAppsMessage.Text = $configClosePromptMessage
    $labelCloseAppsMessage.TextAlign = 'MiddleCenter'
    $labelCloseAppsMessage.Anchor = 'Top'
    $labelCloseAppsMessage.AutoSize = $true
    $labelCloseAppsMessage.add_Click($handler_labelCloseAppsMessage_Click)

    ## Listbox Close Applications
    $listBoxCloseApps.DataBindings.DefaultDataSourceUpdateMode = 0
    $listboxCloseApps.Font = $defaultFont
    $listBoxCloseApps.FormattingEnabled = $true
    $listBoxCloseApps.HorizontalScrollbar = $true
    $listBoxCloseApps.Name = 'listBoxCloseApps'
    $System_Drawing_Size = New-Object -TypeName 'System.Drawing.Size' -ArgumentList (420, 100)
    $listBoxCloseApps.Size = $System_Drawing_Size
    $listBoxCloseApps.Margin = New-Object -TypeName 'System.Windows.Forms.Padding' -ArgumentList (15, 0, 15, 0)
    $listBoxCloseApps.Padding = New-Object -TypeName 'System.Windows.Forms.Padding' -ArgumentList (10, 0, 10, 0)
    $listBoxCloseApps.TabIndex = 3
    $ProcessDescriptions | ForEach-Object { $null = $listboxCloseApps.Items.Add($_) }

    ## Label Defer
    $labelDefer.DataBindings.DefaultDataSourceUpdateMode = 0
    $labelDefer.Font = $defaultFont
    $labelDefer.Name = 'labelDefer'
    $labelDefer.Size = $defaultControlSize
    $labelDefer.MinimumSize = $defaultControlSize
    $labelDefer.MaximumSize = $defaultControlSize
    $labelDefer.Margin = New-Object -TypeName 'System.Windows.Forms.Padding' -ArgumentList (0, 0, 0, 5)
    $labelDefer.Padding = New-Object -TypeName 'System.Windows.Forms.Padding' -ArgumentList (10, 0, 10, 0)
    $labelDefer.TabStop = $false
    $deferralText = "$configDeferPromptExpiryMessage`r`n"

    If ($deferTimes -ge 0) {
        $deferralText = "$deferralText `r`n$configDeferPromptRemainingDeferrals $([Int32]$deferTimes + 1)"
    }
    If ($deferDeadline) {
        $deferralText = "$deferralText `r`n$configDeferPromptDeadline $deferDeadline"
    }
    If (($deferTimes -lt 0) -and (-not $DeferDeadline)) {
        $deferralText = "$deferralText `r`n$configDeferPromptNoDeadline"
    }
    $deferralText = "$deferralText `r`n`r`n$configDeferPromptWarningMessage"
    $labelDefer.Text = $deferralText
    $labelDefer.TextAlign = 'MiddleCenter'
    $labelDefer.AutoSize = $true
    $labelDefer.add_Click($handler_labelDefer_Click)

    ## Label CountdownMessage
    $labelCountdownMessage.DataBindings.DefaultDataSourceUpdateMode = 0
    $labelCountdownMessage.Name = 'labelCountdownMessage'
    $labelCountdownMessage.Font = "$($defaultFont.Name), $($defaultFont.Size + 2), style=Regular"
    $labelCountdownMessage.Size = $defaultControlSize
    $labelCountdownMessage.MinimumSize = $defaultControlSize
    $labelCountdownMessage.MaximumSize = $defaultControlSize
    $labelCountdownMessage.Margin = $paddingNone
    $labelCountdownMessage.Padding = New-Object -TypeName 'System.Windows.Forms.Padding' -ArgumentList (10, 0, 10, 0)
    $labelCountdownMessage.TabStop = $false
    If (($forceCountdown -eq $true) -or (-not $script:runningProcessDescriptions)) {
        Switch ($deploymentType) {
            'Uninstall' {
                $labelCountdownMessage.Text = ($configWelcomePromptCountdownMessage -f $configDeploymentTypeUninstall); Break
            }
            'Repair' {
                $labelCountdownMessage.Text = ($configWelcomePromptCountdownMessage -f $configDeploymentTypeRepair); Break
            }
            Default {
                $labelCountdownMessage.Text = ($configWelcomePromptCountdownMessage -f $configDeploymentTypeInstall); Break
            }
        }
    }
    Else {
        $labelCountdownMessage.Text = $configClosePromptCountdownMessage
    }
    $labelCountdownMessage.TextAlign = 'MiddleCenter'
    $labelCountdownMessage.Anchor = 'Top'
    $labelCountdownMessage.AutoSize = $true
    $labelCountdownMessage.add_Click($handler_labelCountdownMessage_Click)

    ## Label Countdown
    $labelCountdown.DataBindings.DefaultDataSourceUpdateMode = 0
    $labelCountdown.Name = 'labelCountdown'
    $labelCountdown.Font = "$($defaultFont.Name), $($defaultFont.Size + 9), style=Bold"
    $labelCountdown.Size = $defaultControlSize
    $labelCountdown.MinimumSize = $defaultControlSize
    $labelCountdown.MaximumSize = $defaultControlSize
    $labelCountdown.Margin = $paddingNone
    $labelCountdown.Padding = New-Object -TypeName 'System.Windows.Forms.Padding' -ArgumentList (10, 0, 10, 0)
    $labelCountdown.TabStop = $false
    $labelCountdown.Text = '00:00:00'
    $labelCountdown.TextAlign = 'MiddleCenter'
    $labelCountdown.AutoSize = $true
    $labelCountdown.add_Click($handler_labelDefer_Click)

    ## Panel Flow Layout
    $System_Drawing_Point = New-Object -TypeName 'System.Drawing.Point' -ArgumentList (0, $appDeployLogoBannerHeight)
    $flowLayoutPanel.Location = $System_Drawing_Point
    $flowLayoutPanel.MinimumSize = $DefaultControlSize
    $flowLayoutPanel.MaximumSize = $DefaultControlSize
    $flowLayoutPanel.Size = $DefaultControlSize
    $flowLayoutPanel.Margin = $paddingNone
    $flowLayoutPanel.Padding = $paddingNone
    $flowLayoutPanel.AutoSizeMode = 'GrowAndShrink'
    $flowLayoutPanel.AutoSize = $true
    $flowLayoutPanel.Anchor = 'Top'
    $flowLayoutPanel.FlowDirection = 'TopDown'
    $flowLayoutPanel.WrapContents = $true
    $flowLayoutPanel.Controls.Add($labelWelcomeMessage)
    $flowLayoutPanel.Controls.Add($labelAppName)

    If ($CustomText -and $configWelcomePromptCustomMessage) {
        $labelCustomMessage.Text = $configWelcomePromptCustomMessage
        $flowLayoutPanel.Controls.Add($labelCustomMessage)
    }
    If ($showCloseApps) {
        $flowLayoutPanel.Controls.Add($labelCloseAppsMessage)
        $flowLayoutPanel.Controls.Add($listBoxCloseApps)
    }
    If ($showDefer) {
        $flowLayoutPanel.Controls.Add($labelDefer)
    }
    If ($showCountdown) {
        $flowLayoutPanel.Controls.Add($labelCountdownMessage)
        $flowLayoutPanel.Controls.Add($labelCountdown)
    }

    ## Button Close For Me
    $buttonCloseApps.DataBindings.DefaultDataSourceUpdateMode = 0
    $buttonCloseApps.Location = New-Object -TypeName 'System.Drawing.Point' -ArgumentList (14, 4)
    $buttonCloseApps.Font = $defaultFont
    $buttonCloseApps.Name = 'buttonCloseApps'
    $buttonCloseApps.Size = $buttonSize
    $buttonCloseApps.MinimumSize = $buttonSize
    $buttonCloseApps.MaximumSize = $buttonSize
    $buttonCloseApps.TabIndex = 1
    $buttonCloseApps.Text = $configClosePromptButtonClose
    $buttonCloseApps.DialogResult = 'Yes'
    $buttonCloseApps.AutoSize = $true
    $buttonCloseApps.Margin = $paddingNone
    $buttonCloseApps.Padding = $paddingNone
    $buttonCloseApps.UseVisualStyleBackColor = $true
    $buttonCloseApps.add_Click($buttonCloseApps_OnClick)

    ## Button Defer
    $buttonDefer.DataBindings.DefaultDataSourceUpdateMode = 0
    If (-not $showCloseApps) {
        $buttonDefer.Location = New-Object -TypeName 'System.Drawing.Point' -ArgumentList (14, 4)
    }
    Else {
        $buttonDefer.Location = New-Object -TypeName 'System.Drawing.Point' -ArgumentList (160, 4)
    }
    $buttonDefer.Name = 'buttonDefer'
    $buttonDefer.Font = $defaultFont
    $buttonDefer.Size = $buttonSize
    $buttonDefer.MinimumSize = $buttonSize
    $buttonDefer.MaximumSize = $buttonSize
    $buttonDefer.TabIndex = 0
    $buttonDefer.Text = $configClosePromptButtonDefer
    $buttonDefer.DialogResult = 'No'
    $buttonDefer.AutoSize = $true
    $buttonDefer.Margin = $paddingNone
    $buttonDefer.Padding = $paddingNone
    $buttonDefer.UseVisualStyleBackColor = $true
    $buttonDefer.add_Click($buttonDefer_OnClick)

    ## Button Continue
    $buttonContinue.DataBindings.DefaultDataSourceUpdateMode = 0
    $buttonContinue.Location = New-Object -TypeName 'System.Drawing.Point' -ArgumentList (306, 4)
    $buttonContinue.Name = 'buttonContinue'
    $buttonContinue.Font = $defaultFont
    $buttonContinue.Size = $buttonSize
    $buttonContinue.MinimumSize = $buttonSize
    $buttonContinue.MaximumSize = $buttonSize
    $buttonContinue.TabIndex = 2
    $buttonContinue.Text = $configClosePromptButtonContinue
    $buttonContinue.DialogResult = 'OK'
    $buttonContinue.AutoSize = $true
    $buttonContinue.Margin = $paddingNone
    $buttonContinue.Padding = $paddingNone
    $buttonContinue.UseVisualStyleBackColor = $true
    $buttonContinue.add_Click($buttonContinue_OnClick)
    If ($showCloseApps) {
        #  Add tooltip to Continue button
        $toolTip.BackColor = [Drawing.Color]::LightGoldenrodYellow
        $toolTip.IsBalloon = $false
        $toolTip.InitialDelay = 100
        $toolTip.ReshowDelay = 100
        $toolTip.SetToolTip($buttonContinue, $configClosePromptButtonContinueTooltip)
    }

    ## Button Abort (Hidden)
    $buttonAbort.DataBindings.DefaultDataSourceUpdateMode = 0
    $buttonAbort.Name = 'buttonAbort'
    $buttonAbort.Font = $defaultFont
    $buttonAbort.Size = New-Object -TypeName 'System.Drawing.Size' -ArgumentList (0, 0)
    $buttonAbort.MinimumSize = New-Object -TypeName 'System.Drawing.Size' -ArgumentList (0, 0)
    $buttonAbort.MaximumSize = New-Object -TypeName 'System.Drawing.Size' -ArgumentList (0, 0)
    $buttonAbort.BackColor = [System.Drawing.Color]::Transparent
    $buttonAbort.ForeColor = [System.Drawing.Color]::Transparent
    $buttonAbort.FlatAppearance.BorderSize = 0
    $buttonAbort.FlatAppearance.MouseDownBackColor = [System.Drawing.Color]::Transparent
    $buttonAbort.FlatAppearance.MouseOverBackColor = [System.Drawing.Color]::Transparent
    $buttonAbort.FlatStyle = [System.Windows.Forms.FlatStyle]::System
    $buttonAbort.TabStop = $false
    $buttonAbort.DialogResult = 'Abort'
    $buttonAbort.Visible = $true # Has to be set visible so we can call Click on it
    $buttonAbort.Margin = $paddingNone
    $buttonAbort.Padding = $paddingNone
    $buttonAbort.UseVisualStyleBackColor = $true
    $buttonAbort.add_Click($buttonAbort_OnClick)

And the script of Deploy-Application.ps1

[CmdletBinding()]
Param (
[Parameter(Mandatory = $false)]
[ValidateSet(‘Install’, ‘Uninstall’, ‘Repair’)]
[String]$DeploymentType = ‘Install’,
[Parameter(Mandatory = $false)]
[ValidateSet(‘Interactive’, ‘Silent’, ‘NonInteractive’)]
[String]$DeployMode = ‘Interactive’,
[Parameter(Mandatory = $false)]
[switch]$AllowRebootPassThru = $false,
[Parameter(Mandatory = $false)]
[switch]$TerminalServerMode = $false,
[Parameter(Mandatory = $false)]
[switch]$DisableLogging = $false
)

Try {
## Set the script execution policy for this process
Try {
Set-ExecutionPolicy -ExecutionPolicy ‘ByPass’ -Scope ‘Process’ -Force -ErrorAction ‘Stop’
}
Catch {
}

##*===============================================
##* VARIABLE DECLARATION
##*===============================================
## Variables: Application
[String]$appVendor = ''
[String]$appName = ''
[String]$appVersion = ''
[String]$appArch = ''
[String]$appLang = 'EN'
[String]$appRevision = '01'
[String]$appScriptVersion = '1.0.0'
[String]$appScriptDate = 'XX/XX/20XX'
[String]$appScriptAuthor = '<author name>'
##*===============================================
## Variables: Install Titles (Only set here to override defaults set by the toolkit)
[String]$installName = ''
[String]$installTitle = ''

##* Do not modify section below
#region DoNotModify

## Variables: Exit Code
[Int32]$mainExitCode = 0

## Variables: Script
[String]$deployAppScriptFriendlyName = 'Deploy Application'
[Version]$deployAppScriptVersion = [Version]'3.9.0'
[String]$deployAppScriptDate = '10/01/2023'
[Hashtable]$deployAppScriptParameters = $PsBoundParameters

## Variables: Environment
If (Test-Path -LiteralPath 'variable:HostInvocation') {
    $InvocationInfo = $HostInvocation
}
Else {
    $InvocationInfo = $MyInvocation
}
[String]$scriptDirectory = Split-Path -Path $InvocationInfo.MyCommand.Definition -Parent

## Dot source the required App Deploy Toolkit Functions
Try {
    [String]$moduleAppDeployToolkitMain = "$scriptDirectory\AppDeployToolkit\AppDeployToolkitMain.ps1"
    If (-not (Test-Path -LiteralPath $moduleAppDeployToolkitMain -PathType 'Leaf')) {
        Throw "Module does not exist at the specified location [$moduleAppDeployToolkitMain]."
    }
    If ($DisableLogging) {
        . $moduleAppDeployToolkitMain -DisableLogging
    }
    Else {
        . $moduleAppDeployToolkitMain
    }
}
Catch {
    If ($mainExitCode -eq 0) {
        [Int32]$mainExitCode = 60008
    }
    Write-Error -Message "Module [$moduleAppDeployToolkitMain] failed to load: `n$($_.Exception.Message)`n `n$($_.InvocationInfo.PositionMessage)" -ErrorAction 'Continue'
    ## Exit the script, returning the exit code to SCCM
    If (Test-Path -LiteralPath 'variable:HostInvocation') {
        $script:ExitCode = $mainExitCode; Exit
    }
    Else {
        Exit $mainExitCode
    }
}

#endregion
##* Do not modify section above
##*===============================================
##* END VARIABLE DECLARATION
##*===============================================

If ($deploymentType -ine 'Uninstall' -and $deploymentType -ine 'Repair') {
    ##*===============================================
    ##* PRE-INSTALLATION
    ##*===============================================
    [String]$installPhase = 'Pre-Installation'

    ## Show Welcome Message, close Internet Explorer if required, allow up to 3 deferrals, verify there is enough disk space to complete the install, and persist the prompt
    Show-InstallationWelcome -CloseApps 'iexplore' -AllowDefer -DeferTimes 3 -CheckDiskSpace -PersistPrompt


    ## Show Progress Message (with the default message)
    Show-InstallationProgress

    ## <Perform Pre-Installation tasks here>


    ##*===============================================
    ##* INSTALLATION
    ##*===============================================
    [String]$installPhase = 'Installation'

    ## Handle Zero-Config MSI Installations
    If ($useDefaultMsi) {
        [Hashtable]$ExecuteDefaultMSISplat = @{ Action = 'Install'; Path = $defaultMsiFile }; If ($defaultMstFile) {
            $ExecuteDefaultMSISplat.Add('Transform', $defaultMstFile)
        }
        Execute-MSI @ExecuteDefaultMSISplat; If ($defaultMspFiles) {
            $defaultMspFiles | ForEach-Object { Execute-MSI -Action 'Patch' -Path $_ }
        }
    }

    ## <Perform Installation tasks here>


    ##*===============================================
    ##* POST-INSTALLATION
    ##*===============================================
    [String]$installPhase = 'Post-Installation'

    ## <Perform Post-Installation tasks here>

:man_facepalming:
Hi Lena,

Undo the changes I gave you before.

Then, comment out this one line:

If ($showDefer) { $flowLayoutPanel.Controls.Add($labelDefer) }

This will only prevent the Deferral counter from showing.

Thank you :slight_smile:

It works.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.