How to.. multiple commands after opening console window with Systems.Diagnostics.Process

  • Thread starter Thread starter rogdh
  • Start date Start date
R

rogdh

In C# I want to

Have the user make a selection from a ComboBox.

Then..
open a console.window
append a folder to the environment "path"
and then launch an application that uses the user.selected item as an
argument to that application.


Well, with Systems.Diagnostics.Process I can get the console window.
But that's it.
I've tried to add Strings that contained the other commands to the
Process.StartInfo.

But I only get the Console.window.

Any help??


thanks
roger
 
I would suggest you 2 solutions to solve that problem:
1. You could use a batch file which sets the path and than calls the
external application passing further the command line parameter:

start.bat:

SET PATH = %PATH%;c:\mypath
myexternalapp.exe %1 %2 %3 %4

Call from your application the batch file including the command line
parameter:

ProcessStartInfo startInfo = new ProcessStartInfo("start.bat");
startInfo.Arguments = myargument;
System.Diagnostics.Process.Start (startInfo);

Note: your path will not be available outside the console window.

2. You could set your environment variable from your program. You could
take a look on:
http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&threadm=FuD_9.54
54%242y.367892%40twister.austin.rr.com&rnum=20&prev=/groups%3Fq%3Ddotnet%2Bs
et%2Benvironment%2Bvariable%26hl%3Den%26lr%3D%26ie%3DUTF-8%26oe%3DUTF-8%26st
art%3D10%26sa%3DN



--
Adrian Vinca, Developer Division

This posting is provided "AS IS" with no warranties, and confers no rights.

Note: For the benefit of the community-at-large, all responses to this
message are best directed to the newsgroup/thread from which they
originated.
 
Thanks Adrian.
I was hoping for an answer that would allow a "conversation" with the
window, but I guess that is not what that class was designed for.

Thanks.
roger
 
Back
Top