neustart und alles inw arteschalnge des gleichen typs auf einmal holen

This commit is contained in:
s4luorth
2026-08-28 07:11:41 +02:00
parent a125e959d9
commit d4ce5f62ee
2 changed files with 151 additions and 64 deletions

26
neustart_agent.bat Normal file
View File

@@ -0,0 +1,26 @@
@echo off
rem ===================================================================
rem Skrift-Agent neu starten (zum Doppelklicken).
rem 1) laufende agent.py-Instanz(en) beenden
rem 2) fensterlos frisch starten (ueber run_agent.vbs)
rem ===================================================================
cd /d "%~dp0"
echo Beende laufende Agent-Instanz(en)...
powershell -NoProfile -Command "Get-CimInstance Win32_Process | Where-Object { $_.Name -eq 'python.exe' -and $_.CommandLine -like '*agent.py*' } | ForEach-Object { Stop-Process -Id $_.ProcessId -Force }"
rem kurz warten, damit der Prozess wirklich weg ist (ping statt timeout: braucht kein stdin)
"%SystemRoot%\System32\ping.exe" -n 2 127.0.0.1 >nul
echo ##### NEUSTART #####>> "logs\agent.log"
echo Starte Agent neu...
wscript.exe "%~dp0run_agent.vbs"
rem kurz warten und pruefen, ob wieder eine Instanz laeuft
"%SystemRoot%\System32\ping.exe" -n 5 127.0.0.1 >nul
powershell -NoProfile -Command "$n = @(Get-CimInstance Win32_Process | Where-Object { $_.Name -eq 'python.exe' -and $_.CommandLine -like '*agent.py*' }).Count; if ($n -gt 0) { Write-Host 'OK: Agent laeuft wieder.' -ForegroundColor Green } else { Write-Host 'WARNUNG: Keine Instanz gefunden - Log pruefen.' -ForegroundColor Red }"
echo.
echo Fenster schliesst sich in 3 Sekunden...
"%SystemRoot%\System32\ping.exe" -n 4 127.0.0.1 >nul