Transferring data to a file using the ShellExecute command

I use the ShellExecute function in Windows Vista p>

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

i.e.

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

Here is my code

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

EDIT:

I tried

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

but it does not work

+3
source share
4 answers

@Charles, you can use the sim redirector ">" file in ShellExecute, but using cmd.exe, which is an interpreter of Windows commands.

try this sample

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

Other options are using channels, you can find a very good example in this link .

+4

( cmd script), , _ popen ShellExecute.

-result-file mysqldump.

+1
+1

, CreateProcess , hStrOutput STARTUPINFO. .

+1

Source: https://habr.com/ru/post/1729072/


All Articles