Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to close all windows

I would like to close all open windows. This will not minimize the windows but the script will close all windows even if it is minimized. Is there a way to do this in a batch program or powershell?

like image 295
Luke101 Avatar asked Mar 15 '12 18:03

Luke101


People also ask

Is there a shortcut to close all Windows?

Press Alt + E to close all the programs. Finish off by closing the Windows Task Manager by clicking the X in the top right-hand corner (or you can do Alt + F /down arrow and select the Exit Task Manager option).

What is the shortcut key of close all?

(Optional) To use keyboard shortcuts to close all tabs in a window, choose an option: On Windows & Linux, press Alt + F4. On a Mac, press ⌘ + Shift + w.

How do I collapse all Windows in Windows 10?

If your keyboard has a Windows key (and most current keyboards do), you can press the Windows key and the M key simultaneously to minimize all the currently open windows on your desktop.

How do I close all windows 11?

First, hit the Windows Key + D to go to your computer's desktop. Then, press the Alt + F4 keys together, and the shutdown menu will pop up in front of your screen. Select the shutdown option from the dropdown menu and hit Enter. Your Windows 11 computer will now turn off without any hassles.


1 Answers

use this in powershell:

Get-Process | Where-Object {$_.MainWindowTitle -ne ""} | stop-process

-note: this close powershell console or ise too and can't end his job!

(get-process | ? { $_.mainwindowtitle -ne "" -and $_.processname -ne "powershell" } )| stop-process

this way only powershell windows is still alive but the last command in your script can be

stop-process powershell

note: this no affect tray icon minimized process.

EDIT:

to close 'control panel' on xp try this:

(New-Object -comObject Shell.Application).Windows() | where-object {$_.LocationName -eq "Control Panel"} | foreach-object {$_.quit()}

to close all explorer.exe windows:

(New-Object -comObject Shell.Application).Windows() | foreach-object {$_.quit()}
like image 126
CB. Avatar answered Nov 16 '22 03:11

CB.