Thanks :)
Rob Martin
Software Engineer
phone +64 03 377 0495
fax +64 03 377 0496
web www.chreos.com
Wild Software Ltd
John Bird wrote:
Cmd /c is from the help:
Starts a new instance of the Windows XP command interpreter
CMD [/A | /U] [/Q] [/D] [/E:ON | /E:OFF] [/F:ON | /F:OFF] [/V:ON | /V:OFF]
[[/S] [/C | /K] string]
/C Carries out the command specified by string and then terminates
/K Carries out the command specified by string but remains
You have to be aware when its needed and when it isn't. For instance I
usually use ShellExecute, and if the command has the .BAT on the end and the
windows assocation for running a .BAT extension is in place then it make the
association with CMD itself. Specifying CMD/C will remove any uncertainty.
Remember if you run such a command on Windows 9x or ME then you need to use
instead COMMAND/C
John
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of Robert martin
Sent: Thursday, 26 October 2006 11:10 a.m.
To: [EMAIL PROTECTED]; NZ Borland Developers Group - Delphi List
Subject: Re: [DUG] CreateProcess
Hi
You are the man Laurie. That seems to work great now!
btw what does the /c do?
Rob Martin
Software Engineer
phone +64 03 377 0495
fax +64 03 377 0496
web www.chreos.com
Wild Software Ltd
lbisman wrote:
Should that pChar string be 'cmd /c MySQLExport.bat' as it's the
command interpreter that usually runs batch files...
Laurie..
----- Original Message Follows -----
Hi
I am trying to use create process to run a batch file.
The batch file exports a MySQL DB to a file. The batch
file runs but the file is 0kb however if run that batch
file normally (not from CreateProcess) the file is
correctly created (about 2MB). The code I am using is
shown below, does anyone have any idea as to what I am
doing wrong?
var
proc_info : TProcessInformation;
startinfo : TStartupInfo;
ExitCode : longword;
begin
Result := False;
// Initialize the structures
FillChar(proc_info, sizeof(TProcessInformation), 0);
FillChar(startinfo, sizeof(TStartupInfo), 0);
startinfo.cb := sizeof(TStartupInfo);
// Attempts to create the process
if (CreateProcess(Nil,
pChar('MySQLExport.bat'),
nil,
nil,
false,
NORMAL_PRIORITY_CLASS,
nil,
pChar(AppDir),
startinfo,
proc_info) <> False) then begin
// Process created, now s wait till it ends...
WaitForSingleObject(proc_info.hProcess, INFINITE);
GetExitCodeProcess(proc_info.hProcess, ExitCode);
CloseHandle(proc_info.hThread);
CloseHandle(proc_info.hProcess);
Sleep(5000); //Wait 5secs just to allow any
windows cleanup or other to finish
if (FileExists(AppDir + BASE_FILE) = True) then begin
if (CreateZipFile = True) then begin
Result := True;
end;
end;
end;
end;
--
Rob Martin
Software Engineer
phone +64 03 377 0495
fax +64 03 377 0496
web www.chreos.com
Wild Software Ltd
_______________________________________________
Delphi mailing list
Delphi@ns3.123.co.nz http://ns3.123.co.nz/mailman/listinfo/delphi
Laurie..
_______________________________________________
Delphi mailing list
Delphi@ns3.123.co.nz http://ns3.123.co.nz/mailman/listinfo/delphi
_______________________________________________
Delphi mailing list
Delphi@ns3.123.co.nz http://ns3.123.co.nz/mailman/listinfo/delphi
__________ NOD32 1.1461 (20060329) Information __________
This message was checked by NOD32 antivirus system. http://www.eset.com
_______________________________________________
Delphi mailing list
Delphi@ns3.123.co.nz
http://ns3.123.co.nz/mailman/listinfo/delphi
_______________________________________________
Delphi mailing list
Delphi@ns3.123.co.nz
http://ns3.123.co.nz/mailman/listinfo/delphi