WatchDirectory Forum
watchDirectory forums >> Bug Reports >> Bug in Batch file execution

Message started by Youri on May 21st, 2008 at 9:19am

Title: Bug in Batch file execution
Post by Youri on 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.

Title: Re: Bug in Batch file execution
Post by Gert on May 21st, 2008 at 9:32am
Hello Youri,

Make sure that your batch file....

Uses full paths for everything:
If you have something like

Code (]rar.exe bla bla bla[/code):
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
[code]"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

Code (]COPY %WD_FILE_N% C:\OtherDir[/code):
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:
[code]COPY "%WD_FILE%" "C:\OtherDir"

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


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