Skip to content

Instantly share code, notes, and snippets.

@ml4den
Last active September 5, 2017 11:30
Show Gist options
  • Save ml4den/25f13bff6d666c1fbc78b705d3c57f7c to your computer and use it in GitHub Desktop.
Save ml4den/25f13bff6d666c1fbc78b705d3c57f7c to your computer and use it in GitHub Desktop.
Close/Quit Application Window with PowerShell
# Simple find and quit:
(New-Object -comObject Shell.Application).Windows() | where-object {$_.LocationName -eq "Personalisation"} | foreach-object {$_.quit()}
# Credit: https://www.tenforums.com/customization/51260-apply-windows-10-theme-cmd-powershell-programming-post963151.html#post963151
# Wait for window and quit:
do {
$windowcheck = (New-Object -comObject Shell.Application).Windows() | where-object {$_.LocationName -eq "Personalization"}
Write-Host "Waiting for window..."
Start-Sleep -m 200
}
until ($windowcheck.LocationName -eq "Personalization")
# The loop has ended; closing the window...
$windowcheck | foreach-object {$_.quit()}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment