I spent the better part of last Tuesday wrestling with a client's EA. It worked flawlessly on his home Windows 11 machine, but the moment we moved it to a Windows Server 2022 VPS for hosting, it threw a cryptic "DLL call failed" error. The event log was useless. The standard advice from forums? "Just check the DLL imports checkbox." We did that. Ten times.
The issue wasn't the checkbox. It was how Windows Server handles user-specific temporary folders and permission inheritance for 32-bit applications, which most MT4 builds still are. When the EA called a custom DLL for order management, the system tried to write a temporary log file to the
C:\Users\Administrator\AppData\Local\Temp folder. On his desktop, the user had full control. On the VPS, the "Administrator" account, despite being in the local admin group, didn't have explicit write permissions to that specific Temp folder due to a group policy applied by the hosting provider.I found the fix in an unexpected place: the Microsoft documentation on file system redirection for WOW64. Specifically, the note about
%USERPROFILE% expansion in a services context. The EA was running under the context of the terminal session, not a background service, but the registry key that controls this behavior is the same.Here is the exact process that got it running. It is the only method that worked consistently across three different VPS providers I tested.
terminal.exe processes. If you don't do this, Windows holds the registry and file handles open.Win + R, type regedit, and hit Enter. Navigate to HKEY_CURRENT_USER\Software\MetaQuotes\Terminal\Build. You will see a list of GUIDs for your terminals. Find the one for your live account.DataFolder path.</strong> This is the "sandbox" directory. If it points to a protected system folder (like C:\ProgramData), that's a red flag. I changed mine to a dedicated folder in the root, e.g., C:\MT4_Data\, and moved the EA and DLL files there. This bypasses Program Files' strict security policies.TMP and TEMP pointing to a folder you created, e.g., C:\MT4_Temp. Log out and log back into the VPS for this to take effect.CWDIllegalInDllSearch registry key to 0 allows the system to search the application directory for DLLs first, before system paths. For MT4, this is critical. Create a new DWORD (32-bit) value named CWDIllegalInDllSearch under HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager. Set its value to 0. This forces Windows to look in the EA's folder first, bypassing the "known DLLs" list that was blocking our custom file.After rebooting, the EA loaded the DLL without complaint. The
print() statements inside the DLL started spitting debug info into the Experts log.Reference: Dynamic-Link Library Search Order, Microsoft Docs. Windows Server file system redirection policies.
本文首发于FXEAR.com,原创内容,未经授权禁止转载