function ExecuteCommand(CommandStr, ExecDir: string; ShowWindow: boolean): THandle;
var
proc: PROCESS_INFORMATION;
Start: STARTUPINFO;
begin
//Initialize the STARTUPINFO structure:
FillChar(Start,SizeOf(Start),0);
Start.cb := SizeOf(Start);
Start.dwFlags := STARTF_USESHOWWINDOW;
if ShowWindow then Start.wShowWindow := SW_SHOW else Start.wShowWindow := SW_HIDE;
//Start the shelled application:
Win32Check(CreateProcessA(nil, PChar(CommandStr), nil, nil, True,
NORMAL_PRIORITY_CLASS, nil, PChar(ExecDir), Start, proc));
Result := proc.hProcess;
end;