WatchDirectory home page
WatchDirectory Startseite (Deutsche Version)
Site WatchDirectory (Français)
  Welcome, Guest. Please Login or Register
YaBB - Yet another Bulletin Board
Page Index Toggle Pages: 1
Bug in Batch file execution (Read 2307 times)
YaBB Newbies

Posts: 28
Bug in Batch file execution
May 21st, 2008 at 9:19am
We have created a proces that starts a batch file that is working ok however the batch file behaves diffrent in watchdirectory then via a normal command line or via windows scheduler. We call a rar.exe to rar certain files however when used in watchdirectory it skips certain commands. In our opionon this shouldn't happen. The Batch file should just be started when triggerd and run the same a windows scheduler or a command line.

If requested I can give a piece of sample code so you can test it for yourself.
Back to top
IP Logged
YaBB Administrator

Posts: 2260
The Netherlands
Re: Bug in Batch file execution
Reply #1 - May 21st, 2008 at 9:32am
Hello Youri,

Make sure that your batch file....

Uses full paths for everything:
If you have something like
rar.exe bla bla bla 

you are depending on the correct setting of the PATH variable for Windows to find the rar.exe program. This PATH setting depends on the current user (typically a problem when you run as a service). Make sure to enter program paths like this
"C:\Program Files\WinRar\rar.exe" bla bla bla 

The same can be said for the files you work on. Always code your batch file as if the current directory is completely random. When WD starts your batch file the current directory is not guaranteed (again, it depends on the user/service).
So if you have something like
COPY %WD_FILE_N% C:\OtherDir 

You are working on the assumption that the detected new file (%WD_FILE_N% = just the filename, for example NewFile.txt) is in the current directory. Please use this instead:
COPY "%WD_FILE%" "C:\OtherDir" 

Also, always surround all filenames in "quotes" as you never know if they contain spaces (see for an explanation).


Back to top

Gert Rijs - gert (at) gdpsoftware (dot) com
End Alzheimer's:
WWW WWW GdPSoftware  
IP Logged
Page Index Toggle Pages: 1