Key combos like CTRL+C no longer close the window after script execution (#47)

This commit is contained in:
Raphire
2024-04-05 18:26:58 +02:00
parent f878ebf6fd
commit be3993e632

View File

@@ -433,6 +433,16 @@ function PrintFromFile {
} }
function AwaitKeyToExit {
# Suppress prompt if Silent parameter was passed
if (-not $Silent) {
Write-Output ""
Write-Output "Press any key to exit..."
$null = [System.Console]::ReadKey()
}
}
# Check if winget is installed # Check if winget is installed
if (Get-AppxPackage -Name "*Microsoft.DesktopAppInstaller*") { if (Get-AppxPackage -Name "*Microsoft.DesktopAppInstaller*") {
$global:wingetInstalled = $true $global:wingetInstalled = $true
@@ -489,12 +499,7 @@ if ($RunAppConfigurator) {
Write-Output "Your app selection was saved to the 'CustomAppsList' file in the root folder of the script." Write-Output "Your app selection was saved to the 'CustomAppsList' file in the root folder of the script."
} }
# Suppress prompt if Silent parameter was passed AwaitKeyToExit
if (-not $Silent) {
Write-Output ""
Write-Output "Press any key to exit..."
$null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
}
# Exit script # Exit script
Exit Exit
@@ -910,12 +915,7 @@ else {
if ($SPParamCount -eq $global:Params.Keys.Count) { if ($SPParamCount -eq $global:Params.Keys.Count) {
Write-Output "The script completed without making any changes." Write-Output "The script completed without making any changes."
# Suppress prompt if Silent parameter was passed AwaitKeyToExit
if (-not $Silent) {
Write-Output ""
Write-Output "Press any key to exit..."
$null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
}
} }
else { else {
# Execute all selected/provided parameters # Execute all selected/provided parameters
@@ -1095,10 +1095,5 @@ else {
Write-Output "" Write-Output ""
Write-Output "Script completed successfully!" Write-Output "Script completed successfully!"
# Suppress prompt if Silent parameter was passed AwaitKeyToExit
if (-not $Silent) {
Write-Output ""
Write-Output "Press any key to exit..."
$null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
}
} }