When building desktop applications, you often need to pass data between different programs. Fortunately, there is a common method for passing parameters to an executable (.exe) whether you are using WPF or Windows Forms. By leveraging command-line arguments, you can trigger specific behaviors or load specific data into your application upon startup. Below, I’ll show you the universal way to implement this.
1. Add reference System.Diagnostics your class.

2. Then need start process.
ProcessStartInfo processStrInfo = new ProcessStartInfo();processStrInfo.FileName = /// Exe path;
processStrInfo.Arguments = /// Parameter to pass as string;
processStrInfo.UseShellExecute = false;
Process.Start(processStrInfo);
3. parameter can send as string.
ProcessStartInfo processStrInfo = new ProcessStartInfo();
processStrInfo.FileName = "test.exe"; /// Exe path;
processStrInfo.Arguments = tempCommandArgs /// Parameter to pass as string;
Process.Start(processStrInfo);
4 .When we passing multiple parameter, we can use space between parameters .
5. If parameter value have spaces.
Now take a look at how to consume passed argument form exe.
Note:-
This example I have done with WPF application
1. We can override OnStartup in App.xaml.cs
protected override void OnStartup(StartupEventArgs e)
{
string[] args = Environment.GetCommandLineArgs();
args = e.Args;
if (args.Count() > 0)
{
COMPANYNAME = args[0];
USERNAME = args[1];
}
}