Delphi Pages Forums  

Go Back   Delphi Pages Forums > Delphi Forum > General

Lost Password?

Reply
 
Thread Tools Display Modes
  #1  
Old 04-04-2019, 05:54 AM
rmt rmt is offline
Senior Member
 
Join Date: Jun 2013
Posts: 299
Default 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
__________________
Rmt

Last edited by rmt; 04-04-2019 at 10:28 AM.
Reply With Quote
  #2  
Old 04-04-2019, 12:41 PM
Norrit Norrit is online now
Moderator
 
Join Date: Aug 2001
Location: Landgraaf
Posts: 7,335
Default

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;
Reply With Quote
  #3  
Old 04-05-2019, 02:52 AM
rmt rmt is offline
Senior Member
 
Join Date: Jun 2013
Posts: 299
Default

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

Last edited by rmt; 04-05-2019 at 02:56 AM.
Reply With Quote
  #4  
Old 04-06-2019, 01:35 AM
rmt rmt is offline
Senior Member
 
Join Date: Jun 2013
Posts: 299
Default

Dear expert,
Please provide us solution..

Regards
__________________
Rmt
Reply With Quote
  #5  
Old 04-08-2019, 08:49 AM
Norrit Norrit is online now
Moderator
 
Join Date: Aug 2001
Location: Landgraaf
Posts: 7,335
Default

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);
Reply With Quote
  #6  
Old 04-09-2019, 02:53 AM
rmt rmt is offline
Senior Member
 
Join Date: Jun 2013
Posts: 299
Default

Dear Norrit,

Thank you so much. Its working now.

Regards,
Rashmita
__________________
Rmt
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT. The time now is 01:04 PM.


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