I’ve been requested to add an “ok” button during the progress install window, as apparently even though management approved the interface we’re using, they don’t want the window to stay on screen for a whole 5 minutes.
They want the ability to dismiss the progress window while still allowing the rest of the “job” to continue. So whether it be an X on the top of the window or a close button, either will work.
# Disable the X button
try {
$windowHandle = (New-Object -TypeName System.Windows.Interop.WindowInteropHelper -ArgumentList $this).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 close button
Write-Log "Failed to disable the Close button." -Severity 2 -Source ${CmdletName}
}
I don’t know how to add a button (yet…). Just add a “minimize” option to the progress window. Change the line from “NoResize” to “CanMinimize” in the main.ps1: