How to get cmd.exe response as string in mql5?

 

Dear All

I want to get cmd.exe response to get some machine id from it and using in my mql5 code

#import "shell32.dll" 
int ShellExecuteW(int hwnd,string operation,string file,string parameters,string directory,int showCmd); 
#import

void OnStart()
  {
string strParameters = "wmic csproduct get uuid";
int result = ShellExecuteW(0, "open", "cmd.exe", strParameters, NULL, 1);
if (result <= 32) Print("Shell Execute Failed: ", result); 
Print(result);
  }

But I couldn't find how to get the cmd response to following line in an string variable.

wmic csproduct get uuid

please help me.

 
Yashar Safarzadeh:

I want to get cmd.exe response to get some machine id from it and using in my mql5 code

Why have you posted in the MQL4 section.

I will move your post to General.

 
Keith Watford:

Why have you posted in the MQL4 section.

I will move your post to General.

Yes,I did mistake, move it please.
 
Yashar Safarzadeh: But I couldn't find how to get the cmd response to following line in an string variable. 

Direct the output to a file, read the file.

 
William Roeder:

Direct the output to a file, read the file.

But "ShellExecuteW " doesn't provide any output in text file. How can I output cmd results in an text file?
 
The command you call must redirect.
 

William Roeder:
The command you call must redirect.

I used following code to output the text file. But nothing was produced.

 string strParameters = "wmic csproduct get uuid >> myoutput.txt";
   int result = ShellExecuteW(0, "open", "cmd.exe", strParameters, NULL, 0);
   if (result <= 32) Print("Shell Execute Failed: ", result);
   Print(result);

While running following command produces the output file.

"wmic csproduct get uuid >> myoutput.txt"
Printing Error gets value 42.
 

Dear William

Thanks for your guide. I solved the problem by running from a batch file and putting the files to Terminal Files folder.

Reason: