Maximize window and bring it in front with powershell

后端 未结 2 1302
渐次进展
渐次进展 2020-12-01 14:25

Is there a way to bring a window in front from powershell? I tried this to hide all windows (working) and bring me the powershell back (not working)

[void] [         


        
2条回答
  •  感情败类
    2020-12-01 15:18

    This is cheating a bit since it's using WScript, but the following one-liner places the window in the foreground without requiring any external cmdlet installation.

    In the example below, "notepad" is the process name associated with the window.

    Credit goes to the Idera forum posting here by JSanders:

    (New-Object -ComObject WScript.Shell).AppActivate((get-process notepad).MainWindowTitle)
    

提交回复
热议问题