Mining while gaming and switching between multiple GPU mining with Powershell
TL;DR
Script that helps me monitor and switch between mining with 4 cards vs 5 and back depending on if I'm gaming or not automatically.
Hey Steemians,
So the title maybe isn't to clear on whats up but I will be trying to explain it here. If you have been following me you know that one of my mining rigs is also my main gaming rig which I'm running 5 graphics card of in total and there's always at least 4 mining at the same time.
- 4 cards mining when gaming
- 5 cards mining when not gaming
Current cards in my gaming rig:
- Asus 1060 3gb
- Asus 1060 3gb
- Asus 1070 8 gb
- Gigabyte 1060 3gb
- Msi 1070 8gb
In the .bat file you use to start of your miner with you can usually define which graphic cards you want to mine with and with that I have been having 2 .bat files where one file starts the miner with all 5 graphics card mining and one with only 4. This is so I can mine while gaming.
The problem I ran in to was to remember to switch back to the 5 card mining when done gaming or even start the mining at all and it happen to me many times where it's been hours or even days where i forgot to mine with all 5 cards and just been mining with 4 even tho haven't been doing any gaming and thus loosing out on those precious coins. (facepalm)
So to solve this issue without doing physical surgery on my self to correct my failing memory I created a powershell script that checks if any predefined process is running (games in this instance like Dota2 but could be any process like notepad, spotify or what ever) and if a process is running it checks to see that I'm running the correct config with only 4 cards mining and if any of those processes are't running it makes sure that the config with 5 cards is running. To make this reoccurring i created a schedule task in windows to kick of this script every 5 minutes to check that the correct configuration is running.
Example
Here's an video where I go in to more details on how I solved this with the help of powershell and task scheduler.
The script
<#
.SYNOPSIS
Powershell script that checks if a process is running and runs the correct mining config you specified
.DESCRIPTION
.EXAMPLE
Populate the Games.txt file with the process names of the games or other applications you want to run
a different configuration for. Change the variables to your preference.
You also need 2 .exe files for the miner since we need to be able to distinguish between the miner when mining with all cards and when not.
In my example i have one .exe called ccminer.exe and one ccminerGame.exe
From the .bat files you configure which cards you want to mine with and point that .bat file to the correct .exe
for example
Digibyte-Suprnova - Gaming mode.bat contains the following config that only mines with 4 of 5 cards:
ccminerGame.exe --algo=myr-gr -o stratum+tcp://dgbg.suprnova.cc:7978 -u USERNAME -p PASSWORD -d 1,2,3,4
Digibyte-Suprnova.bat contains the following config config mines with 5 of 5 cards
ccminer.exe --algo=myr-gr -o stratum+tcp://dgbg.suprnova.cc:7978 -u USERNAME -p PASSWORD
$ccminerPath Path to your mining folder
$ccminerGame Path to your .bat file that only run the cards you want to mine with while gaming
$ccminerAllcards Path to your .bat file that runs all the cards you want to mine with
$GameProcesses Gets content from your Game.txt file containing the processes you want to include
.NOTES
Author: Timmy
Steemit: @timmyit
Twitter: @Timmyitdotcom
Blog: www.timmyit.com
Created: 2017-06-10
#>
# Variables
$AllProc = (Get-Process)
$MinerNameAll = "ccminer"
$MinerNameGame = "ccminerGame"
$ccminerPath = "C:\Miners\ccminer-1-8-3-git-tpruvot\ccminer 64-bit"
$ccminerGame = ($ccminerPath + "\" + "Digibyte-Suprnova - Gaming mode.bat")
$ccminerAllcards = ($ccminerPath + "\" + "Digibyte-Suprnova.bat")
$GameProcesses = (Get-content -Path ($ccminerPath + "\" + "Games.txt"))
$GameProc = $null
$MiningProc = (($Allproc | where-Object {$_.ProcessName -like $MinerNameAll -or $_.ProcessName -like $MinerNameGame}))
Foreach ($GameProces in $GameProcesses)
{
$GameProc += (($Allproc | where-Object {$_.ProcessName -eq $GameProces}).ProcessName)
}
if ($GameProc -eq $null -and $MiningProc.ProcessName -ne $MinerNameAll)
{
Stop-Process -Name $MinerNameGame -force -ErrorAction SilentlyContinue
Set-Location -Path $ccminerPath
Start-Process $ccminerAllcards
break
}
Else
{
if ($AllProc.ProcessName -eq $MinerNameAll)
{
If ($GameProc -ne $null)
{
Stop-Process -Name $MinerNameAll -force -ErrorAction SilentlyContinue
Set-Location -Path $ccminerPath
Start-Process $ccminerGame
break
}
Else
{
}
}
elseif ($AllProc.ProcessName -like $MinerNameGame)
{
If ($GameProc -eq $null)
{
Stop-Process -Name $MinerNameGame -force -ErrorAction SilentlyContinue
Set-Location -Path $ccminerPath
Start-Process $ccminerAllcards
break
}
Else
{
}
}
elseif (-not $AllProc.ProcessName -like $MinerNameGame -or -not $AllProc.ProcessName -like $MinerNameAll)
{
If ($GameProc -eq $null)
{
Set-Location -Path $ccminerPath
Start-Process $ccminerAllcards
break
}
Else
{
Set-Location -Path $ccminerPath
Start-Process $ccminerGame
break
}
}
}
if ($MiningProc -eq $null)
{
Set-Location -Path $ccminerPath
Start-Process $ccminerGame
break
}
Elseif ($MiningProc -like $MinerNameGame)
{
Stop-Process -Name $MinerNameGame -force -ErrorAction SilentlyContinue
Set-Location -Path $ccminerPath
Start-Process $ccminerAllcards
break
}
Thats all for now but if you would like me to do a more in depth guide on how to setup this from start to finish let me know in the comments below and feel free to ask questions.
Cheers, Timmy
Don't forget to follow me if you found this stuff interesting and you can also
find me over at:
Great script you wrote there. Especially not missing out on those extra coins can really be a difference if the coin in question is appreciating at that moment. I have a separate gaming laptop which overheats while mining so i do not use it except for gaming. Otherwise I would have applied the script as well!
Thanks @rymlen haha yes Digibyte has taken a big dive which I'm actually is more than happy with because that results in a lot of people stops mining it. Just curious what laptop are you gaming on?