Have you ever got a requirement to minimize all windows on the desktop using powershell script? It is helpful when you want to give a pop-up message to user which should draw their immediate attention.
I came across this little tip while exploring shell.application com object. It has other useful functions like undominimizeall, cascade windows, and many other explorer functions.
$shell = New-Object -ComObject "Shell.Application" $shell.minimizeall()
You can also undo minimize all windows by using below code.
$shell = New-Object -ComObject "Shell.Application" $shell.undominimizeall()
To see the clear functionality, add some delay between minimizeall() function and undominimizeall() function.
$shell = New-Object -ComObject "Shell.Application" $shell.MinimizeAll() start-sleep -Seconds 5 $shell.undominimizeall()
Hope this helps… You can explore more functions of shell.application object by using below code snippet.
New-Object -ComObject "Shell.Application" | gm | select Name, MemberType
Comments on this entry are closed.
I am looking for the method to minimize my PowerShell GUI windows. Is there any methods, could you please suggest.
Thank you.
Hi, you can do it using WindowHandle of the process. Some code is available at https://gist.github.com/jakeballard/11240204
I am looking for a command line routine or something that I can run from a batch file that opens a minimized app.
I have the powershell routine that minimizes all my open apps which works great. I have another powershell routine that opens all the minimized apps. For the most part this works fine. However, periodically I want to open/activate just one of the minimized apps not all of them. Is there a way to “undo” or maximize (doesn’t actually have to be maximized, just opened or activated) a specific minimized app?
Code that Minimizes:
powershell -command “& { $x = New-Object -ComObject Shell.Application; $x.minimizeall() }”
Code that Opens:
powershell -command “& { $x = New-Object -ComObject Shell.Application; $x.UndoMinimizeAll() }”
Thanks,
Steve K.
https://community.idera.com/database-tools/powershell/powertips/b/tips/posts/bringing-window-in-the-foreground
Check if this helps your requirement.
Thank you wintel. I started using CloseAll.exe with an exeption. Probably not the cleanest solution but it works. So for now I OKAY.
Again, thank you very much for your input. It truly is appeciated.
SKK