473,659 Members | 2,666 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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. RedirectStandar dInput = true;
prog.StartInfo. RedirectStandar dOutput = 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 1812
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. RedirectStandar dInput = true;
prog.StartInfo. RedirectStandar dOutput = 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.Start Info
.FileName = "cmd.exe"
.UseShellExecut e = False
.CreateNoWindow = True
.RedirectStanda rdOutput = True
.Arguments = "/C c:\test\test.ba t"
End With

m_Process.Start ()
m_Process.WaitF orExit(5000)

Dim output As String = m_Process.Stand ardOutput.ReadL ine()
While output <Nothing
TextBox1.Text &= output & vbCrLf
output = m_Process.Stand ardOutput.ReadL ine()
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
6117
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 file as folows. I need help to resolve them ASAP: cl /c /nologo /MDd /W3 /Od /GR /GM /Zi /GX /D "_DEBUG" /D " WIN32" /D "_W INDOWS" /D "_WINDLL" /D "_AFXDLL" /D "_MBCS" /D "_USRDLL" /
0
373
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 priority, I can keep the computer running ok, or at least recover. So that's what my program does - keeps itself and those programs with high enough priority. It works great when run from visual studio, but as soon as i run it directly (whether in...
1
1440
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 notice there is no redraw in the window in the right panel. -Wait internibably until impatience forces one to open the Task manager -Notice that Visual Studio is not (not responding) and can be alt-tabbed to, but also notice 100% CPU utilization....
4
2514
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 wants to convert it to .NET2.0 what I don't want. How can I make Visual Studio open a .NET1.1 project for me in order to attach to a .NET2.0 process in which it runs to debug it? Or is there a better way to reach my goal: debugging a .NET1.1...
5
11395
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 script, which uses the time.sleep() to sleep for a specified amount of time. This (the use of time.sleep()) seems to have the side effect of the output not being added to the RichTextBox until the process has finished, which it won't do as the...
0
1124
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 IDE the process opens a new shell window for the program and my program is put on hold. How can something work inside the IDE but not outside?!
4
10502
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 doesn't seem to write to the screen in the way I would expect. The output is:
7
9357
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 display the Windows form. The form is being displayed but the command only returns when the form is closed. I want the command line to return immediately, leaving the form displayed.
6
3218
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 debugging to work. I have a wizard page in the anonymous section of my website. If I run it as the startup page in VS it runs fine. But if I link to it from an external link, it gets "object reference not set to an instance of an object" when I...
0
8330
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8850
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8746
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8523
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8626
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7355
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5649
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
2749
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1975
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.