WatchDirectory Forum
http://www.watchdirectory.net/cgi-bin/yabb25/YaBB.pl
watchDirectory forums >> Plugins >> Trying to kill a running task using watchDirectory
http://www.watchdirectory.net/cgi-bin/yabb25/YaBB.pl?num=1352680449

Message started by wesman on Nov 12th, 2012 at 1:34am

Title: Trying to kill a running task using watchDirectory
Post by wesman on Nov 12th, 2012 at 1:34am
Hi Gert

I have been trying to set up a task that runs a bat file on a file event.

The batch file is very simple - it kills a running Windows process - and it runs fine when I click on it in Windows. However, when watchDirectory runs it, nothing happens (ie the processed is not killed)

In the WD task, I have tried unchecking "Hide the run window" on the How to Run page, but still nothing happens. The History for the task shows that WD detects the file event and it says that WD has run the task, but the process is not killed.

The bat script I am trying to run is as follows:

@echo off
taskkill /im "wlmail.exe"
exit

Please can you tell me what I am doing wrong and how to get this to work?


Thanks

Wes Swindale

Title: Re: Trying to kill a running task using watchDirec
Post by Gert on Nov 12th, 2012 at 6:36am
Hello Wes,

Make sure to enable the option "capture bat file output" (or similar wording). Edit your bat file and remove the "echo off".
Now run the task. After it has failed to kill your process, select the menu "Explore Task Directory" (Win Explorer opens), navigate to the sub-directory with the name of your task. There you will find one or more files with names like output999999_99999.log. The most recent of those has the output (error messages?) of your bat file.

Title: Re: Trying to kill a running task using watchDirec
Post by wesman on Nov 12th, 2012 at 6:48am
Hi Gert

I have checked and inside this particular subfolder there are no currently updated output log files. The most recently updated on in there is from 8 hours ago. I have stopped and restarted the WD task but it doesn't make any difference.

What else can I try?


Thanks


Wes

Title: Re: Trying to kill a running task using watchDirec
Post by Gert on Nov 12th, 2012 at 6:55am
If there is no new log, WD didnt detect a file (and thus didnt start your bat) OR your bat file "hangs" somewhere.

Title: Re: Trying to kill a running task using watchDirec
Post by Gert on Nov 12th, 2012 at 6:56am
Try to start the task as a normal program (NOT as a Windows Service) so you will see the script output

Title: Re: Trying to kill a running task using watchDirec
Post by wesman on Nov 12th, 2012 at 6:58am
Ok thanks Gert - I will do that now. I should be able to work it out from here.

Thanks


Wes

WatchDirectory Forum » Powered by YaBB 2.5.2!
YaBB Forum Software © 2000-2017. All Rights Reserved.