After installation is complete, a group of Client Terminal programs will be created in the "Start" menu, and the program shortcut will additionally appear on the desktop. They will help to start the client terminal.
Attention: Two copies of the Client Terminal are prohibited to start from the same directory simultaneously. To start several terminals simultaneously, it is necessary to install the corresponding amount of programs in different directories.
Starting from build 600, the client terminal features the new structure and location of the client terminal files. Now, MQL4 applications are placed in separate directories according to the program type (Expert Advisors, indicators, or scripts). In most cases, the terminal data is now stored in a special data folder separated from the terminal installation location. In this article, we will describe in detail how data is transferred, as well as the reasons for introducing the new storage system.
Why Has the New Data Storage System Been Implemented?
Microsoft Windows XP released 13 years ago allows applications to write their own data at the place of their installation even if the latter took place in the Program Files system folder. A user should only have an administrator's permission to write data to any folder.
When working in 64-bit systems, separate installation directories are provided for 32 and 64-bit programs: Program Files and Program Files (x86). Operation features described in the article apply to both directories.
Starting from Windows Vista, Microsoft has introduced a restriction on writing to the Program Files directory. If User Account Control (UAC) system is enabled, programs are not allowed to store their data in the Program Files folder. All data should be located in a separate user directory. This limitation was introduced in order to protect users against malicious programs and to prevent applications under one user account to change or damage the same program's data necessary for another user account. Since that time, security requirements in Microsoft operating systems have been tightening further. In particular, starting with Windows 8, the UAC system cannot be disabled even if the "Never notify" option is selected in its settings.
Microsoft has implemented a virtualization process in order to provide compatibility with older applications when using UAC. If a program tries to save its data to Program Files directory, the data is actually (physically) saved to a separate folder having the following look - C:\Users\<user-name>\AppData\Local\VirtualStore\Program Files, while Windows File Explorer shows the files as if they are saved in the installation directory. Microsoft claims that this mode has been provided only for compatibility and can be removed later.
In order to comply with Microsoft's recommendations, the data storage structure has been changed in the client terminal starting from build 600. Now, the terminal will also save its data in a user directory.
User Data Directory
In the new version, all data of a certain user working with a certain copy of the terminal are stored in a special place called the terminal data folder. This folder can be found on a system disk (a disk with an installed Windows operating system) along the following path:
- С: — name of a system disk;
- User_account_name — user's account for working in Windows;
- Instance_id — unique name of the folder where all the user's data for working with a certain copy of the terminal is stored. A unique name consists of 16 characters. The name is generated based on the path to the terminal installation directory since the path to the terminal installation directory cannot be explicitly used as a folder name. The significant length of the unique name is explained by the fact that multiple copies of the terminal can be installed on a single PC.
The "Open Data Folder" command in the File menu of the terminal allows searching and opening the data folder.
The root of each terminal data folder also contains the origin.txt file where you can find the path to the installation folder of the terminal this data refers to. This allows users to match each terminal data folder with a certain terminal installation directory, for example, in the case when several copies of the terminal are installed by a user. This type of working with the terminal when the data folder is separated from the installation one is the main mode.
For more convenience, an entry containing the path to the data folder is made in the terminal's journal each time the terminal is launched. For example:
2014.02.10 12:48:28.477 Data Folder: C:\Users\JohnSmith\AppData\Roaming\MetaQuotes\Terminal\9F86138A4E27C7218E9EC98A5F8D8CA1
Copying MQL4 Application Files When Updating to Terminal Build 600 and Higher
When the newly updated terminal is launched, it checks if the data folder is present. If the data folder is not yet present, then it is created. If that folder is different from the installation one, the terminal's regular data (standard MQL4 programs, historical data, configuration files, templates, etc.) is copied into it. The files that are not changed during the terminal operation (executable files, mql.dll compiler, sound files, etc.) are left in the installation directory. The terminal data folder is different from the installation one in the following cases:
- UAC system is enabled. The exception is when the terminal is installed on a portable device (external hard drive, USB flash drive, etc.).
- Current PC user has limited rights to write data to the installation directory.
- A user is working via remote connection (RDP).
If none of the above conditions are satisfied, the terminal data is stored in the installation directory.
Then, the user files are moved to the data folder. At this stage, the directory where the terminal's user data has been stored is determined. If the data has been stored in the terminal installation folder, they are copied the following way:
Next, it is checked whether the client terminal has stored data in the virtualization directory (the operating system's virtual storage described above). If the terminal has been installed in the Program Files directory and the operating system is Windows Vista or higher, the terminal data is most probably stored in that directory. If the data is found, it is copied according to the above table.
The files are copied and not moved during the migration. The copied files are not deleted from the source folders.
During the migration, the entries containing source and destination paths of the copied files are made in the terminal's journal. To view all the logs, open the Journal tab of the Terminal window and execute the Open command in the context menu. The folder containing the terminal log files will open.
If the migration is completed successfully for the current terminal copy, it is not repeated anymore during subsequent terminal updates. If the data folder is different from the installation one, and custom MQL4 applications have been copied together with the standard files during the migration, the following dialog window appears:
Portable launch mode is provided for the terminal operation on portable devices and non-system directories, as well as for working in Windows XP. When launched in this mode, the terminal tries to save its data in the installation folder. However, using Portable mode does not guarantee that an operating system will allow storing data in the installation folder (for example, if the terminal is installed in the Program Files directory and the UAC system is enabled).
The following conditions should be met for working in Portable mode:
In order to launch the terminal in Portable mode, use the "/portable" key. For more convenience, you can create an additional terminal launch shortcut with the appropriate name on your desktop and add the key directly to the shortcut: