H
happygb
Unregistered / Unconfirmed
GUEST, unregistred user!
我自己在程序里調用了一個BAT文件,但是在創建完成后馬上調用確不成功,但是我把創建与調用分開寫確可以成功,請大家幫看看是什么問題
procedure TForm1.Button1Click(Sender: TObject);
var
aList:TstringList;
TmpDirchar;
begin
try
try
aList:=TstringList.Create;
aList.Add('@echo off');
aList.Add('D:');
aList.Add('move ff /recycled');
aList.Add('echo Exit');
GetMem(TmpDir,255);
GetTempPath(255,TmpDir);
TmpDir:=pchar(TmpDir+'a.BAT');
aList.SaveToFile(TmpDir);
//WinExec(pchar('C:/Documents and Settings/gbo/Local Settings/Temp/a.BAT'),SW_HIDE);
WinExec(pchar(TmpDir),SW_HIDE);
//deletefile(TmpDir);
ShowMessage('Success!');
except
ShowMessage('Faild!');
end;
Finally
aList.Free;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
aList:TstringList;
TmpDirchar;
begin
try
try
aList:=TstringList.Create;
aList.Add('@echo off');
aList.Add('D:');
aList.Add('move ff /recycled');
aList.Add('echo Exit');
GetMem(TmpDir,255);
GetTempPath(255,TmpDir);
TmpDir:=pchar(TmpDir+'a.BAT');
aList.SaveToFile(TmpDir);
//WinExec(pchar('C:/Documents and Settings/gbo/Local Settings/Temp/a.BAT'),SW_HIDE);
WinExec(pchar(TmpDir),SW_HIDE);
//deletefile(TmpDir);
ShowMessage('Success!');
except
ShowMessage('Faild!');
end;
Finally
aList.Free;
end;
end;