# keyfarm lane keeper: resurrect dead eternal lanes # schtasks: keyfarm-lane-keeper (every 20 min) $kh = "C:\Users\User\Desktop\keyhunter" $py = "C:\Users\User\AppData\Local\Programs\Python\Python311\python.exe" $keeperlog = "$kh\data\lane_keeper.log" $lanes = Get-ChildItem -Path $kh -Filter "*_eternal.py" | Select-Object -ExpandProperty Name $cmdlines = Get-CimInstance Win32_Process -Filter "Name='python.exe'" | ForEach-Object { $_.CommandLine } $started = @() $skipped = @() foreach ($lane in $lanes) { $alive = $cmdlines | Where-Object { $_ -match [regex]::Escape($lane) } if ($alive) { $skipped += $lane; continue } $p = Start-Process -FilePath $py -ArgumentList "`"$kh\$lane`"" ` -WorkingDirectory $kh -WindowStyle Hidden -PassThru ` -RedirectStandardOutput "NUL" -RedirectStandardError "$kh\data\lane_err_$lane.log" $p.PriorityClass = "BelowNormal" $started += $lane } $stamp = Get-Date -Format 'yyyy-MM-dd HH:mm:ss' Add-Content -Path $keeperlog -Value ("[{0}] lanes total={1} alive={2} started={3}" -f $stamp, $lanes.Count, $skipped.Count, ($started -join ',')) if ($started.Count -gt 0) { Add-Content -Path $keeperlog -Value ("[{0}] resurrected: {1}" -f $stamp, ($started -join ', ')) } exit 0