Hi,

I have a C# (form) program. I need it to run a 'command line program'. I
have it working fine using Process, but it (temporarily) opens a Command
Prompt window everytime it runs (and closes it when it finishes).

How do I get it to run in the background without opening a window each time
I call process.Start()? (FYI: I searched for this on the web but couldn't
find anything)

Thanks,

Hilton

RE: Process - no window open by AMercer

AMercer
Mon Sep 05 07:29:07 CDT 2005

> How do I get it to run in the background without opening a window each time
> I call process.Start()?

This vb fragment works for me and also reads back stdout of the launched
process. I'm not sure how much of this is really necessary - I stopped
experimenting when I got it to work.

Dim s As String
Dim p As New Process
With p.StartInfo
.FileName = "whatever.exe"
.Arguments = "arg1 arg2"
.UseShellExecute = False
.RedirectStandardError = True
.RedirectStandardInput = True
.RedirectStandardOutput = True
.WindowStyle = ProcessWindowStyle.Hidden
.CreateNoWindow = True
End With
Try
p.Start()
s = p.StandardOutput.ReadToEnd()
p.WaitForExit()
Catch e As Exception
s = e.tostring
End Try


Re: Process - no window open by Hilton

Hilton
Mon Sep 05 15:58:55 CDT 2005

Perfect - thank you!

Hilton


"AMercer" <AMercer@discussions.microsoft.com> wrote in message
news:F36687FA-EF23-4314-99A7-47BFB070FBA7@microsoft.com...
> > How do I get it to run in the background without opening a window each
time
> > I call process.Start()?
>
> This vb fragment works for me and also reads back stdout of the launched
> process. I'm not sure how much of this is really necessary - I stopped
> experimenting when I got it to work.
>
> Dim s As String
> Dim p As New Process
> With p.StartInfo
> .FileName = "whatever.exe"
> .Arguments = "arg1 arg2"
> .UseShellExecute = False
> .RedirectStandardError = True
> .RedirectStandardInput = True
> .RedirectStandardOutput = True
> .WindowStyle = ProcessWindowStyle.Hidden
> .CreateNoWindow = True
> End With
> Try
> p.Start()
> s = p.StandardOutput.ReadToEnd()
> p.WaitForExit()
> Catch e As Exception
> s = e.tostring
> End Try
>