stevehopwoodforex.com
https://www.stevehopwoodforex.com/phpBB3/
Print view

PowerShell script for automatical restart Empty4
https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?t=4944
Page 1 of 1
Author:  zentrader [ Tue Oct 11, 2016 6:55 pm ]
Post subject:  PowerShell script for automatical restart Empty4

Hi,

Have you ever experienced your Empty4(MT5) crashing down or freezing?
I think everybody has. It sucks. I know. When it happens your EA does not
have control over your orders anymore.

I have written small PowerShell script. This script automatically starts
your Empty4 an checks out if terminal.exe is running and is responsive in regular intervals.
If your Empty4 crashes down (not running) it will start it again and send you an email message.
If your Empty4 runs but is not responding (terminal freezes) it will kill it and start again with email notification.

Installation:

1. Log in your gmail account.
2. Go to https://www.google.com/settings/security/lesssecureapps
3. Allow access for less secure applications
4. Run PowerShell.exe as Administrator then execute these commands:

Code: Select all

Set-ExecutionPolicy Unrestricted
$cred = Get-Credential (input your gmail username and passwors)
$cred | Export-CliXml c:\scripts\cred.clixml
5. Put StartTerminal.ps1 into c:\scripts
6. Edit your input parameters:

Code: Select all

################################################### external input
$PathTerminal                  = 'e:\MT.DEMO\Empty4\FxPro.VTS\terminal.exe'
$WorkingDirectory              = 'e:\MT.DEMO\Empty4\FxPro.VTS'
$ArgumentList                  = '/portable'
$message                       = 'Terminal Nitro+ has started'
$CheckOutInterval              = 60 #seconds
$WaitForNonRespondingTerminal  = 60 #seconds
$params = @{ 
    From          = 'StartTerminal@gmail.com' 
    To            = 'john.smith@gmail.com' 
    SmtpServer    = 'smtp.gmail.com' 
    Port          = 587 
    Credential    = Import-CliXml c:\scripts\cred.clixml
    UseSsl        = $true
} 
################################################### external input
7. In Windows Explorer right click on StartTerminal.ps1 and click "Run with powerShell"

It is done!

You can automatically run it after computer start with "Task Scheduler" in Windows.

This is my first attempt to write PS script. Any recommendations how to improve script are welcomed.

I have also appended terminal.exe for simulating non responsive process. Just click on "Freeze me!" button.

Zentrader
Author:  tomele [ Tue Oct 11, 2016 7:39 pm ]
Post subject:  PowerShell script for automatical restart Empty4

Hi.

Sounds fantastic. Thanks a lot for sharing.

:!!:
All times are UTC Page 1 of 1