I m writing a console program that launches other applications one after the other, namely that the file produced by the first application is going to be used by the second and so on..
When I run into this issue and the workaround that I use is to, in this case, have blabla0.bat call a third program at the end of it's execution that third program is what processes the data from XX.mb.
The problem is that CreateProcess returns from the OS as soon as the app you called is started.
Otherwise you can do a lot of things in C\C++ that you can with bat files maybe your solution is to rewrite the bat file in C\C++?
EDIT: Pausing a program until a condition is met is really a loop that keeps testing for that condition. When the condition is met the otherwise infinite loop exits allowing the rest of the program to continue processing. In this case you would use the openfile function (who's name escapes me at the moment) and just capture and throw out the fail, exiting the loop once openfile returns true.
The .bat file is important because it is read by the other application later (mayabatch) anyway..
i did make a an while loop checking the existance of the new file yesterday (not using the EDIT function though; i ll give that a try today);
meanwhile i wanted to show you the loop i made that didnt work:
string XX="D:\\XX.mb";
int exists=0;
ifstream ifile(XX);
while (exists==0)
{
if (ifile)
{exists=1; CreateProcess(L"D:\\blabla1.bat",NULL,NULL,NULL,FALSE,0,NULL,NULL,&si, &pi); }
else
{exists=0;}
cout<<exists;
}
}
in principle this should work fine !!!
so during the first round of the while loop the XX.mb file is not created yet so the ifile()function is returning nul, that's ok.
but even when the file is created the later rounds of the while loop, the ifile() function fails to detect the XX.mb file.
Do you have any idea why? is there a refresh action needed or something?
thanks a lot,