Loading…

Task Scheduler Command Generator

Restarting the terminal on a schedule (before the week opens, after a routine reboot window, after a nightly maintenance script) is normally a Task Scheduler chore done by hand: open the GUI, click through six tabs, type the executable path from memory, and hope nothing was mistyped. The one detail that most often goes wrong doing it by hand is the executable path itself - the terminal's install folder is not the same folder shown by File > Open Data Folder, and typing the wrong one produces a task that silently does nothing. This script reads the terminal's own install path with TerminalInfoString (TERMINAL_PATH) - the exact folder this running instance was launched from - and uses it to build two ready-to-use outputs: a one-line "schtasks /create" command for pasting into an elevated Command Prompt, and a minimal but valid Task Scheduler 1.2 XML file for people who prefer Task Scheduler's own "Import Task..." menu item. Both encode the same daily trigger, the same executable path, and the same optional /portable flag and extra arguments, so whichever route is used ends up scheduling the identical task. This is a text generator only. MQL4 cannot call schtasks.exe or the Task Scheduler API itself without a DLL import, which this catalogue's house style forbids outright - so applying either output is a deliberate manual step, not something this script does automatically. Notes and limitations Nothing is scheduled by running this script - it only writes two text files. Creating the actual scheduled task requires the manual step described in How To Use, in an elevated Command Prompt or via Task Scheduler's own Import Task dialog. The generated XML is deliberately minimal: one calendar trigger, one exec action, and the settings needed for a daily restart to behave sensibly. It does not attempt to reproduce every optional element the Task Scheduler GUI itself would add when creating a task by hand. Running the terminal with a scheduled task does not itself unlock the sandbox, undo AutoTrading being off, or address any of the checks this catalogue's DeploymentChecklistRunner.mq4 (S447) covers - a scheduled restart brings the terminal back up, not necessarily back into a ready-to-trade state.

Script · MT4 · v1.0 · Free

About Task Scheduler Command Generator

Task Scheduler Command Generator is a script for MetaTrader 4. It can alert you with a pop-up, sound, email or push message. It has 6 settings, such as Task name, Start time hhmm and Use portable flag. MQL source code included.

Files in the download: TaskSchedulerCommandGenerator.mq4, TaskSchedulerCommandGenerator.txt.

Settings

SettingDefaultWhat it does
Task nameRestartMT4TerminalTask name shown in Task Scheduler
Start time hhmm07:55Daily start time, 24h HH:MM
Use portable flagfalseAdd /portable to the launch command
Extra argumentsExtra command-line arguments (e.g. a specific /config: file)
Run only if logged ontrueRun only when the user is logged on (unticked = run whether logged on or not)
Output base nameTaskSchedulerCommandBase filename for the two files written to MQL4\Files

How to install

  1. Download the ZIP from your PolyMaria library and unzip it.
  2. In MetaTrader 4 open File → Open Data Folder, then go to MQL4 → Scripts.
  3. Copy the .mq4 file(s) there. Put any .mqh files in MQL4 → Include.
  4. Open the .mq4 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
  5. Drag the script onto a chart to run it once.

Download the PDF guide

Tags: Alerts · MT4 Script · MQL4 Source Code

MQL4 & MQL5 scripts · PolyMaria