<!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>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>
[[/S] [/C | /K] string]<br>
<br>
/C Carries out the command specified by string and then terminates<br>
/K Carries out the command specified by string but remains<br>
/S Modifies the treatment of string after /C or /K (see below)<br>
/Q Turns echo off<br>
/D Disable execution of AutoRun commands from registry (see below)<br>
/A Causes the output of internal commands to a pipe or file to be
ANSI<br>
/U Causes the output of internal commands to a pipe or file to be<br>
Unicode<br>
/T:fg Sets the foreground/background colors (see COLOR /? for more
info)<br>
/E:ON Enable command extensions (see below)<br>
/E:OFF Disable command extensions (see below)<br>
/F:ON Enable file and directory name completion characters (see below)<br>
/F:OFF Disable file and directory name completion characters (see
below)<br>
/V:ON Enable delayed environment variable expansion using ! as the<br>
delimiter. For example, /V:ON would allow !var! to expand the<br>
variable var at execution time. The var syntax expands
variables<br>
at input time, which is quite a different thing when inside of
a FOR<br>
loop.<br>
/V:OFF Disable delayed environment expansion.<br>
<br>
Note that multiple commands separated by the command separator
'&&'<br>
are accepted for string if surrounded by quotes. 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. 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>
1. If all of the following conditions are met, then quote
characters<br>
on the command line are preserved:<br>
<br>
- no /S switch<br>
- exactly two quote characters<br>
- no special characters between the two quote characters,<br>
where special is one of: &<>()@^|<br>
- there are one or more whitespace characters between the<br>
the two quote characters<br>
- the string between the two quote characters is the name<br>
of an executable file.<br>
<br>
2. Otherwise, old behavior is to see if the first character is<br>
a quote character and if so, strip the leading character and<br>
remove the last quote character on the command line, preserving<br>
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>
HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\AutoRun<br>
<br>
and/or<br>
<br>
HKEY_CURRENT_USER\Software\Microsoft\Command Processor\AutoRun<br>
<br>
Command Extensions are enabled by default. You may also disable<br>
extensions for a particular invocation by using the /E:OFF switch. 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>
HKEY_LOCAL_MACHINE\Software\Microsoft\Command
Processor\EnableExtensions<br>
<br>
and/or<br>
<br>
HKEY_CURRENT_USER\Software\Microsoft\Command
Processor\EnableExtensions<br>
<br>
to either 0x1 or 0x0. The user specific setting takes precedence over<br>
the machine setting. 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>
DEL or ERASE<br>
COLOR<br>
CD or CHDIR<br>
MD or MKDIR<br>
PROMPT<br>
PUSHD<br>
POPD<br>
SET<br>
SETLOCAL<br>
ENDLOCAL<br>
IF<br>
FOR<br>
CALL<br>
SHIFT<br>
GOTO<br>
START (also includes changes to external command invocation)<br>
ASSOC<br>
FTYPE<br>
<br>
To get specific details, type commandname /? to view the specifics.<br>
<br>
Delayed environment variable expansion is NOT enabled by default. 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. 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>
HKEY_LOCAL_MACHINE\Software\Microsoft\Command
Processor\DelayedExpansion<br>
<br>
and/or<br>
<br>
HKEY_CURRENT_USER\Software\Microsoft\Command
Processor\DelayedExpansion<br>
<br>
to either 0x1 or 0x0. The user specific setting takes precedence over<br>
the machine setting. 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. 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. 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>
HKEY_LOCAL_MACHINE\Software\Microsoft\Command
Processor\CompletionChar<br>
HKEY_LOCAL_MACHINE\Software\Microsoft\Command
Processor\PathCompletionChar<br>
<br>
and/or<br>
<br>
HKEY_CURRENT_USER\Software\Microsoft\Command
Processor\CompletionChar<br>
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. 0x4 is Ctrl-D and 0x6 is Ctrl-F). The user specific<br>
settings take precedence over the machine settings. 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. 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. 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. It then displays the<br>
first matching path. If no paths match, it just beeps and leaves the<br>
display alone. Thereafter, repeated pressing of the same control<br>
character will cycle through the list of matching paths. Pressing the<br>
Shift key with the control character will move through the list<br>
backwards. 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. The same occurs if you switch between file and directory<br>
name completion. 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>
<space><br>
&()[]{}^=;!'+,`~</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) <> 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>