How can I pass multiple arguments to a newly created process in C#?
Also which class (Process
or ProcessStartInfo
or MyProcess
) in should I use in executing a program, with the condition of passing multiple arguments to the newly created/executed process?
As is I have the equivalent (Borland) C++ code for the same task, which is as follows:
spawnv(P_NOWAITO,Registry->ReadString("Downloader").c_str(),arglist);
where arglist
is a char pointer array and
Registry->ReadString("Downloader").c_str()
, is the program to execute.
/* Code Listing 6.9: Passing multiple arguments to a thread requires grouping them into a struct */ /* Assume we have: struct thread_args { int first; const char *second; }; */ struct thread_args *args = malloc (sizeof (struct thread_args)); args->first = 5; args->second = "Hello"; /* Note that the data structure ...
We pass arguments in a function, we can pass no arguments at all, single arguments or multiple arguments to a function and can call the function multiple times.
For cases where multiple arguments must be passed, this limitation is easily overcome by creating a structure which contains all of the arguments, and then passing a pointer to that structure in the pthread_create() routine. All arguments must be passed by reference and cast to (void *).
Just use "&&" in your command line. Save this answer.
In order to pass multiple command line arguments you should separate each with a space and surround it in quotes in case the argument itself contains a space.
string[] args = { "first", "second", "\"third arg\"" };
Process.Start("blah.exe", String.Join(" ", args));
Process.Start( "program.exe", "arg1 arg2 arg3" );
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With