我想使用批处理文件移动文件,因为我确实使用下面的代码,该过程似乎成功执行,但文件没有被传输。这段代码有什么问题吗?
STARTUPINFO osi;
PROCESS_INFORMATION pi;
ZeroMemory( &osi, sizeof(osi) );
osi.cb = sizeof(capinfo);
ZeroMemory( &pi, sizeof(pi) );
wchar_t cmd[8192];
wchar_t ocmd[8192];
char ocmd1[8192];
swprintf_s(ocmd,sizeof(ocmd),L"%s\\%s.bat",capodd->templocation,capodd->wcurrentoutput);
sprintf_s(ocmd1,sizeof(ocmd1),"%ls\\%s.bat",capodd->templocation,capodd->currentoutput);
FILE * tempbat = fopen(ocmd1,"w");
swprintf_s(cmd,8192,L"move %s\\%s.mp4 %s\\%s.mp4",capodd->templocation,capodd->wcurrentoutput,capodd->destination,capodd->wcurrentoutput);
fprintf(tempbat,"%ls\n",cmd);
//swprintf_s(cmd,8192,L"move %s\\%s.txt %s\\%s.txt",capodd->templocation,capodd->currentoutput,capodd->destination,capodd->currentoutput);
//fprintf(tempbat,"%ls\n",cmd);
//fprintf(tempbat,"del %ls\n",ocmd);
fclose(tempbat);
swprintf_s(cmd,sizeof(cmd),L"cmd /c %s",ocmd);
// just for fun, sleep for twice my latency to make sure the other half of the graph has started
Sleep(1000 *2); // of course, this means our overlap better be within 2x of the periodicity
if (!CreateProcess(NULL,cmd,NULL,NULL,FALSE,0,NULL,NULL,&osi,&pi)) {
fprintf(capodd->c_pF,"couldn't execute copy %d\n",GetLastError());
}