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;
This opens the cmd.exe and passes the correct string in the cmd.exe , BUT
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.
Can someone help me with this.
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. Try adding '/c' to the beginning of your parameter string, ie sCmd := Pwidechar('/c b4a_c2dm. bat'.... Also, if you are passing literals, you could do that in one string, '/c b4a_c2dm.
bat from anywhere on the command line. Show activity on this post. Create a folder called Batches (lets say in your C drive). Append C:\Batches in your path environment variable and you then can run batch files in that directory from anywhere.
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.
Regarding your program,
ShellExecute (application.handle, 'open', 'cmd', PChar(sCmd), nil, SW_MAXIMIZE)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With