WatchDirectory Forum
http://www.watchdirectory.net/cgi-bin/yabb25/YaBB.pl
watchDirectory forums >> How to... >> Executing a batch file placed in directory
http://www.watchdirectory.net/cgi-bin/yabb25/YaBB.pl?num=1334868674

Message started by Voltorb on Apr 19th, 2012 at 10:51pm

Title: Executing a batch file placed in directory
Post by Voltorb on Apr 19th, 2012 at 10:51pm
I want to use WatchDirectory to monitor for .bat files deposited in a directory, and execute them.  Can't seem to get it to execute them.

Title: Re: Executing a batch file placed in directory
Post by Gert on Apr 20th, 2012 at 7:26am
Hi,

Here is what you should do. Create a new bat file (for example called C:\Bin\StartBat.bat) with the following contents:
[code]Call "%WD_FILE%"
[/code]

The variable WD_FILE has the full name (including path) of the detected file (see http://www.watchdirectory.net/wdhelp/plugins/wdopAutoRunBatEnv.html ). The newly created bat file in your case.

Should work fine.

Title: Re: Executing a batch file placed in directory
Post by Gert on Apr 20th, 2012 at 7:27am
Also see this blogpost:

http://blog-en.gdpsoftware.com/2010/03/batch-job-scheduling.html

Title: Re: Executing a batch file placed in directory
Post by Voltorb on May 1st, 2012 at 9:16pm
I configured exactly as in the blog post above, except I issue a move to move the .bat file to a history folder.  Here's my code:

@echo off
Call "%WD_FILE%"
Move "%WD_FILE%" C:\DigitalHot\History\

The move is executed, but the batch file is not processed.  I can double click the batch file, and it works that way.  Any ideas?  I'm running WD on a Windows Server 2003 machine.

Thank you!

Title: Re: Executing a batch file placed in directory
Post by Gert on May 1st, 2012 at 9:30pm
Just a guess... You are running the WD task as a Windows Service?
Try to run the task "normally" first (not as a Windows Service).

Also see this blog: http://blog-en.gdpsoftware.com/2010/04/watchdirectory-tasks-as-windows-service.html


Title: Re: Executing a batch file placed in directory
Post by Voltorb on May 1st, 2012 at 9:35pm
Yes, I was running as a service.  

Works like a charm now!  Thank you VERY much!

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