Why is WaitForExit () not waiting?

I am adding Custom Action to my VS2008 installation project (MSI installer).

I call the batch file to create the database and want to delete these files after. I have WaitForExit (), but it will not wait. Why?

            ProcessStartInfo startInfo = new ProcessStartInfo();
            startInfo.UseShellExecute = false;
            string tempDir = @"C:\Temp\";
            startInfo.FileName = tempDir + "sybaseDB\\en_AllInOne_installDB.bat";
            startInfo.Arguments = tempDir + "sybaseDB\\";

            try
            {
                Process startDB = Process.Start(startInfo);
                startDB.WaitForExit();

            }
            catch (Exception e)
            {
                //do something?
            }
            finally {
                System.IO.File.Delete(tempDir);
            }

no difference with startInfo.UseShellExecute = true; The package was executed without any problems, as it requires user input, and I entered y and n for questions. but this delete action happened before input. And I have a pause at the end of the batch file. I can watch the batch file process.

EDIT: 10 , . waitForExit while HasExited. while. , . , WaitForExit. .

+3
1

, , .bat. , cmd.exe, .bat .

0

Source: https://habr.com/ru/post/1767209/


All Articles