Process.waitforexit() always returning false. RRS feed

  • General discussion

  • Hello,

    I have a test automation project in which i am starting a process, and the process is always returning false even after the process is completed.


    I have a test case in which i am opening a IE browser window, performing the case and closing the window.

                            foreach (string value in testSuiteArray)
                                String Cmda = "\"" + MSTestEXEPath + "\"" + " /testsettings:" + ProjectPath + @"\KastleSysTestConfig.testsettings"
                                              + " /testcontainer:KastleSysTestAutomation.dll /test:" + value + ">" + ProjectPath + "\\CmdLog.txt";
                                Process Pros = ExecuteCommandSync(Cmda);

    Cmda contains the command information that is

    "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\MSTest.exe" /testsettings:D:\project\AutomationSecond\myKAndKDAutomation\AutomationExecutableFiles\KastleSysTestConfig.testsettings /testcontainer:KastleSysTestAutomation.dll /test:KSYS6133Test>D:\project\AutomationSecond\myKAndKDAutomation\AutomationExecutableFiles\CmdLog.txt

    Method ExecuteCommandSync(Cmda); contains the below mention code.

                    ProcessStartInfo procStartInfo = new ProcessStartInfo("cmd", "/K " + command);
                    procStartInfo.RedirectStandardOutput = true;
                    procStartInfo.UseShellExecute = false;
                    procStartInfo.CreateNoWindow = true;
                    Process proc = new Process();
                    proc.StartInfo = procStartInfo;
                    return proc;

    Problem is Pros.WaitForExit() always returning false.

    I am using Windows 10 Visual Studio 2017 Professional

    Wednesday, January 15, 2020 9:30 AM