cmd / powershell: minimize all windows on your desktop except for current command prompt (console) or except for some particular window
minimize all but the active window (toggling command):
nircmd sendkeypress rwin+home
escudero380
Updated on July 09, 2022Comments
-
escudero380 almost 2 years
well, I know how to minimize all open windows on the desktop from a batch file by using powershell method - MinimizeAll():
powershell -command "& { $x = New-Object -ComObject Shell.Application; $x.minimizeall() }"
the problem is: this method minimizes everything including current cmd-console which should be in my case always visible to the user.
now, to workaround this problem I use external nircmd.exe tool and this part of my .bat-file looks like this:
:: change current command prompt window title title my-cmd-console :: minimize all open windows on the desktop with powershell command powershell -command "& { $x = New-Object -ComObject Shell.Application; $x.minimizeall() }" :: bring console back to the front with nircmd.exe command 'win activate [filter window by title]' nircmd.exe win activate title "my-cmd-console"
what I don't like about this code is that there is much 'flashing' on the screen: at start, the console appears on the desktop, then it gets minimized with all other windows and then it's brought back on the desktop front again.
so, the question is: how to make console appear on the desktop front and 'lock it', so that it never gets out of sight until the command line EXIT is reached.
P.S. not sure, but maybe there is an alternative solution to 'minimize all except for particular window' problem without need to use external nircmd.exe tool. any ideas?