Re: ShellExecute

From: Davids (nowhere_at_nowthere.com)
Date: 12/23/03


Date: Tue, 23 Dec 2003 11:19:47 -0700

The redirection operators, (<, >, >>, and variations) are part of the command
line interpreter. Althought this API function is called "shellexecute" I doubt
it's sending the command to the CLI; rather, the CLI most likely calls
"shellexecute" to process commands. I've never ever seen any function that
processes command line file redirection operators. The way the CLI usually
works is to attach files of the given names to stdin, stdout, and stderr (as
needed) and THEN execute the command. The shellexecute command is designed to
take file handles to just such pre-opened files.

Your solution here works because batch files are submitted to the CLI (cmd.exe
in WinNT, command.com in Win9x). It's a perfectly acceptable solution.
However, by simply opening the output file (c:\testbackkup.sql) and passing its
write handle as the parameter for stdout when you call shellexecute, you'd get
the desired behavior.

-David

Alan wrote:

> Thank you for your advice.
>
> For the immediate remedy, I found the solution is the put the mysqldump
> statement -
> c:\mysql\bin\mysqldump -h server1 -u
> john -pjohn --extended-insert --databases test > c:\testbackkup.sql
> into a batch file called mysqldump.bat:
>
> shellexecute(Handle,
> 'open',
> 'C:\mysqldump.bat',
> nil,
> nil,
> SW_SHOWNORMAL);
>
> It works and I can find the backup sql file.
> However, I will try to find the solution so that I can put the mysqldump
> statement into the ShellExecute or CreateProcess API as parameter.
>
> "Rob Kennedy" <.> wrote in message news:3fe69464$1@newsgroups.borland.com...
> > Alan wrote:
> > > So what should I fill in the mysqldump parameters list instead of using
> the
> > > '>' ?
> >
> > As I just said, use the TStartupInfo record with the CreateProcess
> > function -- ShellExecute will be useless. Go read about CreateProcess on
> > MSDN first. I suggested that you would be replacing the standard output
> > handle for the new process. And I'll mention again that RedCon will help
> > you solve your problem, and that Google Groups is a useful resource.
> >
> > --
> > Rob



Relevant Pages

  • Re: send email with shellexecute but crlf in body does not work
    ... like opening up a DOS window and typing a command. ... > I try to send an email with shellexecute in FVP8 on Win2k with Outlook ... > Unfortunately the body text will not show my crlf. ...
    (microsoft.public.fox.programmer.exchange)
  • Re: autorun.inf
    ... shellexecute e.. ... Remarks ... The open command specifies the path and file name of the application that AutoRun launches when a user inserts a disc in the drive. ... verb The verb that corresponds to the command. ...
    (microsoft.public.windowsxp.general)
  • Re: remove non empty direcory
    ... ShellExecute will execute any command you can pass to the Start/Run... ... You'd test whether a directory exists by calling CreateDirectory and ...
    (microsoft.public.vc.language)
  • Re: RUN command fails
    ... The RUN command is working fine. ... STRING cParameters ... > But you should use the ShellExecute API function. ... >> Error message: ...
    (microsoft.public.fox.programmer.exchange)
  • Re: ShellExecute and copy, delete command
    ... The COPY command is internal to the Command Prompt, ... > ShellExecute to do the file manipulation job? ... Tim Robinson (MVP, Windows SDK) ...
    (microsoft.public.vc.language)