Lightweight batch script to ensure Metatrader Terminals are always running
metaMonitor is a lightweight batch script that monitors and ensures your MetaTrader 4/5 terminals are always running. If a terminal is not found, it will automatically restart it using its .exe path or an optional .lnk shortcut.
- ✅ Monitors multiple MetaTrader terminals (MT4 & MT5)
- 🚀 Auto-restarts terminals if they stop running
- 🧠 Supports
.lnkshortcuts with custom icons or launch settings - 📄 Logs all activity to
metaMonitor.log - 🔁 Can be set to run on Windows startup
- 💬 Simple plain-text configuration (
terminals.txt)
For convenience and consistency, store all script-related files in a dedicated base folder, for example:
C:\Users\ibitebyt3s\Documents\metaMonitor\
│
├── metaMonitor.bat :: Main monitoring script
├── terminals.txt :: List of MetaTrader terminals to monitor
└── metaMonitor.log :: Log file (auto-generated)
This structure keeps everything in one place, and ensures logs and configs stay organized.
At the top of metaMonitor.bat, you can customize these values:
set "TIMEOUT=60" :: Time (in seconds) between monitoring cycles
set "START_DELAY=30" :: Delay (in seconds) after starting a terminal
set "TERMINALS_FILE=terminals.txt" :: Config file with terminal paths
set "LOG_FILE=metaMonitor.log" :: Output log fileFeel free to edit these to match your desired frequency or log location.
- The default
TIMEOUTis set to60seconds to avoid overloading the system with too many checks. - The
START_DELAYis set to30seconds because in my experience, opening multiple MetaTrader terminals too quickly often caused some or all of my Expert Advisors (EAs) to disappear. I suspect this happens when the system is under heavy load and can't initialize all charts and EAs properly at once — potentially resulting in data loss. A delay ensures the terminals have enough time to start cleanly before continuing the loop.
Define each MetaTrader terminal you want to monitor. You can include:
- Only the
.exepath - Or the
.exepath plus a.lnkshortcut, separated by a semicolon. Useful if you use shortcuts with custom icons.
Example:
# MT4 basic
C:\Program Files (x86)\Metatrader 4\terminal.exe
# MT4 with shortcut
C:\Program Files (x86)\Metatrader 4\terminal.exe;C:\Users\ibitebyt3s\Desktop\MT4Shortcut.lnk
# MT5 basic
C:\Program Files\MetaTrader 5\terminal64.exe
# MT5 with shortcut
C:\Program Files\MetaTrader 5\terminal64.exe;C:\Users\ibitebyt3s\Desktop\MT5Shortcut.lnkLines starting with # are ignored.
You can start the script by double-clicking it, or by running it from Command Prompt:
cd C:\Users\ibitebyt3s\Documents\metaMonitor
metaMonitor.batIt will:
- Check if each terminal is running
- Start it if it's missing (via
.lnkif provided) - Append the result to
metaMonitor.log - Loop every
TIMEOUTseconds
Leave the console window open to let it continue monitoring in the background.
To make metaMonitor.bat launch automatically when you log into Windows:
- Right-click
metaMonitor.bat - Choose Create shortcut
- Rename the shortcut to something like
Start metaMonitor
Press Win + R, type shell:startup, and hit Enter.
This opens your personal startup folder:
C:\Users\ibitebyt3s\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup
Move your Start metaMonitor shortcut into that folder.
✅ Now metaMonitor.bat will run automatically each time you log in.
📝 All logs will be saved in:
C:\Users\ibitebyt3s\Documents\metaMonitor\metaMonitor.log
-----------------------------------
-------- metaMonitor v1.0 --------
-----------------------------------
2025-05-30 13:45:23 - ONLINE: C:\Program Files\MetaTrader 5\terminal64.exe
2025-05-30 13:45:23 - START: C:\Users\ibitebyt3s\Desktop\MT4Shortcut.lnk
Built with care by @ibitebyt3s Helping traders keep their MetaTrader terminals up and running — always.