Metatrader configuration gone when Metatrader auto-start when VPS restart? - page 2

 
Shalem Loritsch #:

That is weird.  I am not aware of Explorer launching startup programs with any environmental conditions that would be different than those it uses when the user manually clicks an icon to open a program.  While I doubt this is the issue (based on its behavior differing from autologon versus manual launch both via the batch file), the exact syntax of the start command with the "/d" flag and separating the application's directory from "terminal.exe" was very important to ensure that the current ("start in") directory was correct; the start command should have read:

Feel free to test the above, but failing that, let's remove the Startup folder batch file and try to launch MetaTrader via the Task Scheduler—an entirely different method/infrastructure than Explorer's Startup folder.  Right-click your Windows Start button, click Computer Management -> Task Scheduler -> Task Scheduler Library -> Action (menu) -> Create Task...
Name the task "Autostart MT4 PU Prime".  The default user settings should be correct (your user account, run only when the user is logged on).  Configure for Windows 10.
For Triggers, select At log on -> Specific user -> (defaults should be correct, your user account).  Delay task for 1 minute.
For Actions, create a new one, browse to "C:\Program Files (x86)\PU Prime MT4 Terminal", and select terminal.exe.
For Conditions, make sure they're all unticked.
For Settings, untick Stop the task if it runs longer than.
Click [OK].  If you have a logon password, it will probably ask for it here; if so, enter it to finish creating the scheduled task.  Then, make sure that MetaTrader is closed, right-click your new task, and click Run.
It should appear on the screen and load your settings as expected.  Assuming it does, restart your PC and see if it autostarts correctly.

If it starts correctly when manually running the scheduled task, but doesn't autostart correctly upon reboot, here's another thing we could try: Go back to the "Autostart MT4 PU Prime" task you created in Computer Management, go to the Triggers tab, and remove the At log on trigger (so there are no triggers).  Now, make sure MetaTrader is closed, open a command window, and execute this command:

Does it load correctly this way?  If so, create a batch file in your Startup folder (like you did before), but with this code:

If after all this, manual launches (right-click -> run task, or manually executing the task run command) work, but none of the automated methods work, my conclusion would be that there is something unusual going on environmentally with your system, possibly even related to user input or antivirus software.  This could be very difficult to debug; but note that I am a very in-depth developer/debugger—it would be a matter of how much we want to go back and forth to figure out a solution!

Do be aware that changing your login password could break the task and your autologon feature; both would have to be manually reconfigured with the new password.  Feel free to disable or delete the "Autostart MT4 PU Prime" task you created if it's no longer needed.

Thank you so much Shalem -- I'm hopeful that we can find the problem and solution to this with your experience.

Also, if it make things easier/faster/simpler, I'm open to setting up a zoom call so we can troubleshoot together.

Here are the results so far:

1. Updated the start command to your suggestion. The result is the same, MT4 load correctly when launch manually, but it doesn't load correctly when launch from startup

start /d "C:\Program Files (x86)\PU Prime MT4 Terminal" terminal.exe

2. Setup task scheduler with "at logon" trigger.
Task run normally when launch manually (right click > run), MT4 launch correctly. When restart the VPS, task launch but same thing MT4 launch with empty profile.

3. Remove "at logon" trigger and add schtasks line in the startup batch file
Task run normally when launch the batch file manually. When restart the VPS, startup batch launch but MT4 launch with empty profile.

It seems like when launching via auto login, always resulting in empty profile even though it triggers the startup sequence correctly.

Would you perhaps need to see log file? or error messages in Windows, etc?

Also, login password was never changed during this entire troubleshoot exercise.

Thank you

 

Wow—that is very strange, but it has become quite predictable thus far!  I know that the Task Scheduler method of launching a process is dependable (as far as credentials/permissions/privileges) and is quite disconnected from the invoker (e.g. a non-privileged process can ask an administrative or even SYSTEM task to start, and then Task Scheduler launches the task's process with the task's saved credentials irregardless of who requested the start and their credentials/permissions/privileges; this is how some programs regularly bypass the UAC elevation prompt).  So there can't be anything directly tied to Explorer and the Startup folder affecting the launch—yet there remains this issue.  I'm not sure that there are any log files or error messages that would be helpful at this point; debugging why this is happening would probably involve tracing the launch with something like Process Monitor to find out what's going wrong and exactly what is different between the working and non-working scenarios, but there will be thousands of file and registry access events to sift through in order to gain some insight into the issue.

Before we go that far, @Mark David Harvey Brewster said something earlier that gave me an idea of something else to try with the Task Scheduler.  Go back to the scheduled task you created, go to the Triggers tab, and create a new trigger.  By default, it should create a specific date/time trigger for the present time.  Kick it forwards several minutes, click [OK] to add the new trigger, click [OK] to save changes, and immediately restart your computer.  Wait for the time you specified to arrive.  MetaTrader should start.  Does it load correctly?  If so, I'll look into writing a startup script that will create a future-dated task for a couple minutes in the future, and we'll see if that works.

 
Shalem Loritsch #:

Wow—that is very strange, but it has become quite predictable thus far!  I know that the Task Scheduler method of launching a process is dependable (as far as credentials/permissions/privileges) and is quite disconnected from the invoker (e.g. a non-privileged process can ask an administrative or even SYSTEM task to start, and then Task Scheduler launches the task's process with the task's saved credentials irregardless of who requested the start and their credentials/permissions/privileges; this is how some programs regularly bypass the UAC elevation prompt).  So there can't be anything directly tied to Explorer and the Startup folder affecting the launch—yet there remains this issue.  I'm not sure that there are any log files or error messages that would be helpful at this point; debugging why this is happening would probably involve tracing the launch with something like Process Monitor to find out what's going wrong and exactly what is different between the working and non-working scenarios, but there will be thousands of file and registry access events to sift through in order to gain some insight into the issue.

Before we go that far, @Mark David Harvey Brewster said something earlier that gave me an idea of something else to try with the Task Scheduler.  Go back to the scheduled task you created, go to the Triggers tab, and create a new trigger.  By default, it should create a specific date/time trigger for the present time.  Kick it forwards several minutes, click [OK] to add the new trigger, click [OK] to save changes, and immediately restart your computer.  Wait for the time you specified to arrive.  MetaTrader should start.  Does it load correctly?  If so, I'll look into writing a startup script that will create a future-dated task for a couple minutes in the future, and we'll see if that works.

Yeah, seems like it's become preditable now -- which is also the latest result with trying the trigger the task using specific time.

If I stay logged on in the VPS, task scheduler trigger at speicfic time and launch MT4 correctly.

If I restart, auto logon enabled, and then wait to connect to the VPS until after the time trigger passed -> MT4 launched but with empty profile.

For what it's worth: I have another VPS, let's call it VPS 1 (Intel cores hardware, Windows server 2022 datacenter edition) and VPS 2 (AMD cores, Wiindows server 2022 datacenter edition). VPS 2 is the one having this issue. VPS 1 works great even with simple startup configuration.

In VPS 1, I only configure auto-logon to work, auto logon to default Administrator profile (that's why I think it's not issue with default Administrator profile) and use a batch file in startup folder. MT4 apps and MT5 apps load correctly and load the configurations correctly too.

Wondering, could this issue has anything to do with Intel vs AMD cores?

 
No, Intel vs AMD shouldn't have anything to do with it.  This is sounding more and more like it's not a startup-launch issue with MetaTrader, but again, an issue with a roaming user profile, where the roaming data isn't being loaded from the network unless you're physically logged into the machine.  I know this function exists but am not so familiar it and all its nuances, so there's not much more I can suggest without being hands-on.  I would suggest looking into information about roaming user profiles online, and then comparing these settings/policies between the two machines you're using, where one is working and the other is not.  I have a hunch that the working machine is keeping all user data on the local computer's internal storage (like a normal desktop PC) while the non-working machine is loading/unloading the roaming user data folder on the network (like a networked domain PC), and for some reason, it's not loading it correctly until you physically log in—despite your auto logon setting (for example, even though your profile is being "loaded" in the background at startup due to the auto-login, perhaps it's not downloading the roaming user data until your user session is connected to an actual screen/RDP session).  This leaves MetaTrader without any of its profile data when any of our auto-start methods try to start it.  Of course, when you manually connect and click on the MetaTrader icon, the user data is then loaded and it starts correctly.  Due to my lack of familiarity with this feature, I can't suggest some command to force the roaming data to load; I thought it loaded automatically at user logon, even if in the background (i.e. not connected to a physical screen or RDP session), but based on your experience above with the different methods we've tried, I have reason to believe that it is not happening this way.  The folder in question would be C:\Users\Admin\AppData\Roaming, with MetaTrader specifically needing the contents of the MetaQuotes folder to be present at startup in order to load correctly.  In your situation, disabling user profile roaming and having a local user account would be ideal.  This may be a conversation to have with your VPS provider.
 
Shalem Loritsch #:
No, Intel vs AMD shouldn't have anything to do with it.  This is sounding more and more like it's not a startup-launch issue with MetaTrader, but again, an issue with a roaming user profile, where the roaming data isn't being loaded from the network unless you're physically logged into the machine.  I know this function exists but am not so familiar it and all its nuances, so there's not much more I can suggest without being hands-on.  I would suggest looking into information about roaming user profiles online, and then comparing these settings/policies between the two machines you're using, where one is working and the other is not.  I have a hunch that the working machine is keeping all user data on the local computer's internal storage (like a normal desktop PC) while the non-working machine is loading/unloading the roaming user data folder on the network (like a networked domain PC), and for some reason, it's not loading it correctly until you physically log in—despite your auto logon setting (for example, even though your profile is being "loaded" in the background at startup due to the auto-login, perhaps it's not downloading the roaming user data until your user session is connected to an actual screen/RDP session).  This leaves MetaTrader without any of its profile data when any of our auto-start methods try to start it.  Of course, when you manually connect and click on the MetaTrader icon, the user data is then loaded and it starts correctly.  Due to my lack of familiarity with this feature, I can't suggest some command to force the roaming data to load; I thought it loaded automatically at user logon, even if in the background (i.e. not connected to a physical screen or RDP session), but based on your experience above with the different methods we've tried, I have reason to believe that it is not happening this way.  The folder in question would be C:\Users\Admin\AppData\Roaming, with MetaTrader specifically needing the contents of the MetaQuotes folder to be present at startup in order to load correctly.  In your situation, disabling user profile roaming and having a local user account would be ideal.  This may be a conversation to have with your VPS provider.

Thank you -- I was able to contact the VPS support and ask about the drive physical location, they assured me that the C drive (where roaming data resides) is physically attached to the VPS machine, so it's not loaded from Network.

The, their support said that they can only support hardware/network related issue, not specific application or software/OS configuration.

This is getting confusing, and I don't have clue who to contact for further support? Should I pursue the VPS support, or Microsoft Support or Metaquotes?

If you can advise the next step or which side of this issue is, I can try to contact them further -- thanks in advance

 
Hi guys,

Same issue for me. I do observe

1) when MT5 opens from AutoStart, File --> Open data folder does open C:\Program Files\MyBroker_MT5-01\
2) when MT5 opens by manually launching it, Data folder is in %appdata%\MetaQuotes\Terminal\abc...yyz\

So I just put my .set, .tpl, Indicators and EA in the first location.
If ever I need to close and re-open MT5, I just reboot the VPS.

Hope this can help
 
If this can help.
My server VPS is a Win2012 R2
I just created a new user who is a member of the Adimistrators group.

1) AutoLogon set to use this new user

2) AutoStart is set to start my MT5 like this:
TIMEOUT 10
start /D "C:\Program Files\Fusion_MT5-01\" /MIN terminal64.exe
TIMEOUT 60
exit

Same situation
AutoStart.cmd open MT5 with C:\Program Files\Fusion_MT5-01 as "Data folder"
Manual open of MT5 it always use %AppData% \MetaQuotes\Terminal\abc...yyz\ as "Data folder"

I tried 2 manual open of MT5
- Using Desktop MT5 icon
- Using AutoStart.cmd
Both open MT5 with   %AppData% \MetaQuotes\Terminal\abc...yyz\ as "Data folder"
Reason: