Does anybody know if there's a way I can code my ea such that when all positions close, it will run "c:\shutdown.exe" which turns off my pc?
is there a run command or shell command anyone is familiar with? Thanks! :)
You have to import shell32.dll to run external programs:
#import "shell32.dll"
int ShellExecuteA(int hwnd,string Operation,string File,string Parameters,string Directory,int ShowCmd);
#import
Then when you want to run it you do it this way:
ShellExecuteA(0, "Open", "c:\shutdown.exe", "", "", 1);
You have to import shell32.dll to run external programs:
#import "shell32.dll"
int ShellExecuteA(int hwnd,string Operation,string File,string Parameters,string Directory,int ShowCmd);
#import
Then when you want to run it you do it this way:
ShellExecuteA(0, "Open", "c:\shutdown.exe", "", "", 1);
thanks robofx!
You have to import shell32.dll to run external programs:
#import "shell32.dll"
int ShellExecuteA(int hwnd,string Operation,string File,string Parameters,string Directory,int ShowCmd);
#import
Then when you want to run it you do it this way:
ShellExecuteA(0, "Open", "c:\shutdown.exe", "", "", 1);
do we need to copy shell32 dll form windows folder to experts/libraries or just use this code snippet only ?
just use the code
does not wrk for me :( . i did the code as robofx.org says. it did nothing but shows cmd n within a moment it dissapear just like that n pc doesnt get shutdwn.can anyone help me ?
The example above would work if shutdown.exe file exists in C:\
Here's the universal way:
ShellExecuteA(0, "Open", "C:\Windows\System32\shutdown.exe", "/s /t 120", "", 1);
This will shutdown PC in 120 seconds.
Or:
ShellExecuteA(0, "Open", "C:\Windows\System32\shutdown.exe", "/s /t 0", "", 1);
to shutdown immediately.
Make sure you have enabled DLL files in MT4.
The example above would work if shutdown.exe file exists in C:\
Here's the universal way:
ShellExecuteA(0, "Open", "C:\Windows\System32\shutdown.exe", "/s /t 120", "", 1);
This will shutdown PC in 120 seconds.
Or:
ShellExecuteA(0, "Open", "C:\Windows\System32\shutdown.exe", "/s /t 0", "", 1);
to shutdown immediately.
Make sure you have enabled DLL files in MT4.
or don't use path at all just
ShellExecuteA(0, "Open", "shutdown.exe", "/s /t 0", "", 1);
The example above would work if shutdown.exe file exists in C:\
Here's the universal way:
ShellExecuteA(0, "Open", "C:\Windows\System32\shutdown.exe", "/s /t 120", "", 1);
This will shutdown PC in 120 seconds.
Or:
ShellExecuteA(0, "Open", "C:\Windows\System32\shutdown.exe", "/s /t 0", "", 1);
to shutdown immediately.
Make sure you have enabled DLL files in MT4.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Does anybody know if there's a way I can code my ea such that when all positions close, it will run "c:\shutdown.exe" which turns off my pc?
is there a run command or shell command anyone is familiar with? Thanks! :)