i am adding Custom Action into my VS2008 setup project (MSI installer).
I am calling a batch file to create database and want to delete those 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 batch was executed without any problem because it require user input and I input y and n for questions. but that delete action happened before my input. And I have a pause at the end of the batch file. I can watch the process of the batch file going.
EDIT: I tested more than 10 times, it didn't work. After lunch, I put one more waitForExit and a while loop with HasExited check. it will sleep inside the while loop. I found it worked. Then I deleted those extra code, back to one WaitForExit. It seems work now.