I was trying to start a exe with arguments by Process.Start. My first try is using Process.Start("Path/of/the/exe", "arguments of exe"). Here's my code snippets:
Process.Start(@"D:\Program Files\ITASCA\UDEC700\Exe64\udecConsole2017.exe", @"call 'D:\Work\202205\20220525\tunnel-for-cmd.txt'");
However the initialization of this exe is a bit slow, and the result is, I can only start the exe but the failed passing arguments. The following is the screenshot:
which is exactly the same result that starts without arguments.
By referencing this post C# - Making a Process.Start wait until the process has start-up, I changed my code as follows:
var process = Process.Start(@"D:\Program Files\ITASCA\UDEC700\Exe64\udecConsole2017.exe", @"call 'D:\Work\202205\20220525\tunnel-for-cmd.txt'");
while (string.IsNullOrEmpty(process.MainWindowTitle))
{
System.Threading.Thread.Sleep(100);
process.Refresh();
}
however these changes does not work.
I think my goal is to wait until exe completely started and then run it with arguments, but I dont know how to implement this.
=====================================================
New additions:
if I type in arguments call 'D:\Work\202205\20220525\tunnel-for-cmd.txt' in this started process, I will get my result:
SO I think the input arguments should be OK?
======================================= new addition 2: