By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,780 Members | 1,118 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,780 IT Pros & Developers. It's quick & easy.

Calling several processes in a dos window

P: n/a
Hi,
here is my trouble:

I need to call 2 différents processes in a same dos window,
the first one is needed for the 2nd, and I have to pass several different
arguments to the 2nd.
My problem is that there are as many dos windows as calls to
"myProcess.start()", and I don't know how to do ...
Anybody has an idea ?

Thanks in advance (and sorry for my bad English)
Nov 16 '05 #1
Share this Question
Share on Google+
7 Replies


P: n/a
If I had to guess, you like Unix.

And unfortunately, Windows does not have the equivalent of "&" in Unix.

To get around this, I believe you would have to write code to fire a
process, and free the "Console", so your application is not a Console
application ..

But my answer will be more accurate if I saw your code.

- Sahil Malik
Independent Consultant
You can reach me thru my blog at -
http://www.dotnetjunkies.com/weblog/sahilmalik/

"w.monthard" <mo*******@free.fr> wrote in message
news:40*********************@news.free.fr...
Hi,
here is my trouble:

I need to call 2 différents processes in a same dos window,
the first one is needed for the 2nd, and I have to pass several different
arguments to the 2nd.
My problem is that there are as many dos windows as calls to
"myProcess.start()", and I don't know how to do ...
Anybody has an idea ?

Thanks in advance (and sorry for my bad English)

Nov 16 '05 #2

P: n/a
My application is a Windows application which has to call a dos application,
but another dos application has to be called before.

Process cmd = new Process();
ProcessStartInfo info = new ProcessStartInfo("cmd");
info.CreateNoWindow = false;
info.UseShellExecute =false;
info.WorkingDirectory = aDirectory;
info.Arguments = args;
cmd.StartInfo = info;
cmd.Start();
info.WorkingDirectory = anotherDirectory;

info.Arguments = otherargs;

cmd.StartInfo = info;

cmd.Start();

This code gives me 2 differents dos windows (2 processes) , and I don't know
how to do to have the same process cmd to execute several times 2
applications with different parameters

"Sahil Malik" <co*****************@nospam.com> a écrit dans le message de
news:OS**************@TK2MSFTNGP12.phx.gbl...
If I had to guess, you like Unix.

And unfortunately, Windows does not have the equivalent of "&" in Unix.

To get around this, I believe you would have to write code to fire a
process, and free the "Console", so your application is not a Console
application ..

But my answer will be more accurate if I saw your code.

- Sahil Malik
Independent Consultant
You can reach me thru my blog at -
http://www.dotnetjunkies.com/weblog/sahilmalik/

"w.monthard" <mo*******@free.fr> wrote in message
news:40*********************@news.free.fr...
Hi,
here is my trouble:

I need to call 2 différents processes in a same dos window,
the first one is needed for the 2nd, and I have to pass several different
arguments to the 2nd.
My problem is that there are as many dos windows as calls to
"myProcess.start()", and I don't know how to do ...
Anybody has an idea ?

Thanks in advance (and sorry for my bad English)


Nov 16 '05 #3

P: n/a
monthar,

If 2nd DOS window is receiving the parameters from the 1st, you have then
wait for the 1st one to get completed before entering the 2nd.

To wait, you can do this

pProcess.WaitForExit();

Have i understood your question correctly?
Shak.
"w.monthard" <mo*******@free.fr> wrote in message
news:40*********************@news.free.fr...
Hi,
here is my trouble:

I need to call 2 différents processes in a same dos window,
the first one is needed for the 2nd, and I have to pass several different
arguments to the 2nd.
My problem is that there are as many dos windows as calls to
"myProcess.start()", and I don't know how to do ...
Anybody has an idea ?

Thanks in advance (and sorry for my bad English)

Nov 16 '05 #4

P: n/a
Hi,

If you need to simply start a new process and get the output printed
onto the same console window, the following code would probably serve
the purpose:

---=== Code begins ===---

System.Diagnostics.Process myProcess = new
System.Diagnostics.Process();
string myFileName = "c:\file.exe";
string myArguments = " /1 /2 /3";

myProcess .StartInfo.FileName = myFileName;
myProcess .StartInfo.Arguments = myArguments;
myProcess .StartInfo.RedirectStandardOutput = true;
myProcess .StartInfo.UseShellExecute = false;
myProcess .StartInfo.CreateNoWindow = true;
myProcess .Start();
string output = myProcess .StandardOutput.ReadToEnd();
myProcess .WaitForExit();

Console.WriteLine(output);

---=== End of Code ===---

The code (process 1) spawns a new process without creating a new
window for it. Process 1 then waits for process 2 to quit, reads
whatever process 2 has output to the console and then prints it to
process 1's console.

Hope that helps. :)

"w.monthard" <mo*******@free.fr> wrote in message news:<40*********************@news.free.fr>...
Hi,
here is my trouble:

I need to call 2 différents processes in a same dos window,
the first one is needed for the 2nd, and I have to pass several different
arguments to the 2nd.
My problem is that there are as many dos windows as calls to
"myProcess.start()", and I don't know how to do ...
Anybody has an idea ?

Thanks in advance (and sorry for my bad English)

Nov 16 '05 #5

P: n/a
The 2nd process does not wait for the 1st process :
1. the 1st process is executed in a dos window, if it is not executed
before, the 2nd process produces nothing; it has to be executed in his
directory.
2. the 2nd process is executed with parameters in the SAME dos window, in
another directory (in a different dos window, it produces nothing), it
receives about 100 different parameters sent in a boucle "for".

My problem is to execute these 2 different processes in the same dos
windows,
I could create a batch file which executes these 2 different processes and
execute it 100 times but I try to find another solution.
Nov 16 '05 #6

P: n/a
write a batch file to the directory you need to execute the apps in. The
batch file will contain the commands to execute both processes.
Then, from .NET, start the batch file.

--- Nick

"w.monthard" <mo*******@free.fr> wrote in message
news:40*********************@news.free.fr...
The 2nd process does not wait for the 1st process :
1. the 1st process is executed in a dos window, if it is not executed
before, the 2nd process produces nothing; it has to be executed in his
directory.
2. the 2nd process is executed with parameters in the SAME dos window, in
another directory (in a different dos window, it produces nothing), it
receives about 100 different parameters sent in a boucle "for".

My problem is to execute these 2 different processes in the same dos
windows,
I could create a batch file which executes these 2 different processes and
execute it 100 times but I try to find another solution.

Nov 16 '05 #7

P: n/a
I'll try this solution if I don't find another solution.
Thanks

"Nick Malik" <ni*******@hotmail.nospam.com> a écrit dans le message de
news:T8LAc.65062$eu.49473@attbi_s02...
write a batch file to the directory you need to execute the apps in. The
batch file will contain the commands to execute both processes.
Then, from .NET, start the batch file.

--- Nick
Nov 16 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.