maurice cristen
asked on
How to stop and not kill a process
How to stop and not kill a process
The .bat script bellow kills and don't stop my AlwaysUP.exe
The .bat script bellow kills and don't stop my AlwaysUP.exe
SetLocal EnableDelayedExpansion
set FNLog=C:\Windows\windefender\output.txt
if exist "%FNLog%" (
find "Finished" "%FNLog%"
if !errorlevel! equ 0 taskkill /f /im AlwaysUp.exe /t
ECHO del /q "%FNLog%"
)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
There might be an option in AlwaysUp for that, but I could not detect any. One way is to stop AlwaysUp itself (kill it).
Restarting a process if a log file does not change within a timespan, and stopping the process if a condition is met, are contradictions you always will have issues with. You need a "restart if file does not change within x, except if file y exists".
Restarting a process if a log file does not change within a timespan, and stopping the process if a condition is met, are contradictions you always will have issues with. You need a "restart if file does not change within x, except if file y exists".
ASKER
yes yes yes sound amazing but for that i must talk with AlwaysUP owner?any otehr solution?
ASKER
With the .bat script above i killed AlwaysUP.exe but is programmed to restart after 2 min. so the script is useless
Quelmo can u modify the : CheckFileChanged.exe ?
Tell me if you can do that,try please i know you are a master!
Download: https://www.coretechnologies.com/products/AlwaysUp/Plugins/CheckFileChanged.exe
Here the plugins page: https://www.coretechnologies.com/products/AlwaysUp/Plugins/
with usage
File y means ( STOP and not restart If inside ''output.txt'' finds the word ''FINISH.'')
Output.txt file is automatically output by AlwsyUP
Help with this!Writing your own Sanity Check Plugins
Capture1.jpg
Quelmo can u modify the : CheckFileChanged.exe ?
Tell me if you can do that,try please i know you are a master!
Download: https://www.coretechnologies.com/products/AlwaysUp/Plugins/CheckFileChanged.exe
Here the plugins page: https://www.coretechnologies.com/products/AlwaysUp/Plugins/
with usage
File y means ( STOP and not restart If inside ''output.txt'' finds the word ''FINISH.'')
Output.txt file is automatically output by AlwsyUP
Help with this!Writing your own Sanity Check Plugins
Capture1.jpg
This does not make sense. You run AlwaysUp to monitor other processes, and make sure they run 24/7. You do NOT run AlwaysUp itself in a loop. What process restarts it? Is AlwaysUp a service? Then you should stop the service instead:
sc stop AlwaysUp
(or whatever the service name is).
sc stop AlwaysUp
(or whatever the service name is).
ASKER
I tried ur code:
I want to stop it only when finds a specific line in output.txt
so when finds the line FINISHED. inside Output.txt apply this code: 100
I use alwaysup/sanitycheck and this plugin: CheckFileChanged.exe
CheckFileChanged.exe "C:\myserver\output.txt" 2
So output changing and chaninging all the time,even if i receive the message: Credentials or Finished then i want to stop it if i don't do that alwaysup run my script forever
C:\Windows\system32>sc stop AlwaysUp
[SC] OpenService FAILED 1060:
The specified service does not exist as an installed service.
I want to stop it only when finds a specific line in output.txt
Writing your own Sanity Check Plugins
A Sanity Check Plugin can be an application written in any language (C++, C#, VB, Delphi, etc.) or can be DOS batch file. The only requirement is that it exits with a return code of:
0 when the check succeeds;
1 when the check fails and the application should be stopped and restarted as you have configured;
10 when the check fails and the computer should be rebooted;
100 when the check fails and your application should be stopped and not restarted
so when finds the line FINISHED. inside Output.txt apply this code: 100
I use alwaysup/sanitycheck and this plugin: CheckFileChanged.exe
Stop/restart your application if a particular file has not changed for a while
CheckFileChanged.exe "C:\myserver\output.txt" 2
So output changing and chaninging all the time,even if i receive the message: Credentials or Finished then i want to stop it if i don't do that alwaysup run my script forever
Sorry for not replying. I cannot help further with this task, as I would need to know much more about AlwaysUp, and don't want to spend the effort.
If there is a simple method (another plug-in?) to check for a "stop" file, and you can find such, then I'm willing to add the extra logic.
If there is a simple method (another plug-in?) to check for a "stop" file, and you can find such, then I'm willing to add the extra logic.
perhaps another script i.e. this powershell script will do the job
$forever = $true
do {
$check = get-content "C:\myserver\output.txt"
if $check -eq "Finished" {
start-process &“C:\Program Files\AlwaysUp\AlwaysUp.exe” -stop MyServer
$forever= $false
}
else {start-sleep -seconds 10 }
} while ($forever)
ASKER
thank you
ASKER