open application silently in the background using Shellexecute

To add comments, please log in or register
jaffer wilson
775
jaffer wilson  

I have tried the following:  

#import "shell32.dll" 
int ShellExecuteW(int hwnd,string operation,string file,string parameters,string directory,int showCmd); 
#import
string strParameters = "/c python c:\\createFiles.py ";
int result = ShellExecuteW(0, "open", "cmd.exe", strParameters, NULL, 1);
if (result <= 32) Print("Shell Execute Failed: ", result); 
       

The above command is creating the command prompt to open and then execute the respective commands on it. Meanwhile if I am clicking on something and suddenly the execution occurs then the complete windows is hanged and nothing is executed till I reclick outside the cmd prompt.    

Kindly, let me know how I can run the command silently without opening the cmd prompt on the screen.

whroeder1
17940
whroeder1  
What does that 1 mean? This is what I have in my notes:
/*                               Notes shell
auto
ShellExecuteA(0,"Open","cmd.exe"," /C del C:\hello.txt > del ", "",0);
#import "shell32.dll"
   int      ShellExecuteA(int    hWnd, string   Verb, string   File, string   Parameter, string Path, int      ShowCommand);
#import
bool     Shell(string file, string parameters=""){
   #define DEFDIRECTORY NULL
   #define OPERATION "open"   // or print
   #define SW_HIDE            0  // http://www.metatrader4.com/forum/1476
   #define SW_SHOWNORMAL      1
   #define SW_NORMAL       1
   #define SW_SHOWMINIMIZED   2
   #define SW_SHOWMAXIMIZED   3
   #define SW_MAXIMIZE        3
   #define SW_SHOWNOACTIVATE  4
   #define SW_SHOW            5
   #define SW_MINIMIZE        6
   #define SW_SHOWMINNOACTIVE 7
   #define SW_SHOWNA       8
   #define SW_RESTORE         9
   #define SW_SHOWDEFAULT     10
   #define SW_FORCEMINIMIZE   11
   #define SW_MAX          11
   int      r=ShellExecuteA(0, OPERATION, file, parameters, DEFDIRECTORY, SW_SHOWNORMAL);
   if(r <= 32){   Alert("Shell failed: ", r); return(false);   }
   return(true);
}
jaffer wilson
775
jaffer wilson  
whroeder1:
What does that 1 mean? This is what I have in my notes:

Thank you for thy notes amigo. I have got it.

To add comments, please log in or register