procedure TForm1.Button2Click(Sender: TObject);
var
f:Textfile;
BATName:string;
str1,str2:string;
begin
BATName:='test.bat';
//1分钟后重新启动程序
str1:='at '+copy(datetimetostr(IncMinute(time,1)),12,5)+' /interactive C:/Project1.exe';
//2分钟后把at清除掉 免得别人看到 这样别人查看at后看不到什么
str2:='at '+copy(datetimetostr(IncMinute(time,2)),12,5)+' /delete /y';
Assignfile(f,BATName);
if FileExists(BATName)=false then //FileExists检测文件是否存在
begin
ReWrite(f);
Closefile(f);
end;
Append(f);
Writeln(f,str1);
Writeln(f,str2);
Closefile(f);
//如果执意要用bat只能这样了:
WinExec(PAnsiChar('test.bat'),0);
end;