Last active
November 29, 2023 12:07
-
-
Save dmsysop/4c6484d27dede0c756ca5e472c184162 to your computer and use it in GitHub Desktop.
Monitoramento ativo do ManagerEdoc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
powershell -ExecutationPolicy Bypass -File C:\Users\nfe\Desktop\MonitorManagerEdoc.ps1 -WindowStyle Hidden |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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