x4
asked on
Create Process and Parameter.
I was wondering if anyone knew how to execute a batch file with a paramater attached.
I can use the code below to just exe the batch file but when I try to add the parameter at the end (NAME).
It drops out.
Procedure
var
Name: string;
begin
Name := TEST;
FileToRun := C:\TEMP + 'RUN.BAT ' + NAME;
if CreateProcess(nil, PChar(FileToRun), nil,
nil, false, NORMAL_PRIORITY_CLASS, nil, nil,
startinfo, proc_info) <> False then
begin
// The process has been successfully created so execute it and wait
// until it ends while still processing the form
while MsgWaitForMultipleObjects( 1,Proc_Inf o.hProcess ,
false, INFINITE, (QS_POSTMESSAGE Or QS_SENDMESSAGE))
<> WAIT_OBJECT_0 do
begin
Forms.Application.ProcessM essages;
end;
// Process has finished. So close the window
//CloseHandle(proc_info.hP rocess);
// take out because dos window closes by itself
end;
end;
I can use the code below to just exe the batch file but when I try to add the parameter at the end (NAME).
It drops out.
Procedure
var
Name: string;
begin
Name := TEST;
FileToRun := C:\TEMP + 'RUN.BAT ' + NAME;
if CreateProcess(nil, PChar(FileToRun), nil,
nil, false, NORMAL_PRIORITY_CLASS, nil, nil,
startinfo, proc_info) <> False then
begin
// The process has been successfully created so execute it and wait
// until it ends while still processing the form
while MsgWaitForMultipleObjects(
false, INFINITE, (QS_POSTMESSAGE Or QS_SENDMESSAGE))
<> WAIT_OBJECT_0 do
begin
Forms.Application.ProcessM
end;
// Process has finished. So close the window
//CloseHandle(proc_info.hP
// take out because dos window closes by itself
end;
end;
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks dont know why I didn't figure that out myself.
Rick Halle