c# - why WaitForExit() doesn't wait? -
i adding custom action vs2008 setup project (msi installer).
i calling batch file create database , want delete files after. have waitforexit() 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?             }             {                 system.io.file.delete(tempdir);             }   no difference startinfo.useshellexecute = true; batch executed without problem because require user input , input y , n questions. delete action happened before input. , have pause @ end of batch file. can watch process of batch file going.
edit: tested more 10 times, didn't work. after lunch, put 1 more waitforexit , while loop hasexited check. sleep inside while loop. found worked. deleted code, 1 waitforexit. seems work now.
this throwing exception because can't execute .bat file. intend execute cmd.exe giving .bat file command line argument.
Comments
Post a Comment