Delphi Pages Forums

Delphi Pages Forums (http://www.delphipages.com/forum/index.php)
-   General (http://www.delphipages.com/forum/forumdisplay.php?f=2)
-   -   ShellExecute from Delphi5 application (http://www.delphipages.com/forum/showthread.php?t=218666)

rmt 04-04-2019 05:54 AM

ShellExecute from Delphi5 application
 
Dear Expert,
I need to execute following command line from delphi5 application:

C:\Windows\system32>aws s3 cp "c:\test.csv" s3://testbucket/

I am coding as below:

ShellExecute(0, nil, 'cmd.exe', 'aws s3 cp "c:\test2.csv" s3://testbucket/', nil, SW_HIDE);

I tried the below code too:

ShellExecute(handle,'open',PChar('c:\Windows\syste m32\cmd.exe'), PChar('aws s3 cp "c:\test2.csv" s3://myerofirstbucket/'), '', SW_SHOWNORMAL);

But the file is not being copied in the required destination. However, if I run the above command from CMD, its coping successfully. Kindly suggest.

Thanks in advance

Norrit 04-04-2019 12:41 PM

Instead of cmd.exe you should execute aws
And ShellExecute has a result that can be an error code.
Something like:
Code:

var
  executeResult: integer;
begin
  executeResult := ShellExecute(....);
  if (executeResult >32)
    ShowMessage(SysErrorMessage(GetLastError)); // or perhaps directly on executeResult
end;


rmt 04-05-2019 02:52 AM

Dear Norrit,

I executed as below; I am not sure if this is the way to be done. But the file is not being copied.

ExecuteResult := ShellExecute(0, 'open',pchar('aws.exe'), pchar('aws s3 cp "c:\test2.csv" s3://myerofirstbucket/'), nil, SW_SHOWNORMAL);

if (executeResult >32) then
ShowMessage(SysErrorMessage(GetLastError));

The message shows "Operation completed successfully"

Thanks and regards,

rmt 04-06-2019 01:35 AM

Dear expert,
Please provide us solution..

Regards

Norrit 04-08-2019 08:49 AM

What is the value of ExecuteResult ?

And it's pointless to duplicate aws. First aws is the program to execute, the second is part of the parameter list, so therefor it shouldn't be there.
Code:

ExecuteResult := ShellExecute(0, 'open',pchar('aws.exe'), pchar('s3 cp "c:\test2.csv" s3://myerofirstbucket/'), nil, SW_SHOWNORMAL);

rmt 04-09-2019 02:53 AM

Dear Norrit,

Thank you so much. Its working now.

Regards,
Rashmita


All times are GMT. The time now is 12:23 AM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2019, vBulletin Solutions, Inc.