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

'The Paramter is incorrect', running a console program

P: 2
I'm trying to run a program and pass it arguments. I know that the arguments provided are correct but I get a "The Parameter is incorrect" error. I has used the exact same arguments as provided in the 'arg' string to the program on the console and it worked as expecterd. (I copied the text directly from a watch I had set up)

I am using C#. Is there anything that I have missed?

Thank you.
Expand|Select|Wrap|Line Numbers
  1.             System.Diagnostics.ProcessStartInfo si = new System.Diagnostics.ProcessStartInfo();
  2.             si.Arguments = arg;
  3.             si.CreateNoWindow = true;
  4.             si.FileName = ".\\planet.exe";
  5.             si.RedirectStandardOutput = true;
  6.             si.UseShellExecute = false;
  7.             try
  8.             {
  9.                 MessageBox.Show(si.FileName+ " "+si.Arguments);
  10.                 System.Diagnostics.Process prc=System.Diagnostics.Process.Start(si);
  11.                 prc.WaitForExit();
  12.             }
Oct 17 '06 #1
Share this Question
Share on Google+
2 Replies


100+
P: 111
hai gilllyo,

si.Arguments = arg;
// I think arg is an array
// We cant assign the array values to ProcessStartInfo.Arguments

This site can help you.

http://msdn2.microsoft.com/en-us/library/system.diagnostics.processstartinfo.arguments.aspx
Oct 17 '06 #2

P: 2
"arg" isn't an array. Are you saying it should be or shouldn't be?

Expand|Select|Wrap|Line Numbers
  1. String arg = (String)e.Argument;
  2.  
That's the line of code that takes the argument passed to a worker thread that's responsible for running the program (ie, same function) and using it for the argument to be passed to the program.
Oct 17 '06 #3

Post your reply

Sign in to post your reply or Sign up for a free account.