Close another metatrader 5 terminal using code

ezraluandre

Trader
Jun 17, 2020
33
1
24
30
Hi, Is there a way to close another MT5 terminal using mql5?

I tried using WinExec but failed to close the other MT5 with error 2 result.
 

Enivid

Administrator
Staff member
Nov 30, 2008
18,696
1,376
144
Odesa
www.earnforex.com
This depends on how you launched the program. Did you start it from MQL5 code as well?
If not, then you need to search the right program using GetClassName and then use PostMessage to send WM_CLOSE to it. At least that's how it worked with MT4 long time ago.