Need to execute command from within Windows form

P

Philip Colmer

I need to run a command line tool from within a Windows form application
without the command window opening at all. I had found some code (below) but
the window is still opening.

Dim psi As New System.Diagnostics.ProcessStartInfo(strCmd,
strParams)
psi.RedirectStandardOutput = True
psi.WindowStyle = ProcessWindowStyle.Hidden
psi.UseShellExecute = False
Dim listFiles As System.Diagnostics.Process
listFiles = System.Diagnostics.Process.Start(psi)
Dim myOutput As System.IO.StreamReader = listFiles.StandardOutput
listFiles.WaitForExit(20000)

Can anyone see what is wrong with this (i.e. why does the window open) or
does anyone have any suggestions for running command line stuff without the
black window appearing?

Thanks.

--Philip
 
J

Jeffrey Tan[MSFT]

Hi Philip,

Thanks for your post.

Base on my research, we can use CreateNoWindow property to get what you
want, sample code listed below:

psi.WindowStyle = ProcessWindowStyle.Hidden
psi.CreateNoWindow = True ¡®Just set CreateNoWindow = true, it works

Hope this helps

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
P

Philip Colmer

"Jeffrey Tan[MSFT]" said:
Hi Philip,

Thanks for your post.

Base on my research, we can use CreateNoWindow property to get what you
want, sample code listed below:

psi.WindowStyle = ProcessWindowStyle.Hidden
psi.CreateNoWindow = True ¡®Just set CreateNoWindow = true, it works

Hope this helps

Thank you - that has solved it for me.

--Philip
 
J

Jeffrey Tan[MSFT]

It's my pleasure to help you.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top