|
-
Nov 21st, 2004, 02:34 AM
#1
Thread Starter
Frenzied Member
System.Dianostics.Process.StartInfo.WindowMode = ...Hidden doesn't work
I am trying to get my program to execute a command line program, retrieve the results, process them and return them to a user from my program. However, it all works fine except that it doesn't hide the command window. It always appears, you can't see anything on it because it is redirected to my program and I have no idea how to stop it. I tried it with even just a simple batch file with nothing more than
Code:
@echo off
echo Hello World
in it and it still displays the window.
How can I prevent it from displaying the window?
Note: Using shell is not an option because shell doesn't redirect the output.
Code:
VB Code:
Dim Process As New Process 'Creates a new process
Dim StreamOut As IO.StreamReader 'Creates a stream reader to read the stream from the command
Dim Output As CommandOutput 'Holds the output from the command
'
'Creates the shutdown process
Process.StartInfo.FileName = "C:\Echo.bat"
Process.StartInfo.UseShellExecute = False
Process.StartInfo.RedirectStandardOutput = True
Process.StartInfo.RedirectStandardError = True
Process.StartInfo.RedirectStandardInput = True
Process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden 'Hides the window from the user
Process.Start() 'Executes the process
StreamOut = Process.StandardOutput 'Retrieves the output from the process
Process.WaitForExit(2000) 'Waits for 20 seconds for the process to finish
Output = ProcessOutput(StreamOut.ReadToEnd) 'Converts the output from the command to CommandOutput
StreamOut.Close() 'Closes the stream reader
Last edited by Ideas Man; Nov 21st, 2004 at 04:31 AM.
I use Microsoft Visual Basic 2005. (Therefore, most code samples I provide will be based around the .NET Framework v2.0, unless otherwise specified)
-
Nov 21st, 2004, 04:15 AM
#2
Frenzied Member
Add this line:
Process.StartInfo.CreateNoWindow = True
'Heading for the automatic overload'
Marillion, Brave, The Great Escape, 1994
'How will WE stand the FIRE TOMORROW?'
Eloy, Silent Cries and Mighty Echoes, The Vision - Burning, 1979
-
Nov 21st, 2004, 04:30 AM
#3
Thread Starter
Frenzied Member
Thanks Lunatic3, you legend. I saw that and I thought about it and for some reason, decided against it, wish I hadn't. Thanks again.
I use Microsoft Visual Basic 2005. (Therefore, most code samples I provide will be based around the .NET Framework v2.0, unless otherwise specified)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|