<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
This may help:<tt><br>
<br>
C:\Documents and Settings\Alister&gt;cmd /?<br>
Starts a new instance of the Windows XP command interpreter<br>
<br>
CMD [/A | /U] [/Q] [/D] [/E:ON | /E:OFF] [/F:ON | /F:OFF] [/V:ON |
/V:OFF]<br>
&nbsp;&nbsp;&nbsp; [[/S] [/C | /K] string]<br>
<br>
/C&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Carries out the command specified by string and then terminates<br>
/K&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Carries out the command specified by string but remains<br>
/S&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Modifies the treatment of string after /C or /K (see below)<br>
/Q&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Turns echo off<br>
/D&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Disable execution of AutoRun commands from registry (see below)<br>
/A&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Causes the output of internal commands to a pipe or file to be
ANSI<br>
/U&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Causes the output of internal commands to a pipe or file to be<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Unicode<br>
/T:fg&nbsp;&nbsp; Sets the foreground/background colors (see COLOR /? for more
info)<br>
/E:ON&nbsp;&nbsp; Enable command extensions (see below)<br>
/E:OFF&nbsp; Disable command extensions (see below)<br>
/F:ON&nbsp;&nbsp; Enable file and directory name completion characters (see below)<br>
/F:OFF&nbsp; Disable file and directory name completion characters (see
below)<br>
/V:ON&nbsp;&nbsp; Enable delayed environment variable expansion using ! as the<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; delimiter. For example, /V:ON would allow !var! to expand the<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; variable var at execution time.&nbsp; The var syntax expands
variables<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at input time, which is quite a different thing when inside of
a FOR<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; loop.<br>
/V:OFF&nbsp; Disable delayed environment expansion.<br>
<br>
Note that multiple commands separated by the command separator
'&amp;&amp;'<br>
are accepted for string if surrounded by quotes.&nbsp; Also, for
compatibility<br>
reasons, /X is the same as /E:ON, /Y is the same as /E:OFF and /R is the<br>
same as /C.&nbsp; Any other switches are ignored.<br>
<br>
If /C or /K is specified, then the remainder of the command line after<br>
the switch is processed as a command line, where the following logic is<br>
used to process quote (") characters:<br>
<br>
&nbsp;&nbsp;&nbsp; 1.&nbsp; If all of the following conditions are met, then quote
characters<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; on the command line are preserved:<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; - no /S switch<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; - exactly two quote characters<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; - no special characters between the two quote characters,<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; where special is one of: &amp;&lt;&gt;()@^|<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; - there are one or more whitespace characters between the<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; the two quote characters<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; - the string between the two quote characters is the name<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; of an executable file.<br>
<br>
&nbsp;&nbsp;&nbsp; 2.&nbsp; Otherwise, old behavior is to see if the first character is<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; a quote character and if so, strip the leading character and<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; remove the last quote character on the command line, preserving<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; any text after the last quote character.<br>
<br>
If /D was NOT specified on the command line, then when CMD.EXE starts,
it<br>
looks for the following REG_SZ/REG_EXPAND_SZ registry variables, and if<br>
either or both are present, they are executed first.<br>
<br>
&nbsp;&nbsp;&nbsp; HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\AutoRun<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; and/or<br>
<br>
&nbsp;&nbsp;&nbsp; HKEY_CURRENT_USER\Software\Microsoft\Command Processor\AutoRun<br>
<br>
Command Extensions are enabled by default.&nbsp; You may also disable<br>
extensions for a particular invocation by using the /E:OFF switch.&nbsp; You<br>
can enable or disable extensions for all invocations of CMD.EXE on a<br>
machine and/or user logon session by setting either or both of the<br>
following REG_DWORD values in the registry using REGEDT32.EXE:<br>
<br>
&nbsp;&nbsp;&nbsp; HKEY_LOCAL_MACHINE\Software\Microsoft\Command
Processor\EnableExtensions<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; and/or<br>
<br>
&nbsp;&nbsp;&nbsp; HKEY_CURRENT_USER\Software\Microsoft\Command
Processor\EnableExtensions<br>
<br>
to either 0x1 or 0x0.&nbsp; The user specific setting takes precedence over<br>
the machine setting.&nbsp; The command line switches take precedence over the<br>
registry settings.<br>
<br>
The command extensions involve changes and/or additions to the following<br>
commands:<br>
<br>
&nbsp;&nbsp;&nbsp; DEL or ERASE<br>
&nbsp;&nbsp;&nbsp; COLOR<br>
&nbsp;&nbsp;&nbsp; CD or CHDIR<br>
&nbsp;&nbsp;&nbsp; MD or MKDIR<br>
&nbsp;&nbsp;&nbsp; PROMPT<br>
&nbsp;&nbsp;&nbsp; PUSHD<br>
&nbsp;&nbsp;&nbsp; POPD<br>
&nbsp;&nbsp;&nbsp; SET<br>
&nbsp;&nbsp;&nbsp; SETLOCAL<br>
&nbsp;&nbsp;&nbsp; ENDLOCAL<br>
&nbsp;&nbsp;&nbsp; IF<br>
&nbsp;&nbsp;&nbsp; FOR<br>
&nbsp;&nbsp;&nbsp; CALL<br>
&nbsp;&nbsp;&nbsp; SHIFT<br>
&nbsp;&nbsp;&nbsp; GOTO<br>
&nbsp;&nbsp;&nbsp; START (also includes changes to external command invocation)<br>
&nbsp;&nbsp;&nbsp; ASSOC<br>
&nbsp;&nbsp;&nbsp; FTYPE<br>
<br>
To get specific details, type commandname /? to view the specifics.<br>
<br>
Delayed environment variable expansion is NOT enabled by default.&nbsp; You<br>
can enable or disable delayed environment variable expansion for a<br>
particular invocation of CMD.EXE with the /V:ON or /V:OFF switch.&nbsp; You<br>
can enable or disable completion for all invocations of CMD.EXE on a<br>
machine and/or user logon session by setting either or both of the<br>
following REG_DWORD values in the registry using REGEDT32.EXE:<br>
<br>
&nbsp;&nbsp;&nbsp; HKEY_LOCAL_MACHINE\Software\Microsoft\Command
Processor\DelayedExpansion<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; and/or<br>
<br>
&nbsp;&nbsp;&nbsp; HKEY_CURRENT_USER\Software\Microsoft\Command
Processor\DelayedExpansion<br>
<br>
to either 0x1 or 0x0.&nbsp; The user specific setting takes precedence over<br>
the machine setting.&nbsp; The command line switches take precedence over the<br>
registry settings.<br>
<br>
If delayed environment variable expansion is enabled, then the
exclamation<br>
character can be used to substitute the value of an environment variable<br>
at execution time.<br>
<br>
File and Directory name completion is NOT enabled by default.&nbsp; You can<br>
enable or disable file name completion for a particular invocation of<br>
CMD.EXE with the /F:ON or /F:OFF switch.&nbsp; You can enable or disable<br>
completion for all invocations of CMD.EXE on a machine and/or user logon<br>
session by setting either or both of the following REG_DWORD values in<br>
the registry using REGEDT32.EXE:<br>
<br>
&nbsp;&nbsp;&nbsp; HKEY_LOCAL_MACHINE\Software\Microsoft\Command
Processor\CompletionChar<br>
&nbsp;&nbsp;&nbsp; HKEY_LOCAL_MACHINE\Software\Microsoft\Command
Processor\PathCompletionChar<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; and/or<br>
<br>
&nbsp;&nbsp;&nbsp; HKEY_CURRENT_USER\Software\Microsoft\Command
Processor\CompletionChar<br>
&nbsp;&nbsp;&nbsp; HKEY_CURRENT_USER\Software\Microsoft\Command
Processor\PathCompletionChar<br>
<br>
with the hex value of a control character to use for a particular<br>
function (e.g.&nbsp; 0x4 is Ctrl-D and 0x6 is Ctrl-F).&nbsp; The user specific<br>
settings take precedence over the machine settings.&nbsp; The command line<br>
switches take precedence over the registry settings.<br>
<br>
If completion is enabled with the /F:ON switch, the two control<br>
characters used are Ctrl-D for directory name completion and Ctrl-F for<br>
file name completion.&nbsp; To disable a particular completion character in<br>
the registry, use the value for space (0x20) as it is not a valid<br>
control character.<br>
<br>
Completion is invoked when you type either of the two control<br>
characters.&nbsp; The completion function takes the path string to the left<br>
of the cursor appends a wild card character to it if none is already<br>
present and builds up a list of paths that match.&nbsp; It then displays the<br>
first matching path.&nbsp; If no paths match, it just beeps and leaves the<br>
display alone.&nbsp; Thereafter, repeated pressing of the same control<br>
character will cycle through the list of matching paths.&nbsp; Pressing the<br>
Shift key with the control character will move through the list<br>
backwards.&nbsp; If you edit the line in any way and press the control<br>
character again, the saved list of matching paths is discarded and a new<br>
one generated.&nbsp; The same occurs if you switch between file and directory<br>
name completion.&nbsp; The only difference between the two control characters<br>
is the file completion character matches both file and directory names,<br>
while the directory completion character only matches directory names.<br>
If file completion is used on any of the built in directory commands<br>
(CD, MD or RD) then directory completion is assumed.<br>
<br>
The completion code deals correctly with file names that contain spaces<br>
or other special characters by placing quotes around the matching path.<br>
Also, if you back up, then invoke completion from within a line, the<br>
text to the right of the cursor at the point completion was invoked is<br>
discarded.<br>
<br>
The special characters that require quotes are:<br>
&nbsp;&nbsp;&nbsp;&nbsp; &lt;space&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp; &amp;()[]{}^=;!'+,`~</tt><br>
<pre class="moz-signature" cols="72">Alister Christie
Computers for People
Ph: 04 471 1849 Fax: 04 471 1266
<a class="moz-txt-link-freetext" href="http://www.salespartner.co.nz">http://www.salespartner.co.nz</a>
PO Box 13085
Johnsonville
Wellington </pre>
<br>
<br>
lbisman wrote:
<blockquote cite="mid453ee752.3b3.5e39.25007@clear.net.nz" type="cite">
  <pre wrap="">Should that pChar string be 'cmd /c MySQLExport.bat' as it's
the command interpreter that usually runs batch files...

Laurie..


----- Original Message Follows -----
  </pre>
  <blockquote type="cite">
    <pre wrap="">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) &lt;&gt; 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 <a class="moz-txt-link-abbreviated" href="http://www.chreos.com">www.chreos.com</a>

Wild Software Ltd

_______________________________________________
Delphi mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Delphi@ns3.123.co.nz">Delphi@ns3.123.co.nz</a>
<a class="moz-txt-link-freetext" href="http://ns3.123.co.nz/mailman/listinfo/delphi">http://ns3.123.co.nz/mailman/listinfo/delphi</a>
    </pre>
  </blockquote>
  <pre wrap=""><!---->
Laurie..
_______________________________________________
Delphi mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Delphi@ns3.123.co.nz">Delphi@ns3.123.co.nz</a>
<a class="moz-txt-link-freetext" href="http://ns3.123.co.nz/mailman/listinfo/delphi">http://ns3.123.co.nz/mailman/listinfo/delphi</a>


  </pre>
</blockquote>
</body>
</html>