怎么判断一个bat文件是否已执行结束

如何判断一个bat文件是否已执行结束
何判断一个bat文件是否已执行结束

------解决方案--------------------
>>在bat结束的时候写一个文件吧,检测文件是否存在就可以了。

如果这样的话,在bat开始的时候要del这个文件

if exists filename then del filename
rem other operations


rem end of other operations
if not exists filename then copy nul filename
------解决方案--------------------
不好意思,上面的代码不是delphi的
Delphi(Pascal) code

function WinExecAndWait32_v1(FileName: string; Visibility: integer): Cardinal;
var
  zAppName: array[0..512] of char;
  zCurDir: array[0..255] of char;
  WorkDir: string;
  StartupInfo: TStartupInfo;
  ProcessInfo: TProcessInformation;
begin
  StrPCopy(zAppName, FileName);
  GetDir(0, WorkDir);
  StrPCopy(zCurDir, WorkDir);
  FillChar(StartupInfo, Sizeof(StartupInfo), #0);
  StartupInfo.cb := Sizeof(StartupInfo);
  StartupInfo.dwFlags := STARTF_USESHOWWINDOW;
  StartupInfo.wShowWindow := Visibility;
  if not CreateProcess(nil,
    zAppName,               { pointer to command line string }
    nil,                    { pointer to process security attributes }
    nil,                    { pointer to thread security attributes }
    true,                   { handle inheritance flag }
    CREATE_NEW_CONSOLE or   { creation flags }
    NORMAL_PRIORITY_CLASS,
    nil,                    { pointer to new environment block }
    nil,                    { pointer to current directory name, PChar}
    StartupInfo,            { pointer to STARTUPINFO }
    ProcessInfo)            { pointer to PROCESS_INF }
    then Result := INFINITE {-1} else
  begin
    WaitforSingleObject(ProcessInfo.hProcess, INFINITE);
    GetExitCodeProcess(ProcessInfo.hProcess, Result);
    CloseHandle(ProcessInfo.hProcess);  { to prevent memory leaks }
    CloseHandle(ProcessInfo.hThread);
  end;
end;

------解决方案--------------------
bat文件执行时会有新的进程或线程启动
可以利用WaitForSingleObject这个API函数来实现对进程或者线程的等待,直到它返回。
is that clear?