WatchDirectory Forum
http://www.watchdirectory.net/cgi-bin/yabb25/YaBB.pl
watchDirectory forums >> Plugins >> WD_INSTDIR Environmental Variable
http://www.watchdirectory.net/cgi-bin/yabb25/YaBB.pl?num=1422388406

Message started by Verne on Jan 27th, 2015 at 8:53pm

Title: WD_INSTDIR Environmental Variable
Post by Verne on Jan 27th, 2015 at 8:53pm
I am using the Run Any .Bat file plugin and the WD_INSTDIR Environmental Variable is not expanding to the install path of Watch Directory.  It outputs blank in the batch file.

Title: Re: WD_INSTDIR Environmental Variable
Post by Verne on Jan 27th, 2015 at 9:03pm
If I use the Start Any Program plugin and tell it to run CMD.EXE and pass these arguments (/C mybatfile.bat) to cmd.exe then the variable expands to the install path of Watch Directory.

Using WD 4.8.8 on Windows 2008 server.

Title: Re: WD_INSTDIR Environmental Variable
Post by Verne on Jan 27th, 2015 at 9:12pm
just testing with a simple batch file

Code (]echo off

ECHO WD BASE FILE NAME: %WD_FILE_N%

ECHO WD FILE is: %WD_FILE%

ECHO WD INSTALL PATH: %WD_INSTDIR%

pause[/code):

Output using Run Any Bat file.
[code]
C:\Windows\System32>GOTO :StartOfBat
annotate not available when not waiting for .bat file info "Starting E:\BatchFil
es\DELBatchTest.bat for event"

C:\Windows\System32>Call "E:\BatchFiles\DELBatchTest.bat" FILENEW
WD BASE FILE NAME: asdfasdfasdf.txt
WD FILE is: E:\JOSHTEST\asdfasdfasdf.txt
WD INSTALL PATH:
Press any key to continue . . .


Output using Start Any Program
[code]WD BASE FILE NAME: asdfasd.txt
WD FILE is: E:\JOSHTEST\asdfasd.txt
WD INSTALL PATH: C:\Program Files (x86)\watchDirectory
Press any key to continue . . .[/code]

Title: Re: WD_INSTDIR Environmental Variable
Post by Gert on Jan 28th, 2015 at 9:24am
Thanks for reporting that Verne. I will have a look at the code and fix this for the next release.

Title: Re: WD_INSTDIR Environmental Variable
Post by Verne on Jan 29th, 2015 at 12:19am
I hope that is soon.  I am being forced to migrate to Windows 2008 server from 2003 server.  We use WDrun.exe in a lot of batch files to stop and start other tasks.  Mostly Quiet tasks that wait for output from another job that was launched from WD.

Lucky for me my predecessor hard coded the path to WD in all the batch files.  Otherwise that would have been a big problem for our current production.  But it is still a problem as now I have to go a change a couple dozen batch files to the (x86) Program Files path when we move these two servers to Windows 2008.

Title: Re: WD_INSTDIR Environmental Variable
Post by Gert on Jan 29th, 2015 at 6:32am
Hello Verne,

I have just looked at the code and see that the WD_INSTDIR variable is not set when you let the task NOT wait for the bat file to complete. This is fixed for the next release.

An easy fix you can apply now is to create a System Environment Variable named WD_INSTDIR. After a reboot this variable will be available to all scripts.

Another alternative...
Select the menu "Tools -> Explore Task Directory", this opens Explorer inside the folder where WD stores all its settings.
If there is a file present called wdglobal.bat, edit it with notepad. If it is not there, create it.
If the "run bat file" task sees this file, the following happens:
* the task sets the variable WD_REALBATFILE to the bat script configured
* the task calls wdglobal.bat, instead of the configured script
So you can do something like this:
[code]
SET WD_INSTDIR=C:\Program Files (x86)\WatchDirectory
Call "%WD_REALBATFILE%"
[/code]

Title: Re: WD_INSTDIR Environmental Variable
Post by Gert on Jan 29th, 2015 at 7:44am
and this should be fixed in this new beta:
http://www.watchdirectory.net/cgi-bin/yabb25/YaBB.pl?num=1416810194/0#1

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