Download MetaTrader 5

call dos commands with ShellExecuteA

To add comments, please log in or register
Interested in MetaTrader 5 features? Learn more about them!
Ryan
76
Ryan 2009.05.20 22:05 

I'm trying to execute some command prompt commands but I'm having a little trouble.


I can get xcopy to work

ShellExecuteA(0,"Open","xcopy","\""+From_path+File_name+"\" \""+Destination_path+"\" /y","",3);


But how do I get the command move to work

I tried

ShellExecuteA(0,"Open","move"," /y""\""+From_path+File_name+"\" \""+Destination_path,"",3);

But it doesn't open the command prompt

I guess xcopy opens the command prompt automatically, maybe because it is a external command??


Then I tried

ShellExecuteA(0,"Open","cmd.exe","move /y""\""+From_path+File_name+"\" \""+Destination_path,"",3);

but that doesn't work either.

So how do I get these to work?

Patrick Nouvion
11
Patrick Nouvion 2009.05.20 23:03  

Why don't you create bat files and then use the ShellExecute command and point them to the bat file?

I have not tried it myself but in theory that should work :P

Ryan
76
Ryan 2009.05.20 23:38  

That does work

string path = "C:\Program Files (x86)\Interbank FX Trader 4\experts\files\move.bat";
ShellExecuteA(0, "Open", path, 0, "", 3);


But isn't there a way to to this without a batch file?

Patrick Nouvion
11
Patrick Nouvion 2009.05.21 00:07  
bunnychopper:

That does work

string path = "C:\Program Files (x86)\Interbank FX Trader 4\experts\files\move.bat";
ShellExecuteA(0, "Open", path, 0, "", 3);


But isn't there a way to to this without a batch file?

Well the difference is that xcopy is an actual exe file whereas move is command inside of cmd.exe ...

You could write your own move.exe program ...

JC
1456
JC 2009.05.21 01:22  
bunnychopper:

[...] But isn't there a way to to this without a batch file?

Have a look at the documentation of cmd (i.e. use "cmd /?"). Off the top of my head you probably need to be using "cmd /c <command>" rather than just "cmd <command>". 

Ryan
76
Ryan 2009.05.21 05:57  

Well after 4 hours of trial and error I finally figured it out


To delete the file located at C:\hello.txt

ShellExecuteA(0,"Open","cmd.exe"," /C del C:\hello.txt > del ", "",0);


To move the same file to C:\Users

ShellExecuteA(0,"Open","cmd.exe"," /C move "C:\hello.txt " "C:\Users" > move", "",0);


And of course remember

#import "shell32.dll"
int ShellExecuteA(int hwnd,string Operation,string File,string Parameters,string Directory,int ShowCmd);

Do Hung
151
Do Hung 2011.12.03 07:46  

I want to open a form in menu File/Login then write information on text box of this form.


Please advice me how to do this with EA.

Thank you very much !

whroeder1
14543
whroeder1 2011.12.03 13:26  
oxarbitrage
152
oxarbitrage 2012.05.08 14:03  

i know its old but this post helped me on what i was trying to do. i appreciate the comments made here-

Saravanakumar D
360
Saravanakumar D 2013.09.28 06:00  
bunnychopper:

Well after 4 hours of trial and error I finally figured it out


To delete the file located at C:\hello.txt

ShellExecuteA(0,"Open","cmd.exe"," /C del C:\hello.txt > del ", "",0);


To move the same file to C:\Users

ShellExecuteA(0,"Open","cmd.exe"," /C move "C:\hello.txt " "C:\Users" > move", "",0);


And of course remember

#import "shell32.dll"
int ShellExecuteA(int hwnd,string Operation,string File,string Parameters,string Directory,int ShowCmd);



You are awesome man..
Simon Gniadkowski
Moderator
18001
Simon Gniadkowski 2013.09.28 07:25  
d.saravana21:


You are awesome man..
It took you 4 years to post that ? why bother ? why dredge a 4 year old thread back to the top of the list just to say "you are awesome" to someone who will probably never read your post ?


Thread start date: 2009.05.21
12
To add comments, please log in or register