如何用delphi写一个批处理文件并自动执行这个批处理文件?(30分)

  • 主题发起人 yueocean
  • 开始时间
Y

yueocean

Unregistered / Unconfirmed
GUEST, unregistred user!
如何用delphi写一个批处理文件并自动执行这个批处理文件?
或者如何实现输入dos命令并执行,
我是个新手,所以麻烦说的详细些,谢谢!!!
 
写批处理文件可以用DELPHI的文件格式写
Var
fn:textfile;
begin
assignfile(fn,'c:/temp.bat');
ReWrite(fn);
Writeln(fn,'@echo off');
Writeln(fn,'path c:/dos');
......
closeFile(fn);
end;

然后可以用 Winexec() 来执行这个批处理文件
Winexec(Pchar('c:/command.com /c c:/temp.bat'),SW_SHOWNORMAL);
你试试,我也不晓得我写错了没有。。。
 
winexec('cmd.exe /c del c:/*.*', sw_hide);
// nt/2000下
winexec('command.com /c del c:/*.*', sw_hide);
// 98下
 
就像写文本文件一样的
 
多人接受答案了。
 
顶部