Skip to content

Instantly share code, notes, and snippets.

@dmsysop
Last active November 29, 2023 12:07
Show Gist options
  • Save dmsysop/4c6484d27dede0c756ca5e472c184162 to your computer and use it in GitHub Desktop.
Save dmsysop/4c6484d27dede0c756ca5e472c184162 to your computer and use it in GitHub Desktop.
Monitoramento ativo do ManagerEdoc
powershell -ExecutationPolicy Bypass -File C:\Users\nfe\Desktop\MonitorManagerEdoc.ps1 -WindowStyle Hidden
#Path do exe
$path = "C:\homo\Manager eDoc\"
$executable = "ManagerEdoc.exe"
$processName = "ManagerEdoc"
$date = Get-Date
$formattedDate = $date.ToString("dd/MM/yyyy HH:mm:ss")
$logPath = "C:\Users\nfe\Desktop\MonitorManagerEdoc.log"
$textLog = "$processName não encontrado ou não executando em $formattedDate. Reinicializando o software!!"
$fullPath = Join-Path $path $executables
$process = Get-Process -name $processName -ErrorAction SilentlyContinue
if(-not $process) {
Add-Content -Path $logPath -Value $texLog
Set-Location $path
Start-Process -FilePath $executable -WindowStyle Hidden
#Grava log com o registro de quando a aplicação estava fora do ar!
Add-Content -Path $logPath -Value $textLog
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment