I have a shortcut with these properties:
Target: "D:\Metatrader3\MetaQuotes\MetaTrader5\terminal64.exe" /portable
Start in: "D:\Metatrader3\MetaQuotes\MetaTrader5"
at this location: "D:\Metatrader3\MetaQuotes\MetaTrader5\portable.lnk"
When I double-click the shotcut, it opens the terminal and takes me to the account that I was logged in when I last closed the terminal.
I want to run a powershell script that monitors the terminal and restarts it if it crashes. Here is the script:
Powershell opens the terminal, but the terminal has 'forgotten' what the last open account was. It takes me to the "Open account" screen instead of my charts.
I am struggling to figure out how does the double-click differ from invoking the shortcut programmaticaly. Does anyone know how the account information is invoked at terminal startup?
Make sure your PowerShell script is running under the same Windows User account as when you work with MetaTrader manually.
Otherwise, it will just invalidate the encrypted trading account details.
I am not starting the app from the terminal, I am invoking a shortcut .Ink file - passing arguments to a shortcut does not make sense. And the PS script is running under the same (the only) account on my PC. But I appreciate the brainstorming. :)
Achieved the desired outcome by setting up a python script:
import os def main(dir = 'Metatrader3'): shortcut = f'D:\\{dir}\\MetaQuotes\\MetaTrader5\\portable.lnk' os.startfile(shortcut) if __name__ == '__main__': try: import sys main(sys.argv[1]) except KeyboardInterrupt: pass
and starting that script via PS:
$processPath = "C:\Users\Viktoria\AppData\Local\Programs\Python\Python313\python.exe" if ($results.Count -eq 0) { $scriptPath = "D:\$($dir)\MetaQuotes\MetaTrader5\launch.py" $argList = "$($scriptPath) $($dir)" Start-Process $($processPath) -ArgumentList $($argList) -NoNewWindow:$false }
This works and does not forget the credentials.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I have a shortcut with these properties:
Target: "D:\Metatrader3\MetaQuotes\MetaTrader5\terminal64.exe" /portable
Start in: "D:\Metatrader3\MetaQuotes\MetaTrader5"
at this location: "D:\Metatrader3\MetaQuotes\MetaTrader5\portable.lnk"
When I double-click the shotcut, it opens the terminal and takes me to the account that I was logged in when I last closed the terminal.
I want to run a powershell script that monitors the terminal and restarts it if it crashes. Here is the script:
Powershell opens the terminal, but the terminal has 'forgotten' what the last open account was. It takes me to the "Open account" screen instead of my charts.
I am struggling to figure out how does the double-click differ from invoking the shortcut programmaticaly. Does anyone know how the account information is invoked at terminal startup?