Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > PowerShell

Vista - How stop Powershell flashing when run with .NET Process object?

Reply
 
Old 11-01-2009   #1 (permalink)
CodeSlinger


 
 

How stop Powershell flashing when run with .NET Process object?

Does anyone have the PSScriptRunner.zip that claims to help this but seems to
no longer be available?

I am using C# to run various command line commands including Powershell and
am pretty knowledgeable on how to use the Process and StartInfo objects but
for the life of me I cannot stop Powershell from flashing briefly. I have no
issues with other command line programs - just Powershell.

I can launch by powershell.exe or with cmd.exe, full path or not, set the
process.startinfo options to create no window and windowsstyle.hidden and
then on the PS command line set -nolog -noninteractive and -windowstyle
hidden as well. I am also redirecting all output to a streamreader and all
that works fine. But I get a brief DOS like "flash" the size of which depends
upon whether I used cmd.exe or powershell.exe to launch under the process
object.

If I try other -WindowStyle values I can actually watch PS max, or min, or
hide but it always flashes for a second first and is driving me nuts trying
to get around that.

I have actually written PS hosting for in-process but I can't use that in
this situation. I have to launch with the .NET process object as an external
process.

Would be most grateful if anyone can verify this behaviour and has a
workaround. Thanks. I still need to capture redirected I/O though which at
least that works fine right now.

Thanks, Dave Kolb
http://WndDotNet.com


My System SpecsSystem Spec
Old 4 Weeks Ago   #2 (permalink)
CodeSlinger


 
 

RE: How stop Powershell flashing when run with .NET Process object?

Well the problem is not Powershell after all. The .NET Process object will
flash if you run any command line program if you add a userid and password to
the StartInfo object. I'd love to hear of any workaround! Thanks, Dave

"CodeSlinger" wrote:
Quote:

> Does anyone have the PSScriptRunner.zip that claims to help this but seems to
> no longer be available?
>
> I am using C# to run various command line commands including Powershell and
> am pretty knowledgeable on how to use the Process and StartInfo objects but
> for the life of me I cannot stop Powershell from flashing briefly. I have no
> issues with other command line programs - just Powershell.
>
> I can launch by powershell.exe or with cmd.exe, full path or not, set the
> process.startinfo options to create no window and windowsstyle.hidden and
> then on the PS command line set -nolog -noninteractive and -windowstyle
> hidden as well. I am also redirecting all output to a streamreader and all
> that works fine. But I get a brief DOS like "flash" the size of which depends
> upon whether I used cmd.exe or powershell.exe to launch under the process
> object.
>
> If I try other -WindowStyle values I can actually watch PS max, or min, or
> hide but it always flashes for a second first and is driving me nuts trying
> to get around that.
>
> I have actually written PS hosting for in-process but I can't use that in
> this situation. I have to launch with the .NET process object as an external
> process.
>
> Would be most grateful if anyone can verify this behaviour and has a
> workaround. Thanks. I still need to capture redirected I/O though which at
> least that works fine right now.
>
> Thanks, Dave Kolb
> http://WndDotNet.com
>
My System SpecsSystem Spec
Old 4 Weeks Ago   #3 (permalink)
Martin Zugec


 
 

Re: How stop Powershell flashing when run with .NET Process object?

Hi Dave,

well, it's not truly powershell question then

But to give you some useful answer, have a look at MSDN:
http://msdn.microsoft.com/en-us/libr...startinfo.aspx

"You can change the parameters specified in the StartInfo property up
to the time that you call the Start method on the process. After you
start the process, changing the StartInfo values does not affect or
restart the associated process. If you call the Start
(ProcessStartInfo) method with the ProcessStartInfo..::.UserName and
ProcessStartInfo..::.Password properties set, the unmanaged
CreateProcessWithLogonW function is called, which starts the process
in a new window even if the CreateNoWindow property value is true or
the WindowStyle property value is Hidden."

Martin
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Need an idiot check on technique for releasing out-of-process COM object in PowerShell PowerShell
Please Help! - Annoying Flashing Window Won't Stop Vista performance & maintenance
get-process & stop-process by owner PowerShell
Bug? Shouldn't Stop-Process automatically match Id if object is a process? PowerShell
measure-object {get-process} PowerShell


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46