WatchDirectory Forum
http://www.watchdirectory.net/cgi-bin/yabb25/YaBB.pl
watchDirectory forums >> Plugins >> Batch question
http://www.watchdirectory.net/cgi-bin/yabb25/YaBB.pl?num=1446583974

Message started by LRI on Nov 3rd, 2015 at 9:52pm

Title: Batch question
Post by LRI on Nov 3rd, 2015 at 9:52pm
I am trying to run a batch file located on C:\.

It runs a form for a MS Access database. It runs fine outside of WD but won't launch through WD.

It is supposed to trigger on a FileNew on another local drive (F:\). WD sees the file because it shows in the last message area for the task (FN: F:pinscrub\report\2_K...csv)

Below is the syntax for the batch file:

C:
"C:\Program Files (x86)\Microsoft Office\OFFICE11\msaccess.exe" "C:\Scrub\LIDB_StandAlone.mdb" /x RunForm

What am I missing?

Thanks in advance.

Title: Re: Batch question
Post by LRI on Nov 3rd, 2015 at 10:15pm
Update:

I am receiving a warning email from WD-

TaskCaller: terminating thread as it didn't respond within 10 seconds to stop request.
Date/Time: 11/3/2015 2:06:34 PM

Title: Re: Batch question
Post by LRI on Nov 3rd, 2015 at 10:37pm
Apparently I was mistaken. WD only see the new file when the task is fired up, it subsequently ignores all new files afterwards.

In neither case will it launch the bat file.

Title: Re: Batch question
Post by Gert on Nov 4th, 2015 at 7:42am
Hi,

There are several issues here.
You are wondering if the bat files is called at all. Should be easy to see by adding something like
[code]ECHO %WD_REASON% %WD_FILE% >> C:\Temp\wdlog.txt[/code]
as the first line of your bat file.

You say it looks like your bat is only called for the first file, not for subsequent files.
My guess would be that WD is still waiting for that first bat file to complete. Further evidence for this is the "terminating thread" message you see. When you stop a task, WD will tell its background threads to stop as well. If they do not stop within 10 seconds, WD will "kill" them. The message you get is from the "TaskCaller" thread, the thread that is calling your script. The thread is waiting for your bat file to complete.

Most likely it is the issue that msaccess.exe is "hanging", perhaps with a message saying something like "file not found".

While testing those kind of things do NOT run the task as a Windows Service, see http://blog-en.gdpsoftware.com/2010/04/watchdirectory-tasks-as-windows-service.html

Title: Re: Batch question
Post by LRI on Nov 4th, 2015 at 3:05pm
If I turn off the Windows services it runs flawlessly.

No changes were made to the batch file.

If I insert your code into the batch file the log just reads "Echo is on"

Is this a batch file issue or something else?

Title: Re: Batch question
Post by Dirk on Nov 4th, 2015 at 4:12pm
You need to make sure that the service user under which the windows service is running can access all directories and programs and is configured to logon as batch process in Windows security settings.

Title: Re: Batch question
Post by LRI on Nov 4th, 2015 at 4:55pm
The service was logged on as the administrator when we had it running.

I tried running it under Local System as well and it failed to fire the batch file

Do you know where in the security policies this setting may be?

For what its worth we have Watch FTP running as a service, which also triggers a bat file, without any problems.

Title: Re: Batch question
Post by Dirk on Nov 4th, 2015 at 5:09pm
see here:
https://technet.microsoft.com/en-us/library/cc957131.aspx

if your Administrator user has already this right there is in issue in user rights somewhere (an Administrator has not the right "full access" on every folder per default - but he can get it).

Please also enable and run "interactive service detection" in windows services. This will maybe help seeing why the cmd hangs in the background. When it hangs you should see a blinking icon in task bar. Click it and click "view message".

Title: Re: Batch question
Post by LRI on Nov 4th, 2015 at 6:22pm
I checked the Security Policies and the Admin does have rights to Log on as a batch job as well as Log on as a service.

Enabling "interactive service detection" did not produce the desired blinking icon.

I moved the batch file to the same folder that houses the batch files that are triggered by Watch FTP but it still won't fire. This folder is on the F:\ drive.

It still only triggers if it is run manually.

Title: Re: Batch question
Post by Gert on Nov 5th, 2015 at 6:46am
Please, for the moment, change your bat file to something super-simple like

[code]SET WD_ >> "C:\Temp\wdlog.txt"[/code]
and remove the rest (the part calling msaccess).
This will dump all WD environment variables to wdlog.txt every time your script is called. I am quite sure if you run the task (as a service) it will work fine and you will see this dump for every file detected.

That will "prove" it is caused by msaccess.

If the above works, try to get the original working. Change the Windows Service properties so the task runs with YOUR userid/pass.

Title: Re: Batch question
Post by LRI on Nov 6th, 2015 at 12:37am
You are right it ran perfectly without any other changes to the set up. I just ran your code. The results are below. I am still unclear what the problem with my syntax is...

WD_CONFIG=AutoRunLIDB-MBD
WD_CUREVT=60
WD_CURRUN=35
WD_DATE=20151105
WD_DIR=F:\Test\Report
WD_DTTM=20151105 112537
WD_EVENTNO=1
WD_FILE=F:\Test\Report\2_K051124081.CSV
WD_FILE_B=2_K051124081
WD_FILE_D=F:\Test\Report\
WD_FILE_DATE_CR=20151105
WD_FILE_DATE_LM=20151105
WD_FILE_E=CSV
WD_FILE_N=2_K051124081.CSV
WD_FILE_OWNER=Administrators
WD_FILE_SHORTNAME=2_K051~1.CSV
WD_FILE_SHORTPATH=F:\Test\Report\2_K051~1.CSV
WD_FILE_SIZE=28014
WD_FILE_SIZE_GB=0
WD_FILE_SIZE_KB=27
WD_FILE_SIZE_MB=0
WD_FILE_TIME_CR=112410
WD_FILE_TIME_LM=112410
WD_INSTDIR=C:\Program Files (x86)\watchDirectory
WD_REASON=FILENEW
WD_RELDIR=
WD_TASKDIR=c:\programdata\watchdirectory\autorunlidb-mbd
WD_TIME=112537
WD_CONFIG=AutoRunLIDB-MBD
WD_CUREVT=61
WD_CURRUN=35
WD_DATE=20151105
WD_DIR=F:\Test\Report
WD_DTTM=20151105 112554
WD_EVENTNO=2
WD_FILE=F:\Test\Report\2_K051125461.CSV
WD_FILE_B=2_K051125461
WD_FILE_D=F:\Test\Report\
WD_FILE_DATE_CR=20151105
WD_FILE_DATE_LM=20151105
WD_FILE_E=CSV
WD_FILE_N=2_K051125461.CSV
WD_FILE_OWNER=Administrators
WD_FILE_SHORTNAME=2_K051~2.CSV
WD_FILE_SHORTPATH=F:\Test\Report\2_K051~2.CSV
WD_FILE_SIZE=28014
WD_FILE_SIZE_GB=0
WD_FILE_SIZE_KB=27
WD_FILE_SIZE_MB=0
WD_FILE_TIME_CR=112547
WD_FILE_TIME_LM=112547
WD_INSTDIR=C:\Program Files (x86)\watchDirectory
WD_REASON=FILENEW
WD_RELDIR=
WD_TASKDIR=c:\programdata\watchdirectory\autorunlidb-mbd
WD_TIME=112554

Title: Re: Batch question
Post by Gert on Nov 6th, 2015 at 6:03am
I don't think your syntax is incorrect, I think msaccess finds some kind of error and is prompting you (and you can not see that prompt when running as a service) to fix it.

One thing I now think of.....
When you run a task as a windows service, I think the working directory always is c:\windows\system32. When not running as a service it is the monitored directory (I think).

In your msaccess app, make sure to use Full Paths to filenames, not just the name of the file.

And as mentioned earlier, set the user/pass of the windows service to YOUR username/pass.

Title: Re: Batch question
Post by LRI on Nov 6th, 2015 at 2:22pm
The MS Access DB is on C: and the monitored directory is F:
Should I try placing them on the same drive?

Title: Re: Batch question
Post by LRI on Nov 6th, 2015 at 3:03pm
Not sure if this matters but in the Task Manager it shows the cmd.exe as well as msaccess are both hanging. I would have thought that only MSAccess would be having the problem.

Putting the MDB on the same drive as the monitored directory did not resolve the issue.

Title: Re: Batch question
Post by Dirk on Nov 6th, 2015 at 4:01pm
The cmd hangs because it's waiting of a feedback from msaccess.exe. You may use 'start C:/....' to run msaccess in a different instance.

There are a few programs that never can run as service - maybe msaccess.exe is one of those.

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