WatchDirectory home page
WatchDirectory Startseite (Deutsche Version)
Site WatchDirectory (Franais)
  Welcome, Guest. Please Login or Register
YaBB - Yet another Bulletin Board
   
  HomeHelpSearchLoginRegister  
 
Page Index Toggle Pages: 1
Batch question (Read 4332 times)
LRI
YaBB Newbies
*
Offline



Posts: 25
Batch question
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.
Back to top
 
 
IP Logged
 
LRI
YaBB Newbies
*
Offline



Posts: 25
Re: Batch question
Reply #1 - 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
Back to top
 
 
IP Logged
 
LRI
YaBB Newbies
*
Offline



Posts: 25
Re: Batch question
Reply #2 - 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.
Back to top
 
 
IP Logged
 
Gert
YaBB Administrator
*****
Offline



Posts: 2232
The Netherlands
Re: Batch question
Reply #3 - 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 


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.h...
Back to top
 

Gert Rijs - gert (at) gdpsoftware (dot) com
Blog: http://blog-en.gdpsoftware.com/
End Alzheimer's: http://www.alz.org&&...
WWW WWW GdPSoftware  
IP Logged
 
LRI
YaBB Newbies
*
Offline



Posts: 25
Re: Batch question
Reply #4 - 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?
Back to top
 
 
IP Logged
 
Dirk
YaBB Administrator
*****
Offline



Posts: 659
South Germany
Re: Batch question
Reply #5 - 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.
Back to top
 

Viele Gre / Best regards
Dirk - GdP Software

dirk [at] gdpsoftware [dot] com
http://blog-de.gdpsoftware.com
Webseite: http://www.gdpsoftware.com
WWW WWW  
IP Logged
 
LRI
YaBB Newbies
*
Offline



Posts: 25
Re: Batch question
Reply #6 - 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.
Back to top
 
 
IP Logged
 
Dirk
YaBB Administrator
*****
Offline



Posts: 659
South Germany
Re: Batch question
Reply #7 - 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".
Back to top
 

Viele Gre / Best regards
Dirk - GdP Software

dirk [at] gdpsoftware [dot] com
http://blog-de.gdpsoftware.com
Webseite: http://www.gdpsoftware.com
WWW WWW  
IP Logged
 
LRI
YaBB Newbies
*
Offline



Posts: 25
Re: Batch question
Reply #8 - 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.
Back to top
 
 
IP Logged
 
Gert
YaBB Administrator
*****
Offline



Posts: 2232
The Netherlands
Re: Batch question
Reply #9 - 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" 


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.
Back to top
 

Gert Rijs - gert (at) gdpsoftware (dot) com
Blog: http://blog-en.gdpsoftware.com/
End Alzheimer's: http://www.alz.org&&...
WWW WWW GdPSoftware  
IP Logged
 
LRI
YaBB Newbies
*
Offline



Posts: 25
Re: Batch question
Reply #10 - 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
Back to top
 
 
IP Logged
 
Gert
YaBB Administrator
*****
Offline



Posts: 2232
The Netherlands
Re: Batch question
Reply #11 - 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.
Back to top
 

Gert Rijs - gert (at) gdpsoftware (dot) com
Blog: http://blog-en.gdpsoftware.com/
End Alzheimer's: http://www.alz.org&&...
WWW WWW GdPSoftware  
IP Logged
 
LRI
YaBB Newbies
*
Offline



Posts: 25
Re: Batch question
Reply #12 - 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?
Back to top
 
 
IP Logged
 
LRI
YaBB Newbies
*
Offline



Posts: 25
Re: Batch question
Reply #13 - 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.
Back to top
 
 
IP Logged
 
Dirk
YaBB Administrator
*****
Offline



Posts: 659
South Germany
Re: Batch question
Reply #14 - 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.
Back to top
 

Viele Gre / Best regards
Dirk - GdP Software

dirk [at] gdpsoftware [dot] com
http://blog-de.gdpsoftware.com
Webseite: http://www.gdpsoftware.com
WWW WWW  
IP Logged
 
Page Index Toggle Pages: 1