End a Windows service/process in Task Manager and start it back up
Posted on 2008-01-28
I have tried another script that supposedly works for this, but it's causing problems...in that it doesn't actually end or start the service back up. It was a generated script from a site, so I guess that's always room for flaws.
I want to kill a certain service from the Task Manager at a certain time (I guess this can be done via Scheduled Tasks instead of coding). After that process is killed at the said time, I want it to be started back up again after like 30 seconds or so. I do NOT want the service to be restarted as it still might cause problems. I want it to be completely killed off.
1. Is it possible to add a verification code so that the script makes sure it's terminated first before it waits 30 seconds and try starting it back up? The first generated script I tried didn't seem to have this error check.
2. I want everything to be logged into a separate notepad log file (when it was brought down, when it was back up and any other errors if any in between the process). Do this without any prompts from the script....I just want it to run at the scheduled time (I'll do it via Scheduled Tasks) and that's it. No clicking OK to say it was stopped and started.
VBS would be perfect/preferable for this or any other methods (programming wise even), feel free to let me know. Something that I can edit if need be. I'm not sure if the starting back the service (services.msc service that is) will require a second script to be put into Scheduled Tasks or not. If it can be done with one VBS script file and run the stop and start command (check to make sure it's stopped first before starting) that would be great.
PS: Sorry about the point value. Tried to give more but I'm left with only 275. I have around 90,000 but I guess EE limits inactive users (been away for a while).