Search This Blog

Showing posts with label Questions and Answers. Show all posts
Showing posts with label Questions and Answers. Show all posts

Wednesday, 6 July 2022

Fix a corrupt history database for WatchFTP

When your computer abruptly shuts down or crashes, it can happen WatchFTP's history database becomes corrupt. Your task can not run anymore.


When this has happened you will typically get a message about SQL Errors (can not select from the housekeeping table). When you start the WatchFTP control center it tries to fix this but sometimes it needs a little help.


How to fix this issue

You will need to delete the current (corrupt) database, here is how:
  • Open the WatchFTP Control Center
  • Make sure the problem task is stopped
  • Right-click the task and select "Explore Task Directory" from the popup menu. This will open Windows Explorer, typically inside (a subdirectory of) "C:\ProgramData\WatchFTP"
  • Make sure you are in a subdirectory with the same name of the task
  • Delete all files with names that start with "history", it is typically only one but there could be a few
  • Stop the WatchFTP Control Center and start it again, this will create a new (empty) history database

After this, your task should run fine again.

 

Please note this will not work for WatchDirectory. A future blog will explain how to fix a WatchDirectory corrupt database.


Friday, 1 July 2022

WatchDirectory - Could not create temporary file

 

If you try to edit or create a WatchDirectory task and receive a message like

"Could not create a temporary file"

Here is the reason and how to resolve this issue.

Why this happens

While you create or edit a task the WatchDirectory Control Center needs to store your new settings somewhere. It can not be inside the WatchDirectory settings directory itself because you may cancel editing. So WatchDirectory asks Windows what the directory for "temporary files" is.
All your changes are made to a temporary file inside that directory. When you press OK, the file is moved to the WatchDirectory settings directory.

The problem here is Windows tells WatchDirectory it can create temporary files in some directory (something like C:\Temp), but there is a problem. Typically the directory does not exist or (not so common) WatchDirectory is not allowed to write/create/delete files inside the directory.

How to resolve

Here are the steps you need to follow to fix this:
  1. Stop the WatchDirectory Control Center
  2. Open a Windows command prompt by running cmd.exe
  3. On the command prompt enter the following 2 commands
    SET TMP
    SET TEMP
Those commands will respond with the name of 1 or 2 directories (they typically are the same directory). Now you need to make sure those directories exist and "Everyone" has the privilege to create/change/delete files inside them.


Sunday, 4 May 2014

Rename xml files using the value of an xml-node

Q&A

A customer wants to monitor a directory for new XML files and move/rename those files to a different directory. The files should be renamed to the value of an xml-node inside the xml file.

For example, the file 123.xml, which has the following contents

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<data-set xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
 <Title>
  <PRMap>I_32c_T_A</PRMap>
  <IMP>HH</IMP>
  <Pszx>683</Pszx>
  <Pszy>560</Pszy>
  <PGszx>27.305</PGszx>
......

should be renamed to the value of the <PRMap> node, the 123.xml file will be renamed to I_32c_T_A.xml.

Solution

WatchDirectory does not directly support reading xml values, but we wrote a little helper program (GetFromXML.exe) to make this possible. The idea is to use the "Copy Files" task with the Dynamic Naming option.

One of the dynamic name tags allows you to call a batch script to determine (part of) the final name to use. This batch script can then read the xml file (using GetFromXML.exe) to extract the correct name to use.
Download GetFromXML here.

This is the batch script (GetFromXML.bat):

SET GET=C:\Bin\GetFromXml.exe
  
"%GET%" "%WD_FILE%" Title^|PRMap^|* > "%WD_FILTERRESULT%"
if %errorlevel% neq 0 (
  DEL "%WD_FILTERRESULT%"
  echo Error xml lookup in file fails > "%WD_FILTERRESULT%"
)

The script should be saved as C:\Program Files (x86)\WatchDirectory\Resolvers\GetFromXML.bat and now the customer can use the following "Dynamic Name" as the target for this copy files task:

C:\Target\{code{GetFromXml.bat,}}.xml

Wednesday, 12 March 2014

Filter Scrips - Slightly underdocumented

Q&A

WatchDirectory v4.7 and higher have support for filter scripts, run a little batch script to decide if a detected file should be processed by a task. This is a new option on the Filter Events settings of your task.

Before this new feature was introduced you could only filter based on (parts of) the filename or folder where the file was detected. For example "only run the task for files that match *.txt". The new filter script option gives you far more flexibility, your script receives all information about the detected file in Environment Variables and can, for example, check the contents of the detected file to decide wether the task should continue processing the file.

Several example filter scripts can be found inside the directory <Install Directory>\ExampleFilterScripts (typically C:\Program Files (x86)\watchDirectory\ExampleFilterScripts).

Example: Only email when files contain the word "Error"

A client was monitoring a directory where log files are created by an automated nightly process. Most log files are of no interest but sometimes one or two files contain error information and the client wants to be notified of those. He created a task using the Email plugin and enabled the option to attach the log file. Below is the filter script he used.

rem When called from the WatchDirectory Control Center, always process the "event"
IF "%WD_CALLEDFROMSETUP%" EQU "Y" GOTO :SayYes

rem use FINDSTR to check the contents of the file
FINDSTR /I "Error" "%WD_FILE%"
IF %errorlevel% EQU 0 GOTO :SayYes
rem this is not an error log, tell the task to ignore the event
GOTO :SayNo

:SayYes
ECHO Y > "%WD_FILTERRESULT%"
GOTO :EOF

:SayNo
ECHO N > "%WD_FILTERRESULT%"
GOTO :EOF

A few tips

Do not perform any heavy processing inside those scripts. If your script takes a long time to finish the WatchDirectory task will abort. A few seconds is okay, 10 seconds is not.

Make sure your script always writes its result (the single character Y or N) to the result file (echo Y > "%WD_FILTERRESULT%").

Friday, 17 August 2012

Print downloaded PDF files automatically with WatchFTP

Q&A

A customer asked how he can automatically print PDF files downloaded by WatchFTP.

WatchFTP can start a batch file after downloading so we use a script to run Foxit Reader to print the file. One extra feature was needed: he wants to print invoices on one printer and tickets on another.

Here is an example bat file you can use for this:

SET FOXCMD=C:\Program Files (x86)\Foxit Software\Foxit Reader\Foxit Reader.exe
rem the printer for INV- files (printer names exactly as on your "Printers" control panel applet)
SET PRINTER1=Local Printer1
rem the printer for TIC- files
SET PRINTER2=\\Server\ServerPrinter 1
rem the printer for everything else
SET PRINTERDEFAULT=Local Printer2
rem a log file (taskname_yyyymmdd.log)
SET LOG=C:\Logs\%WF_CONFIG%_%WF_DATE%.log

rem check for valid file type, only PDFs are supported
IF "%WF_FILE_E%" NEQ "PDF" GOTO :Eof

rem get the first 4 positions of the filename
SET P4=%WF_FILE_N:~0,4%

SET PRINTER=%PRINTERDEFAULT%
IF /I "%P4%" EQU "INV-" (
   SET PRINTER=%PRINTER1%
)
IF /I "%P4%" EQU "TIC-" (
   SET PRINTER=%PRINTER2%
)
echo [%time%] printing %WF_FILE% to printer %PRINTER% >> "%LOG%"
"%FOXCMD%" /t "%WF_FILE%" "%PRINTER%"
IF %errorlevel% GEQ 1 GOTO :PrintFails
echo [%time%] printed >> "%LOG%"
GOTO :EOF

:PrintFails
echo [%time%] ERROR - FILE WAS NOT PRINTED >> "%LOG%"
GOTO :EOF

Tuesday, 31 July 2012

Automatically copy a file to multiple directories

Q&A

Perhaps I should blog a little more often. Perhaps just some questions from customers and answers from me.
Sometimes the answers are so obvious to me, but people who didn't use WatchDirectory as long as I did may find this useful.

How can I copy a file to multiple target directories?

Easy (part 1): just configure multiple Copy Files tasks.

Easy and Obvious. Another question answered. Another happy customer!!

How can I copy a file to multiple target directories in ONE process?

Oops. If you setup multiple tasks like described above, you will have multiple processes running (one for each "target directory"). Not a big problem if you want to copy to 3 or 4 targets but Windows will not like it if you need to copy to (say) 30 or 40 target directories.


Easy Answer - Alternative 1 - Sort Files

As copying files is one of the most popular uses for WatchDirectory (together with email notifications and Upload Files) we made a task especially for this.

It is called the Sort Files plugin. It is one process that monitors a directory and uses "rules" (see here) to determine where it should copy the files to. If you do not set the "final" option for a rule, the rules after it will also run, thereby allowing you to copy a file to multiple locations.


Easy Answer - Alternative 2 - Subtasks

WatchDirectory Professional (not the Standard edition) includes a plugin called the Subtask plugin. This is a more general task that can call other plugins (including "Copy Files", "Upload Files" and "Email Files") for each detected new or changed file.

See Also

How many tasks does WatchDirectory support?


Saturday, 6 November 2010

Move File Viking to another Computer

File Viking stores all its settings (configured baskets) in 2 files (baskets.cc and repository.cc). If you want to "copy" your File Viking settings to another computer, follow the steps in this post.

On the Old Computer

Exit File Viking

Open the directory with File Viking Settings. The exact location depends on your operating system.

Vista & Win-7 (Win2008)
Enter %LOCALAPPDATA% in the Search box of your start menu, this will open C:\Users\YourLoginName\AppData\Local and you will find a FileViking sub-directory there.

Earlier Operating Systems (Windows XP, 2000 and 2003)
Enter "%USERPROFILE%\Local Settings\Application Data" in the "Run..." box of your start menu, this will open the directory which has the FileViking sub-directory.

From this File Viking directory, copy the files baskets.cc and repository.cc. You can ignore the Backup files.

On the New Computer

Install File Viking and Run it once so the settings directory will be created. Exit File Viking.

Depending on the Operating System, see the steps above to open the proper File Viking settings directory.

Copy the 2 .cc files from the old computer here, overwriting the 2 files already there.

See Also

Move your WatchDirectory install to another Computer
Move your WatchFTP install to another Computer (soon)

Tuesday, 19 October 2010

A Collection of Links

Q&A

When we do support for customers we often include links to relevant blogposts. Here is a list of posts we refer to most often.


Saturday, 11 September 2010

Automatic Video Transcoding with HandbrakeCLI

Q&A

A customer, Kai, asked a few questions on our forum how he could configure WatchDirectory's Start any Program task to run Handbrake on newly detected video files. He was able to figure out most of it himself (what do *I* know about video conversion?) after a few tips.

HandBrake is a highly popular open-source, GPL-licensed, multiplatform, multithreaded video transcoder, available for MacOS X, Linux and Windows. It includes a command line version, called HandbrakeCLI which allows for easy automation when used together with WatchDirectory or File Viking's Run Action.

Settings

Here you see Kai's setting for his WatchDirectory task. He uses a rather long line for "Parameters for this program", so here is the plain text version:

-i "%WD_FILE%" -f mp4 -w 720 -l 400 -e x264 -b 1000 -2
     -a 1 -E faac -6 dpl2 -R 48 -B 128 -D 0.0 -v 1
     -o "C:\Converted Videos\%WD_FILE_B%.mp4"

I added a few linebreaks, but obviously they should be on 1 line. You will notice he uses 2 variables:

  • %WD_FILE% - this will be replaced by the full path of the detected file by WatchDirectory.
  • %WD_FILE_B% - this will be replaced by just the name of the detected file.

The full list of supported variables

Important Setting

When you are transcoding videos with Handbrake and WatchDirectory like this, please be aware that video transcoding is a very slow, time consuming process. WatchDirectory has no way of knowing if a program started by it is "hanging" or just busy working. In this case Kai has set "Wait for program to exit" to 14400 seconds (4 hours), which should be more than enough if you run this on a reasonably modern computer. If you set this too low, WatchDirectory will "kill" the Handbrake process prematurely.

If you disable "Wait for program to exit" and multiple video's are detected by WatchDirectory, WD will start multiple Handbrake processes to transcode multiple video files. This is only advised for the most powerful computers.

If you use File Viking

File Viking's Run Action can also run HandbrakeCLI, but its environment variables have slightly different names:

  • %FV_FILE% - this will be replaced by the full path of file you dropped on the File Viking basket.
  • %FV_FILE_B% - this will be replaced by just the name of the dropped file.

File Viking currently always waits for the program to exit, there is no need to set a timeout.

Wednesday, 23 June 2010

Send a Task Backup to Support

Q&A

When you contact us about an issue with a WatchDirectory task we may ask you to send us the settings and history for us to look at. We may also ask you to enable "Debug" for your task before you send us the backup.

This posts has all the tiny little details.

Enable Debug Info

On the "Other Settings" window enable the option "[X] Write Debug Info". Now run the task. After a while, when you know the problem has occurred again, stop the task and create the backup for us (see further down below).

The FTP (Upload) Task

If the task is an FTP (Upload) Task, there is an extra "debug" setting you need to enable, "[X] Write FTP Conversation to History". This will output all FTP commands and responses to the history database.

Just before you backup this FTP task, you may want to edit it again to temporarily change the username/password. The encrypted password is stored inside the backup.

Create the Backup

  • Stop the task
  • Right-click the task, a context menu opens.
  • Select the option "Backup selected task(s)

This will create a ZIP file of your task settings and its history for us to look at.

Task History

If you want to look into the history info yourself and you are not familiar with WD's History Viewer, please read the post How Task History Works first.

Monday, 19 April 2010

WatchDirectory Tasks as a Windows Service

Q&A

Here are a few tips if you have trouble running a WatchDirectory task as a Windows Service.

Make sure it works at all

As a first step, please make sure the task works properly when you manually start it (Not as a Windows Service). Set How to Run to Manually. When you have the task working properly "Manually", read on.

Network Directories

If your task only works on "local directories" (typically C:\ or D:\), you can skip this. If your task accesses drives on other computers ("The Network"), read on.

The Windows Service created by WatchDirectory runs as the user "Local System". Notice the word "Local"? The task can not access any network resources. Only directories on the computer where this task runs are accessible. So if you have a task that reads (monitors) or writes to network directories, you need to change the user that runs this task to someone who has access to those directories, see Change the User (last paragraphs of this post).

P:\

Are you accessing Mapped Network Drives? Please note that drive mappings (typically something like P:\ or X:\) are set by Windows based on the logged in user. Also, depending on the Windows version, those mappings are not available to Services even if you Change the User of the Service. Always use UNC naming for network drives (\\Server\Sharename\Directory instead of P:\Directory).

Network Share Permissions

When you share a directory on the network, older Windows versions by default gave Full Control (read, write, delete...) to anyone who is allowed to access the share. Current Windows releases default to read-only access. If your task needs to write to a network share, please check if the User running the task has proper privileges.

Batch Files

All the network issues above also apply to bat/cmd files you write. Please access network drives using their UNC name (\\server\share\directory\file.txt).

PATH
Please note the Windows PATH, where Windows can find executables to run, depends on the logged in user (the user that "runs" the WD task). If your script depends on programs that should be on your PATH, you may need to change the PATH in your bat script:

SET PATH=C:\My Binaries;%PATH%

Use Full Paths for files
If you currently have commands like

DoIt.exe "%WD_FILE%"

in your script, assuming DoIt.exe is in the current directory or your PATH, please change it to

"C:\Program Files\Do It Incorporated\DoIt.exe" "%WD_FILE%"

Note: %WD_FILE% contains the full path to the detected file, see Environment Variables.

Do not depend on the Working Directory
You should consider the "Current" (or "Working") directory to be RANDOM when your script is started. So, if you need a specific working directory, your script should set it itself.

Printing

Just like mapped drives, printers are maintained by Windows separately for each user account. Please see the last paragraph of this blogpost: Printing from a Windows Service.

Change the User for the WatchDirectory Service

Currently you can not change the user that runs the Windows Service inside the WatchDirectory Control Center. You must change it on the Windows Control Panel Applet "Windows Services":

  • Inside the WatchDirectory Control Center, select the menu "Tools -> Windows Services"
  • Open the settings for the service called watchDirectory:TheNameOfYourWatchDirectoryTask
  • Change the user/password for the Service

A future WatchDirectory version will make changing this user/password easier, from inside the WD Control Center.

Perhaps it is a good idea to create a new (domain) user called WatchDirectory specifically for your WD tasks. One important aspect of this user is to let its password "never expire". If you set it up so the password does expire, you will need to change the password for all WatchDirectory tasks every month...

Blog auf Deutsch lesen

Sunday, 7 March 2010

Batch Job Scheduling

Q&A

When we receive multiple requests from customers, in a short period of time, asking for a solution to the same issue, it is time to write a blogpost about it.

Automatically Run New Bat or CMD files

The question asked was

I want WatchDirectory to detect new Batch Scripts, *.cmd or *.bat, in a directory and automatically run them. I tried the Automatically Run Bat Files task, but it wants me to enter the name of the bat file to run. How can I do this?

The answer:

Yes, you need the "Run Bat Files" task, you just need to create a "static" batch file that will run the newly detected bat or cmd file. A simple RunTheNewScript.bat like this will do:

@echo off
rem the variable %WD_FILE% has the complete path to the newly detected script
Call "%WD_FILE%"
rem delete the script after it has run? Remove the "REM" on the next line
REM DEL "%WD_FILE%"

It is probably best to also Setup a Filter so this new task will only run when it detects a CMD or BAT file, see the picture below.

This is a low cost alternative to products such as Camellia Batch Job Server. Obviously, as a specialized program, Camellia BJS offers more/other functionality, but if all you need is to run dynamically created batch scripts automatically, you can do it with WatchDirectory.

Friday, 5 February 2010

Receive an Email when No Files are Created

This post will describe how you can configure WatchDirectory's Email Task to receive an email when a directory has no activity for some time.

The Problem

WatchDirectory and its Email Task are most often used to send email when new files are created or changed. To make it send an email when "nothing happened" might seem easy, just select the QUIET option on the Events page and WatchDirectory will "trigger" when no changes are detected.

If you only select "QUIET" as the event, you will soon find you also receive emails even if there is activity (new files) in the monitored directory. Why is this?

The issue is that "QUIET" needs other events to "compare against". When another event happens, for example "FILENEW" - a new file is created, WatchDirectory sets a timer for the QUIET event. If there is another event before the timer times out, the timer is reset again.

So, if you want to receive an email when nothing happened for some time, you must enable both the QUIET and the FILENEW events. Obviously, now you will also receive emails when new files are created.

No Email for New Files

Here is how you can configure WatchDirectory to prevent those emails for new files.

First, you must make sure the email body has some unique text to distinguish between emails for the QUIET event (nothing happened) and the emails for FILENEW (new files are detected). Enter something like this at the bottom of the message body:

%WD_CONFIG%-%WD_REASON%

The above are 2 Environment Variables you can use with the Email task. %WD_CONFIG% is replaced by the name of your task (for example "NotifyNoActivity") and %WD_REASON% is replaced by "what happened" (QUIET or FILENEW).

Filter Email

Close the settings of the task and select WatchDirectory's menu
"View -> Email -> Email Settings".
At the bottom of the window that opens click "Filter Email" and the window to the left will open.

On this window you can enter (partial) subjects and message body strings that will prevent WatchDirectory sending those emails. Every email, for all tasks you create that has the text "NotifyNoActivity-FILENEW" in its body, will not be sent.

Friday, 8 January 2010

Create a CSV of all WatchDirectory Events

Q&A

Thomas asked if it is possible to have an overview of all events (detected files) from all his tasks. The Task History Viewer only shows you information of one task, it is currently not possible to see detected file information for all tasks on one window.

WatchDirectory stores all event information (detected files) in an SQLite database. Each task has its own history database. This post shows how you can create a CSV (comma separated values) file from the history of all your tasks.

Download the Scripts

Download the example scripts and tools (~0.5MB) and extract them to C:\listEvents. Make sure the "tmp" subdirectory is also created. The scripts write temporary files to this directory.

Configure the Scripts

The download contains 2 scripts:

  • listEvents.bat
    This script extracts the latest XXX events of all tasks
  • listEventsByDate.bat
    This script extracts the events of the last XXX days of all tasks

Please inspect the first few lines of those scripts and change them to reflect where you unzipped the download and the location of WatchDirectory's task directory.

How the Scripts Work

Both scripts enumerate all config files in the task directory and write SQL statements to a temporary file to copy event information to a temporary SQLite database. Once all data is copied, it queries the new database and exports the information to a CSV file. Once complete they start Excel to open the CSV.

Saturday, 1 August 2009

Q&A - Load Balancing Humans

Q&A

One of our customers, USA Transcription Services, uses WatchDirectory to automatically send work from clients to transcriptionists. Clients upload work to a directory monitored by WatchDirectory and WatchDirectory sends it to the transcriptionist assigned to the client.

Normally each client has a dedicated transcriptionist, but some clients send a lot of work to transcribe - more work than one employee can handle in a reasonable time. What is needed is to assign 2 transcriptionists to such a client, making sure no work is duplicated (done by both).

Lori, my contact at USA Transcription Services, asked if I knew a way to solve this.

Solution Outline

Instead of sending work directly from the directory where clients upload work, we first need to distribute these files into separate directories, assigned to different transciptionists. These directories can then be monitored by another WatchDirectory task to send the work to the individual employees.

Solution 1 - Sort Files

Use the Sort Files plugin to distribute the detected files to employee folders. Create multiple "sort rules", making sure they are all "final" (so a file is only copied to one employee folder).

This solution depends on the names of the files uploaded by the customers. If you can be sure these names are quite random, you can base the sort rules on, for example, the first letter of the filename. The first sort-rule would use a mask like

*\a*;*\b*;*\c*;*\d*;*\e*;*\f*;*\g*;*\h*

so it copies all files with names starting with a, b, c, d, e, f, g and h (ignoring case), and the second rule would just use * as the mask - matching all files not handled by the first rule.

One problem: the masks as entered for sort-rule one will also match the file C:\Directory\ZZZZZZZZ.TXT because of the mask "*\d*".
So, in this case, it is better to enter the file masks as *directory\d* (or just *ory\d*).

Another problem, it can be quite hard to guarantee all files uploaded by clients have random names. Maybe better to use masks based on the second character of those names:

*\?a*;*\?b*;*\?c*;*\?d*;*\?e*;*\?f*;*\?g*;*\?h*

This post is not intended to go into the linguistic analysis of filenames but I think the letter 'E' is quite common as the second letter in English filenames

Solution 2 - A Batch File that distributes randomly

This is the solution Lori is using now. If you don't need rocket science precision (exactly half of the files go to directory-1, the other half goes to directory-2), this will work fine. Especially if you are dealing with a large number of files to distribute.
This solution uses the Run a Batch File task to start a script that uses the environment variable %RANDOM% to determine the target directory (and thus the employee that transcribes the file).
Here is the script:

SET TARGET1=C:\Uploads\Employee1
SET TARGET2=C:\Uploads\Employee2
rem get a random number (0 - ~32000)
rem and get the remainder of divide by 2, so we have a number 0 or 1 as the result
SET /a REMAINDER=%RANDOM% %% 2
SET TARGET=%TARGET1%
IF %REMAINDER% EQU 1 SET TARGET=%TARGET2%
rem move the detected file to TARGET
MOVE "%WD_FILE%" "%TARGET%"

If a client needs 3 employees, the script can be changed to (changes highlighted):

SET TARGET1=C:\Uploads\Employee1
SET TARGET2=C:\Uploads\Employee2
SET TARGET3=C:\Uploads\Employee3
rem get a random number (0 - ~32000)
rem and get the remainder of divide by 3, so we have a number 0, 1 or 2 as the result
SET /a REMAINDER=%RANDOM% %% 3
SET TARGET=%TARGET1%
IF %REMAINDER% EQU 1 SET TARGET=%TARGET2%
IF %REMAINDER% EQU 2 SET TARGET=%TARGET3%
rem move the detected file to TARGET
MOVE "%WD_FILE%" "%TARGET%"

Solution 3 - No Randomness

Random can be a tricky concept... I will let Dilbert Explain. To guarantee an even distribution of files you need to count the files, please see this forum post.

PS: I found the Dilbert comic only on web.archive.org. It must be somewhere on the official dilbert.com site as well, but I could not find it. If you have a link to the original pic on dilbert.com, please let me know.

Friday, 17 April 2009

Q&A - Run bwavinfo for detected files

Q&A

Adam on our Forum asks:

Q

Hi all,

I'll confess I'm no expert on scripting, but I've had a good deal of success in running simple batch files on watched directories, up until now..

I'm trying to run a command 'bwavinfo' via a simple .bat file. For the command to work, it requires an "--info" switch after the bwavinfo command, and before the input/output filenames (i.e. bwavinfo --info in.wav >in.txt). I have a working batch file which will do this outside of watchdirectory using the above script, though when i try and run it via watchdirectory, i'm met with a 'bwavinfo is not reconized as an internal or external command' message.

Here's my WD batch file:

bwavinfo --info "%WD_FILE%" >"N:\%WD_FILE_B%.wav.txt"

bwavinfo relies on Ruby and Java to run, but has been installed correctly, and works fine via a command prompt. Where am I going wrong?!

Adam.

A

Adam,

bwavinfo --info "%WD_FILE%" >"N:\%WD_FILE_B%.wav.txt"

May I suggest to you to always use full path-names in batch scripts. Something like this:

"C:\Program Files\bwa\bwavinfo.exe" --info "%WD_FILE%" >"N:\%WD_FILE_B%.wav.txt"

That way, the bwainfo program can be found no matter how your PATH is setup.

Also, redirecting to "N:\...."... it looks like N: is a mapped network drive? Remember that these drive-mapping will not work if you run this WD task as a service. It is probably a better way to use the UNC name of the drive-mapping, something like

"C:\Program Files\bwa\bwavinfo.exe" --info "%WD_FILE%" >"\\Server\share\%WD_FILE_B%.wav.txt"

Finally, for the Ruby & Java issue, you also need to remember that the environment (among other things the PATH setting) may be different for Windows Services. You could temporarily change the PATH in your batch-script yourself, to work-around this, something like

 
SET PATH=C:\Program Files\Java\jre1.6.0\bin;%PATH%
SET PATH=C:\Program Files\RoR\Bin;%PATH%
"C:\Program Files\bwa\bwavinfo.exe" --info "%WD_FILE%" >"\\Server\share\%WD_FILE_B%.wav.txt" 

Further reading

All those WD_ variables you can use in your batch files...

Friday, 10 April 2009

Q&A - Clear the email queue

Q&A

Flyinglow on our Forum asks:

Q

I have Watch Directory installed on a Management server. It watches directories on a database server. The database server crashed and had to be rebuilt on a new machine. All the files were copied over via a backup. I went into the Watch Directory jobs and just changed the server name for all the directories it was watching as we recreated the folder structure exactly.

When I started the jobs Watch Directory viewed all the files in the folder as new or changed and started sending out mass emails. I turned off all the jobs to stop it. Now when I turn on the System.Mail job it keeps sending out more messages even though all the other jobs are still turned off.

Is there any way to clear the queue for System.Mail? I already went into all the jobs and turned off the missed events option but I haven't turned any of them back on since I can't start System.Mail without flooding my email server.

A

When a WatchDirectory task sends email, the email message is only prepared: it is written to a directory monitored by the System.Mail task (the wdPostman program). When System.Mail detects the new message in this directory, it is read and sent.

If, for some reason, you want to clear this email queue, you should remove all files in the following directory:

C:\ProgramData\watchDirectory\System.Mail\Out

The directory above is the default location on Windows Vista.
You open the "System.Mail\Out" directory by right-clicking the System.Mail task and select the "Explore ..." menu option. Alternatively, select "Tools -> Explore Task Directory" (this opens C:\ProgramData\watchDirectory) and navigate to the System.Mail\Out sub-folder.

The directory contains files with a wdmail extension. These are the actual email messages waiting to be sent by System.Mail/wdPostman. If you have WatchDirectory tasks that are set to "Combine" email messages, you will also find files with a wdmailcombine extension in this directory. Delete these as well.