I want to achieve the following with a CreateProcess() - call:
- Change to an svn working-copy
- Execute svn commands
- Pipe the output to a file
I try this with the following function
procedure TQPortMainForm.CmdMigrationClick(Sender: TObject);
var
StartInfo: TStartupInfo;
ProcInfo: TProcessInformation;
CreateOk: boolean;
input: String;
begin
{ fill with known state }
FillChar(StartInfo, SizeOf(TStartupInfo), #0);
FillChar(ProcInfo, SizeOf(TProcessInformation), #0);
StartInfo.cb := SizeOf(TStartupInfo);
//debug
input := 'D: && cd D:\Qport\trunk\Qport\ && ' + SVN_PATH + ' log > C:\users\PhilippKober\UNIQUE_NAME_BLUB.txt';
CreateOk := CreateProcess(nil, PChar(input), nil, nil, false, CREATE_NEW_PROCESS_GROUP + NORMAL_PRIORITY_CLASS, nil,
nil , StartInfo, ProcInfo);
{ check to see if successful }
if CreateOk then
// may or may not be needed. Usually wait for child processes
WaitForSingleObject(ProcInfo.hProcess, INFINITE);
end;
Simply nothing happens. Has anybody got an idea how to achieve this?
Thanks,
Philipp
EDIT 1: I am using Delphi XE - Build 7601: Service Pack 1
EDIT 2: Here is the solution:
var
StartInfo: TStartupInfo;
ProcInfo: TProcessInformation;
CreateOk: boolean;
input: String;
path : String;
cmd : String;
begin
{ fill with known state }
FillChar(StartInfo, SizeOf(TStartupInfo), #0);
FillChar(ProcInfo, SizeOf(TProcessInformation), #0);
StartInfo.cb := SizeOf(TStartupInfo);
path := 'D:\Qport\trunk\Qport\';
cmd := 'C:\Windows\System32\cmd.exe';
//debug
input := '/C' + SVN_PATH + ' help > C:\users\PhilippKober\UNIQUE_NAME_BLUB.txt';
CreateOk := CreateProcess(PChar(cmd), PChar(input), nil, nil, false, CREATE_NEW_PROCESS_GROUP + NORMAL_PRIORITY_CLASS, nil,
Pchar(path), StartInfo, ProcInfo);
{ check to see if successful }
if CreateOk then
// may or may not be needed. Usually wait for child processes
WaitForSingleObject(ProcInfo.hProcess, INFINITE);
end;