Hide or minimize powershell window during events

Hide or minimize powershell window during events

avatar
magnus03
Disabled

Hi

When triggering powershell script during events. Is it possible to hide or atleast minimize the powershell window?

\Masonit

All Comments (5)

avatar

Do you have a print screen of the PowerShell window you are talking about?

Regards

David Hervieux

avatar

This big powershell window shows when script runs.

I have tried starting with: PowerShell.exe -windowstyle hidden {your script..}. But does not work.

\Masonit

Capture.JPG

avatar

It's a macro script tool that you execute?

Regards

David Hervieux

avatar

Nope. See print.

Capture.JPG

avatar

My understanding is that powershell.exe -windowstyle hidden only hides the child windows of the first instance of powershell, but that first instance always shows. I've reverted to using vbScript for those kinds of things where it absolutely must be hidden..

something like:
option explicit
dim wshShell
dim vbWaitForReturn
dim vbQuote
vbQuote = chr(34)

vbWaitForReturn = vbTrue
set wshShell = CreateObject("wscript.shell")

wshShell.Run "powershell.exe -file " & vbQuote & <pathtofile> & vbQuote & " other arguments", 0, vbWaitForReturn

[edit]
I forgot to add... you would run this as wscript.exe //I <pathtovbs> so that the wscript doesn't popup a window.. if you use cscript.exe it will generate a window
[/edit]

David F.