我调试成功的是VC6system("d: & cd test & dir & del test.txt & pause");
很抱歉,我刚才可能没把要求将清楚。我希望用户的感觉就像手工执行多条命令一样。所以要满足如下条件:1。不用*.bat文件 2。不改变命令格式。(不把命令转换为“d: & cd test & dir & del test.txt & pause”) 3。如果需要的话,用户可以在程序运行完这些命令后,再手工运行一些其他命令。还是要谢谢zngsai和ydfy6,我也会给你们加分的。
system("del test.txt");
system(dir );
system(del test.txt );
system(pause);
STARTUPINFO si;
PROCESS_INFORMATION pi;
ZeroMemory( &si, sizeof(si) );
si.cb = sizeof(si);
si.dwFlags=STARTF_USESHOWWINDOW;
si.wShowWindow=SW_SHOW;
ZeroMemory( &pi, sizeof(pi) );
//watchdog
if( !CreateProcess(NULL, // No module name (use command line).
TEXT("cmd.exe /k xx.bat"), // Command line.
NULL, // Process handle not inheritable.
NULL, // Thread handle not inheritable.
FALSE, // Set handle inheritance to FALSE.
0, // No creation flags.
NULL, // Use parent's environment block.
NULL, // Use parent's starting directory.
&si, // Pointer to STARTUPINFO structure.
&pi) // Pointer to PROCESS_INFORMATION structure.
)
{
MessageBox("error");
exit(-1);
}
system("cd c:\test&dir&del test.txt&pause" );//VC6.0SP6+XPSP3调试成功!
system("cd c:\test&dir&del test.txt&pause" );//VC6.0SP6+XPSP3调试成功!
2。不改变命令格式。(不把命令转换为“d: & cd test & dir & del test.txt & pause”)
3。如果需要的话,用户可以在程序运行完这些命令后,再手工运行一些其他命令。还是要谢谢zngsai和ydfy6,我也会给你们加分的。