NVIDIA GTX 1080 ti GPUs

Here is a quick PowerShell (3) script to keep your EBWF miner running in the case that it fails and exits while you’re away.

It’s pretty simply, the script checks for the process and if the process isn’t running it attempts to restart it every 5 minutes. You can change that value (Sleep 300) at the end to less or more.

You’ll need to change the batpath, error path (or comment that out) and email information. This uses Gmail’s smtp and you will need to setup an application-specific password to make that part work. You could always leave out the email.

Also, if the app exits due to lost internet connection the email won’t send until it comes back online (obvious but worth mentioning).

I’ll be improving this over time, maybe adding desktop screenshots of the command prompt window? We’ll see.

In order to run this, save to a mine.ps1 file and throw it into the base EWBF directory, then run powershell as an administrator and cd into that directory. Then: .\mine.ps1

Last, in order to run this you might need to set Set-ExecutionPolicy Unrestricted if you’re using this on more than one machine and transfer the .ps1 via usb. Kinda a hassle with PowerShell, but I figure it’s cross-platform so someone on linux/mac might be able to us this as well.

# make sure to use these flags in the bat file: --eexit 3 --log 1 --logfile error.txt
while($true) {
  $batpath = "C:\Users\username\path\to\batfile.bat"
  # get mining process
  $mining = Get-Process miner -ErrorAction SilentlyContinue
  # check to see if the process exists
  if (!$mining) {
    # start the process
    Start-Process $batpath
    # give it time to startup
    Sleep 5
    $didrestart = Get-Process miner -ErrorAction SilentlyContinue
    if ($didrestart) {
      $message = "ZecBot - Restarted miner."
    } else {
      $message = "ZecBot - Unable to restart miner."
    }
    Write-Host $message
    # email
    $pwd = ConvertTo-SecureString 'yourGmailAppPassword' -AsPlainText -Force
    $cred = New-Object System.Management.Automation.PSCredential yourmail@gmail.com,$pwd
    $body = Get-Content -Path C:\Users\username\path\to\error.txt -Raw
    $param = @{
      SmtpServer = 'smtp.gmail.com'
      Port = 587
      UseSsl = $true
      Credential  = $cred
      From = 'yourmail@gmail.com'
      To = 'yourOtherMail@gmail.com'
      Subject = $message
      Body = $body
    }
    Send-MailMessage @param
  } else {
    Write-Host "mining"
  }
  # wait 5 mins, change this as desired
  Sleep 300
}

Please comment for additions/improvements/etc. I might throw this into a repo if someone finds it useful.

12 Likes