Is there a way to pass a string argument to a process which is spawned from my own process.
I have in my main application:
Process.Start(Path.Combine(Application.StartupPath, "wow.exe");
wow.exe is another app I created. I need to pass argument to this exe (a string). How can I achieve this typically?
What I tried:
ProcessStartInfo i = new //........
i.Argument = "cool string";
i. FileName = Path.Combine(Application.StartupPath, "wow.exe");
Process.Start(i);
And in the main of wow application i wrote:
static void Main()
{
//print Process.GetCurrentProcess().StartInfo.Argument;
}
But I never get my string there in second application’s Main. Here is a question which asks why, but no how to solve it..
Edit: Environment.GetCommandLineArgs()[1], it has to be. Nevertheless, got it working. Accepted @Bali’s answer as he cameup first with this answer. Thanks all
To get the arguments passed you can either use the
string[] argsin yourMain, or you can useEnvironment.GetCommandLineArgs.Example:
or