![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| 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. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | 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 Specs![]() |
| | #2 (permalink) |
| | 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 Specs![]() |
| | #3 (permalink) |
| | 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 Specs![]() |
![]() |
| 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 | |||