473,383 Members | 1,853 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Process opens program window when outside Visual Studio

Hi,

My program uses the Process class to start a bat file that starts an
exe. When I run my program inside Visual Studio (debug) the bat and exe
run in the background (are not visible) and all their output is
redirected to my stream reader.

But when I try to run my program outside the IDE, the exe starts in
it's own window and my prgram is put on hold. When I exit the started
program the output of the bat is flushed to my stream.

Why does this work when I'm inside Visual Studio but not outside?!

Here is the simple code I use to start the bat...

prog= new Process();
prog.StartInfo.FileName = executable;
prog.StartInfo.UseShellExecute = false;
prog.StartInfo.RedirectStandardInput = true;
prog.StartInfo.RedirectStandardOutput = true;
prog.StartInfo.CreateNoWindow = true;

if(arguments != null)
{
prog.StartInfo.Arguments = arguments;
}

I hope somebody knows an answer, otherwise weeks of work will go down
the drain.

Br,
Tom

Sep 15 '06 #1
2 1804
tomko wrote:

In Line...
>
Why does this work when I'm inside Visual Studio but not outside?!

Here is the simple code I use to start the bat...

prog= new Process();
prog.StartInfo.FileName = executable;
What is the value of the executable variable? Is it a string? What
does it contain? The name of the batch file? Does it show the black
DOS screen when you run it outside the IDE? Is that what you mean when
you say it shows it's own window?
prog.StartInfo.UseShellExecute = false;
prog.StartInfo.RedirectStandardInput = true;
prog.StartInfo.RedirectStandardOutput = true;
prog.StartInfo.CreateNoWindow = true;

if(arguments != null)
{
prog.StartInfo.Arguments = arguments;
}
Here is the code I use to start a batch file. Notice that I run
cmd.exe and not the batch file directly. This is in VB2005 so I use
the Using statement. If you're not using VB2005, you'll have to
dispose of the Process manually.

Using m_Process As New Process()
With m_Process.StartInfo
.FileName = "cmd.exe"
.UseShellExecute = False
.CreateNoWindow = True
.RedirectStandardOutput = True
.Arguments = "/C c:\test\test.bat"
End With

m_Process.Start()
m_Process.WaitForExit(5000)

Dim output As String = m_Process.StandardOutput.ReadLine()
While output <Nothing
TextBox1.Text &= output & vbCrLf
output = m_Process.StandardOutput.ReadLine()
End While
End Using

Hope this helps

Sep 15 '06 #2

If I run my program outside the ide the program opens a dos prompt
window... this doesn't happend insde the window.

It seems that program executed by the bat file prints out a header
inside ascii 1 characters. The affect of this seems to be omitted
inside the ide where the special characters are only printed in the
consolde window... but outside the ide they force windows to open a new
dos window for the program.

How can I prevent this?

Sep 20 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Tom Lee | last post by:
Hi, I'm new to .NET 2003 compiler. When I tried to compile my program using DEBUG mode, I got the following errors in the C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7 \include\xdebug...
0
by: wtfhits | last post by:
I'm writing my own task manager as I often change process priorities but have gotten myself into trouble on several occasions. I have discovered by keeping csrss.exe and explorer at the equal highest...
1
by: tadpole | last post by:
This has been the bane of my existence using Visual Studio 2003. Recipe: -Use UNC path to browse to directory on Win2003 Server with IIS. -Double Click the project file, the IDE opens, but...
4
by: hvj | last post by:
I need to run a .NET1.1 program in a .NET2.0 CLR. The .NET1.1 exe starts correctly in .NET2.0. Now I want to debug in Visual Studio 2005. But when I try to open the .NET1.1 project, Visual Studio...
5
by: Mikko Nylén | last post by:
Hi!, I'm trying to read the output of an process as it gets executed and append the output to a RichTextBox. However, I have a little problem: the process I'm trying to execute is a Python...
0
by: tomko | last post by:
Hi, When I start a console program using the Process calss inside the Visual Studio IDE (debug) all the output is redirected to my stream reader. But when I run the same program from outside the...
4
by: Peter Nimmo | last post by:
Hi, I am writting a windows application that I want to be able to act as if it where a Console application in certain circumstances, such as error logging. Whilst I have nearly got it, it...
7
by: Jwe | last post by:
Hi, I've written a program which has both a command line interface and Windows form interface, however it isn't quite working correctly. When run from command line with no arguments it should...
6
by: GaryDean | last post by:
I see some references on debugging by attaching to a process. There are MSDN articles that show how to attach to a process for debugging. However, I can find no info on how exactly to get the...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.