如何使用Delphi正确执行.bat文件 [英] How to use Delphi to execute a .bat file properly
本文介绍了如何使用Delphi正确执行.bat文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在从德尔福.bat文件(2010)。
I am running a .bat file from delphi(2010).
procedure TForm1.Button2Click(Sender: TObject);
var sCmd: String;
Begin
sCmd := Pwidechar('b4a_c2dm.bat' +' ' +'send ' + Trim(Edit1.Text)+' ' + Trim(edit2.Text ));
ShellExecute(0, 'open', 'b4a_c2dm.bat', PChar(sCmd), nil, SW_SHOWMAXIMIZED);
end;
这将打开的cmd.exe并通过在CMD.EXE正确的字符串,但
This opens the cmd.exe and passes the correct string in the cmd.exe , BUT
一些如何在.bat文件行(java命令b4a_c2dm.jar anywheresoftware.b4a.c2dm.C2DM%*)是显示了在cmd.exe窗口,而不是让.bat文件完成其工作。
Some how the line in the .bat file (java -cp b4a_c2dm.jar anywheresoftware.b4a.c2dm.C2DM %*) is showing up in the cmd.exe window and not letting the .bat file do its job.
有人可以帮助我。
推荐答案
在为了执行一个批处理文件,被称为程序CMD和它的参数应该是批处理文件的名称。
In order to execute a batch file, the program to be called is 'cmd' and its parameter should be the name of the batch file.
关于你的程序,
ShellExecute (application.handle, 'open', 'cmd', PChar(sCmd), nil, SW_MAXIMIZE)
这篇关于如何使用Delphi正确执行.bat文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文