Enable the close "X" button in Show-InstallationPrompt

Hello guys. Need to configure Show-InstallationPrompt close “X” button to be active and close the Show-InstallationPrompt window. Thanks

Personally, I would just use one of the 3 buttons.

But if you want to bring back the X button, try to edit AppDeployToolkitMain.ps1 and comment out these lines in the Show-InstallationPrompt function:

            # Disable the X button
            Try {
                $windowHandle = $formInstallationPrompt.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}
                $formInstallationPrompt.ControlBox = $false
            }

Thanks for your response. I did it already and set to $true in these lines:

$menuHandle = [PSADT.UiAutomation]::GetSystemMenu($windowHandle, $true)
 # 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}
                $formInstallationPrompt.ControlBox = $true

After that the “X” button became active and now I can push it, but it doesn’t close the window. Any ideas…?

Please note that I did not say to change the code.

I said to comment it out as in the ENTIRE Try/Catch statement.
Put <# at the top
and #> at the bottom

Or even delete the Try/Catch.

1 Like

Hi. Commented out as you wrote, but no result - the X button doesn’t close the window. And one more thing - it looks like it closes and opens again immediately.

чт, 4 янв. 2024 г. в 18:17, That-Annoying-Guy via PSAppDeployToolkit Community <notifications@psappdeploytoolkit.discoursemail.com>:

On top of commenting out the section described by @That-Annoying-Guy, add the following:

1 Like

Hi. Thanks for your reply, but this didn’t help :frowning: