WatchDirectory Forum
http://www.watchdirectory.net/cgi-bin/yabb25/YaBB.pl
watchDirectory forums >> Plugins >> "Start any Program" - service does not work
http://www.watchdirectory.net/cgi-bin/yabb25/YaBB.pl?num=1283778683

Message started by Dschuwi on Sep 6th, 2010 at 3:11pm

Title: "Start any Program" - service does not work
Post by Dschuwi on Sep 6th, 2010 at 3:11pm
Hi,

I am testing watchDirectory, version 4.6.2.

Most of the tasks I would need (copy/move/rename) work well when started as a service.

The plugins "Start any Program" or "Run a .bat file" donot work as service - they work fine when started manually (F5) though.

Is this a bug or am I missing something?

tnx

Title: Re: "Start any Program" - service does not work
Post by Gert on Sep 6th, 2010 at 3:14pm
Hi,

Not a bug, but an unfortunate way services work. See this blogpost how to troubleshoot/fix Services:
http://watchdirftp.blogspot.com/2010/04/watchdirectory-tasks-as-windows-service.html

Gert

Title: Re: "Start any Program" - service does not work
Post by Dschuwi on Sep 6th, 2010 at 4:28pm
I'm afraid this does not help -

I work on local drives only, I have the full path name to the program/bat file provided, no spaces contained, the service is running (I also tried to run this service as a user with admin privileges.).

I must be missing something :(

Title: Re: "Start any Program" - service does not work
Post by Gert on Sep 6th, 2010 at 4:34pm
What happens if you enter your OWN user/password for the service?

Title: Re: "Start any Program" - service does not work
Post by Dirk on Sep 6th, 2010 at 5:03pm
Hi Dschuwi,

please note that not all progams can run as services. This has nothing to do with WatchDirectory, you also will not be able to run the program with srvany.exe or other service-making helpers.
Please take start option "auto start folder" together with "keep task running at logoff".

Title: Re: "Start any Program" - service does not work
Post by Dschuwi on Sep 7th, 2010 at 12:18pm

Gert wrote on Sep 6th, 2010 at 4:34pm:
What happens if you enter your OWN user/password for the service?


I did try with my own account...
It looks just as if nothing would happen at all.

Title: Re: "Start any Program" - service does not work
Post by Dschuwi on Sep 7th, 2010 at 12:22pm

Dirk wrote on Sep 6th, 2010 at 5:03pm:
Hi Dschuwi,

please note that not all progams can run as services. This has nothing to do with WatchDirectory, you also will not be able to run the program with srvany.exe or other service-making helpers.
Please take start option "auto start folder" together with "keep task running at logoff".


Well that's why I tried to run a simple .bat file - it does not even open the command window.
Auto start folder is an option, certainly, but I want to dig into this problem.
Is there a way to find out if watchDirectory does detect the triggering event in the first place - so we could track down where in the processing chain we are stuck?

cheers
hp

Title: Re: "Start any Program" - service does not work
Post by Dirk on Sep 7th, 2010 at 12:26pm
Please check at the machine where wd is installed if the account you are using has the rights to log on as service like described here for Windows 2003 Server:
http://technet.microsoft.com/en-us/library/cc739424(WS.10).aspx?ppud=4

Title: Re: "Start any Program" - service does not work
Post by Gert on Sep 7th, 2010 at 12:28pm
For "Run a bat file", make sure you have the option
[X] Capture output
enabled.

If your task is called HELLO, and after you drop a file into the directory, it starts your bat file and redirects all output (ECHO HELLO WORLD) to a log file in directory

<taskdirectory>\HELLO\

those files have names like 12345_6789.log
To explore the task-directory, select the menu Tools -> Explore task directory. Good chance you will see error messages in the log files.

You can also look at the history database to see if the files are detected:
http://watchdirftp.blogspot.com/2008/05/how-task-history-works.html

Title: Re: "Start any Program" - service does not work
Post by Dschuwi on Sep 7th, 2010 at 4:27pm

Gert wrote on Sep 7th, 2010 at 12:28pm:
For "Run a bat file", make sure you have the option


those files have names like 12345_6789.log
To explore the task-directory, select the menu Tools -> Explore task directory. Good chance you will see error messages in the log files.


The output of the log files is absolutely the same whether WD runs as a service or not:

[code]
E:\WatchDirTest>GOTO :StartOfBat
E:\WatchDirTest>"D:\WA\WatchDirectory\wdAnnotate.exe" info "Starting E:\WatchDirTest\RunTest.bat for event"

E:\WatchDirTest>Call "E:\WatchDirTest\RunTest.bat" FILENEW
E:\WatchDirTest>D:\TESTDIR\TESTPROG.EXE
E:\WatchDirTest>"D:\WA\WatchDirectory\wdAnnotate.exe" info "Done" [/code]

However, when running as a service, "D:\TESTDIR\TESTPROG.EXE" (which is the only line in RunTest.bat) does not get executed, otherwise it does (three times actually, and three log files, even though only one file gets dropped into the monitored directory)

puzzled...
hp

Title: Re: "Start any Program" - service does not work
Post by Dschuwi on Sep 7th, 2010 at 4:28pm

Dirk wrote on Sep 7th, 2010 at 12:26pm:
Please check at the machine where wd is installed if the account you are using has the rights to log on as service like described here for Windows 2003 Server:
http://technet.microsoft.com/en-us/library/cc739424(WS.10).aspx?ppud=4

Yes, the account does have the rights, and other WD services do run very well...

Title: Re: "Start any Program" - service does not work
Post by Dirk on Sep 7th, 2010 at 4:40pm
Please try to run your program without WatchDirectory as a service.
How to:
http://support.microsoft.com/kb/137890/en-us
Required files:
http://www.microsoft.com/downloads/details.aspx?familyid=9d467a69-57ff-4ae7-96ee-b18c4790cffd&displaylang=en

Let me know if you can run it successfully with this tools.

Title: Re: "Start any Program" - service does not work
Post by Gert on Sep 7th, 2010 at 5:57pm
Also, as mentioned in the blogpost http://watchdirftp.blogspot.com/2010/04/watchdirectory-tasks-as-windows-service.html

Does your program depend on a certain Working Directory? Then set it yourself inside the bat file.

Code (]
rem set current dir to D:\Whatever
D:
CD "\Whatever"
[/code):

Does your program depend on certain PATH settings? Then set it yourself inside the bat file.
[code]
SET PATH=%PATH%;D:\testdir;c:\MyDlls

Title: Re: "Start any Program" - service does not work
Post by Dschuwi on Sep 9th, 2010 at 10:31am

Dirk wrote on Sep 7th, 2010 at 4:40pm:
Please try to run your program without WatchDirectory as a service.
How to:
http://support.microsoft.com/kb/137890/en-us
Required files:
http://www.microsoft.com/downloads/details.aspx?familyid=9d467a69-57ff-4ae7-96ee-b18c4790cffd&displaylang=en

Let me know if you can run it successfully with this tools.

No.
The service is created, successfully, but cannot be started.
However, if I understand it correctly, the WD task should run as a service and consequently start my program if needed - the program itself is not supposed to run as a service, right?

Title: Re: "Start any Program" - service does not work
Post by Dschuwi on Sep 9th, 2010 at 10:36am

Gert wrote on Sep 7th, 2010 at 5:57pm:
Also, as mentioned in the blogpost http://watchdirftp.blogspot.com/2010/04/watchdirectory-tasks-as-windows-service.html

Does your program depend on a certain Working Directory? Then set it yourself inside the bat file.

Tried - did not help...

Title: Re: "Start any Program" - service does not work
Post by Dschuwi on Sep 9th, 2010 at 10:39am
FYI - the custom program is Cyber-D's Autodelete 2.24 (Freeware).

If WD only had an option to autodelete files based on their created/modified file age, I would not need it ;-)

Title: Re: "Start any Program" - service does not work
Post by Gert on Sep 9th, 2010 at 10:42am
One further thing you could try (not recommended by MS) is to change the service property so it is allowed to interact with the desktop (or some such wording).

To use WD's delete task ( http://www.watchdirectory.net/wdhelp/plugins/wdopAutoDelete.html ) based on timestamps, look at the "File Age" monitoring method: http://www.watchdirectory.net/wdhelp/help/detect_old_files.html

Title: Re: "Start any Program" - service does not work
Post by Dschuwi on Sep 9th, 2010 at 11:07am

Gert wrote on Sep 9th, 2010 at 10:42am:
To use WD's delete task ( http://www.watchdirectory.net/wdhelp/plugins/wdopAutoDelete.html ) based on timestamps, look at the "File Age" monitoring method: http://www.watchdirectory.net/wdhelp/help/detect_old_files.html


Uh-oh... I did try this before, tried again now, seems to work.
There was only one uncertainty, I could not accurately test:

Can you confirm, ONLY files that actually triggered due to their age, will be deleted?

After my first tests I had the impression, after ONE file had triggered, ALL files according to the filter criteria would be deleted...

Since autodelete is a rather dangerous task, maybe this should be clarified directly in WD's settings window.

Title: Re: "Start any Program" - service does not work
Post by Gert on Sep 9th, 2010 at 11:14am
confirmed

Also, please read this blogpost (about  "remember triggered files"):
http://watchdirftp.blogspot.com/2009/01/file-age-monitoring-method.html

Title: Re: "Start any Program" - service does not work
Post by Gert on Sep 9th, 2010 at 11:14am
oh, and to re-iterate what Dirk said somewhere: some programs just can not run in a service context.

Title: Re: "Start any Program" - service does not work
Post by Dschuwi on Sep 9th, 2010 at 11:27am

Gert wrote on Sep 9th, 2010 at 11:14am:
confirmed

Also, please read this blogpost (about  "remember triggered files"):
http://watchdirftp.blogspot.com/2009/01/file-age-monitoring-method.html


Wow. Great. Perfect program. Thanks!

I need to run it 24/7 on an FTP server, will keep testing it for the rest of the trial period, and then eventually kick out it's competitor, which is outdated and not only by its name behaves like an ape in the trees ;-)

Cheers
hp

Title: Re: "Start any Program" - service does not work
Post by Dirk on Sep 10th, 2010 at 3:01pm
Dschuwi,


Quote:
No.
The service is created, successfully, but cannot be started.
However, if I understand it correctly, the WD task should run as a service and consequently start my program if needed - the program itself is not supposed to run as a service, right?


I have overlooked your posting, sorry.
Yes - I f you were not able to run your program as service with those MS tools, it cannot run as service. Your problem is not WatchDirectory-related, its application-related. I have several customers with exact the same problem.
You may contact the the programmer, maybe he is willing to change it.

Title: Re: "Start any Program" - service does not work
Post by Gert on Sep 10th, 2010 at 3:14pm
Just to add to Dirk's remarks...

99% of programs that are *really* command line (you know, you can start it in a "dos box") can be run in a service context as long as they do not ask questions but just "do it".

Programs that open a graphic user interface, with dialogs asking you "Are  you sure you want to delete..." are impossible to run in a service context because there is no user present to press OK.

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