call dos commands with ShellExecuteA

 

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?

 

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

 

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?

 
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 ...

 
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>". 

 

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);

 

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 !

 

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

 
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..
 
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
Reason: