Windows App Command Line

  • Thread starter Thread starter Red2
  • Start date Start date
R

Red2

Hey all,
I have a windows application that I need to pass command line
arguments to. However I can't get it to work. Does anyone have any
example on how to do this. I can get it to work on a consol app, not a
windows one like I need though. .net 2.0 c#...

Thanks for the help
 
Hi,
You need to change the signature static void Main() to static void
Main(string[] args).
You could find this function in Program.cs. All the command line parameters
separated with spaces will be populated in the args array.
 
Hi,
Here is the code that maybe helpful

Process cscPro=new Process();
cscPro.StartInfo.FileName = "csc.exe";
cscPro.StartInfo.WorkingDirectory = Path;
cscPro.StartInfo.Arguments = codeFileName;
cscPro.StartInfo.CreateNoWindow = true;
cscPro.StartInfo.UseShellExecute = false; //don't use shell,
then we can redirect the input and output of the exe
cscPro.StartInfo.RedirectStandardInput = true;
cscPro.StartInfo.RedirectStandardOutput = true;
cscPro.StartInfo.RedirectStandardError = true;
cscPro.Start();
cscPro.StandardInput.WriteLine("xxx"); //send parameters to
the exe
string outPut = cscPro.StandardOutput.ReadToEnd(); //get the
output
 
Thanks for all your help

Hi,
Here is the code that maybe helpful

Process cscPro=new Process();
cscPro.StartInfo.FileName = "csc.exe";
cscPro.StartInfo.WorkingDirectory = Path;
cscPro.StartInfo.Arguments = codeFileName;
cscPro.StartInfo.CreateNoWindow = true;
cscPro.StartInfo.UseShellExecute = false; //don't use shell,
then we can redirect the input and output of the exe
cscPro.StartInfo.RedirectStandardInput = true;
cscPro.StartInfo.RedirectStandardOutput = true;
cscPro.StartInfo.RedirectStandardError = true;
cscPro.Start();
cscPro.StandardInput.WriteLine("xxx"); //send parameters to
the exe
string outPut = cscPro.StandardOutput.ReadToEnd(); //get the
output
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top