Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Piping data to a file with the windows ‘ShellExecute’ function

I am using the ‘ShellExecute’ function in windows vista

Is there any way to pipe the output to a file?

i.e.

MySqlDump.exe '-u user1 -ppassword dbName > TheOutputFile.Sql

Here my code

theProgram     :=  'MySqlDump.exe';
itsParameters  :=  '-u user1  -ppassword  dbName';
rslt := ShellExecute(0, 'open',
                       pChar (theProgram),
                       pChar (itsParameters),
                       nil,
                       SW_SHOW);

EDIT:

I have tried

 itsParameters  :=  '-u user1  -ppassword  dbName > TheOutputFile.Sql';

but this does not work

like image 471
Charles Faiga Avatar asked Feb 27 '23 18:02

Charles Faiga


1 Answers

@Charles, you can use the redirector simbol ">" in a ShellExecute, but using the cmd.exe which is the Windows command interpreter.

try this sample

ShellExecute(0,nil,'cmd.exe','/c MySqlDump.exe -u user1  -ppassword  dbName > TheOutputFile.Sql',nil,sw_normal);

Another options is use pipes, you can find a very nice example in this link.

like image 200
RRUZ Avatar answered Mar 02 '23 06:03

RRUZ