Newsgroups : Borland : borland.public.delphi.nativeapi.win32 : 2008 Jan : How to start a batch file via CreateProcess?
| Subject: | How to start a batch file via CreateProcess? |
| Posted by: | "Bo Berglund" (bo.berglu..@telia.com) |
| Date: | Thu, 24 Jan 2008 18:11:53 |
I know how to start an exe file via CreateProcess, this is no
problems.
But when I try to execute a batch file it does not work.
I created a test.bat file with the single line:
echo %1 > %2
When run from the command prompt like this:
test.bat Charlie C:\foxbat.txt
it results in the creation of a new file with name foxbat.txt and
containing 'Charlie'.
But when I try this with the CmdLine parameter being:
test.bat "Charlie" "C:\foxbat.txt"
it results in nothing:
CreateProcess(nil, // lpApplication
pChar(Cmdline), // lpCommandLine
nil, // lpProcessAttributes
nil, // lpThreadAttributes
InheritHandle, // bInheritHandles
prioCls or CREATE_NEW_CONSOLE, // dwCreateFlags
nil, // lpEnvironment
nil, // lpCurrentDirectory
si, // lpStartupInfo
FPiInfo;
(I have a general function to start programs, that I call and it
contains this CreateProcess call.
I would like the user to be able to execute arbitrary files throgh my
command interface.
How is it properly done?
/BoB