who can run batch

now ,I develope a app on xp ,i run it on server2003.It can run normally .when i use app to invoke a batch ,problems come here. The batch can not run rightly.In batch file ,some commands can run ,some commands can not run,for example ,find command can not, findstr can .Because app using mfc.so I using "createprocess "function,in this ,i can create pipe and get output Real-time. I use many ways ,but not work rightly. system() and shellexcute can work rightly,but do not meet my requirements.They will have black Console.Now,who can solve the question or find another way that meet my requirements.Thank you!
Please post your code of the batch invoke and the batch file itself. Do you start the batch file with cmd /c <batch>?
yes,i start with cmd /c xxx.bat.The code is mainly :
createprocess("C:\\windows\\system32\\cmd.exe"," /C xxx.bat",.....true,...,"workdirectory"........);I don't know where problem is.
The batch file is :
echo off
find
..........
You can try it .you will find it not work really.
i only can say so much,because i can not get code ,it is at company.Thank you
i waiting on line...........
Please post the full content of batch file for us to test.
CString CmdString="mybatch.bat"
SECURITY_ATTRIBUTES sa;
STARTUPINFO si;
PROCESS_INFORMATION pi;
sa.nLength = sizeof(SECURITY_ATTRIBUTES);
sa.lpSecurityDescriptor = NULL;
sa.bInheritHandle = TRUE;
if(!CreatePipe(&ProcessReadPipe,&ProcessWritePipe,&sa,1000)) {
MessageBox(0,"Error On CreatePipe()","Error",MB_ICONERROR);
return false;
}
si.cb = sizeof(STARTUPINFO);
GetStartupInfo(&si);
si.lpReserved=NULL;
si.lpDesktop=NULL;
si.lpReserved2=NULL;
si.hStdError = ProcessWritePipe;
si.hStdOutput = ProcessWritePipe;
si.wShowWindow = SW_HIDE;
si.dwFlags = STARTF_USESHOWWINDOW | STARTF_USESTDHANDLES;
HANDLE htoken=NULL;
LPCH lpch=GetEnvironmentStrings();
if (!CreateProcess("C:\\WINDOWS\\system32\\cmd.exe ",Char_CmdString ,&sa,&sa,TRUE,"try many args",GetEnvironmentStrings(),"D:\\",&si,&pi))
The batch is :
.....................
echo off
find "abc" a.txt
pause
.....................
this is all.


Topic archived. No new replies allowed.