andy2609
2nd July 2013, 11:33
I need to read a Windows environmental variable (%temp%) in a Baan 4GL script, in order to create a file for editing in Windows. I can already create a file for editing on a PC, where I can create a directory or where the temporary directory is already known, but I need to do this for a Citrix client setup, where each user has their own temporary folder and no permissions to create a directory. Therefore, I need the program to read the variable above, in order to allow any user to create the file successfully. Has anyone any thoughts on this?

Han Brinkman
2nd July 2013, 12:29
Did you try getenv$()?

bhushanchanda
2nd July 2013, 12:31
SERVER SIDE ENV. VARIABLES:-

string value(100)

value = getenv$("PATH") | to get the variable value of PATH


For getting the list of all the environment variables you can just use:-

set > file_name

e.g set > C:\test.txt

The file will now contain the list of Environment Variables with their value.

If you want to do this using baan 4GL, just use this function:-

run.prog("cmd /c > C:\test.txt","",RP_NOWAIT)

CLIENT SIDE ENV. VARIABLES:-

app_start("cmd /c > C:\test.txt","", "", "", "")

Then you can just read this file to get the required info.

andy2609
2nd July 2013, 12:58
Thanks guys.

Han - the 'getenv$()' function retrieves the environmental variables of the Baan O/S OK, but not of the user's client machine O/S, so it's not suitable for my needs.

Bhushanchanda - it is the process of creating a file that I want to achieve, ultimately. I did also consider the method you have proposed, but this involves creating a list file in a known location ('C:\', in your example). On the Citrix client machines, there will not necessarily be a 'C:\' - and if there is, there is no permission to create a file there. Therefore, I need to know the temporary file location (from %temp%), before creating the file there.

Essentially, there is a file on the Baan O/S that I want to copy to the client's temporary directory, allow it to be edited and copy it back. I have achieved this on a PC with no problem, but on the Citrix client, I need to know the (user-specific) temporary file location.

Thanks for your time, both.

andy2609
2nd July 2013, 13:00
Hi Bhushanchanda - it is the process of creating a file that I want to achieve, ultimately. I did also consider the method you have proposed, but this involves creating a list file in a known location ('C:\', in your example). On the Citrix client machines, there will not necessarily be a 'C:\' - and if there is, there is no permission to create a file there. Therefore, I need to know the temporary file location (from %temp%), before creating the file there.

Essentially, there is a file on the Baan O/S that I want to copy to the client's temporary directory, allow it to be edited and copy it back. I have achieved this on a PC with no problem, but on the Citrix client, I need to know the (user-specific) temporary file location.

bhushanchanda
2nd July 2013, 13:29
Searched and found this VB Script:-
Dim sh
Dim en
noWorkstation = "No Workstation"
Set sh = CreateObject("WScript.Shell")
Set en = sh.Environment("VOLATILE")
en("Citrix_Variable") = sh.ExpandEnvironmentStrings("%CLIENTNAME%")
sTemp = sh.ExpandEnvironmentStrings("%CLIENTNAME%")
set WshNetwork = CreateObject("Wscript.Network")
computername = wshNetwork.Computername
msgbox "Computer name is" computername "...And should be empty because we are looking for CLIENTNAME"
msgbox "CLIENTNAME is..." clientname

'Or if you can return the correct answer via Citrix or locally connected app
if sTemp = "%CLIENTNAME%" then
clientname = computername
end if
Referred Link (http://stackoverflow.com/questions/4566271/reading-environment-variables-using-vbscript-or-activex-on-citrix-client)

Try this. I am not sure what the infrastructure is on Citrix.

bhushanchanda
2nd July 2013, 14:25
Alernatively,

You can maintain a share folder on each client machine with a same name and you can access it using Baan 4GL.

Just get the host name using hostname$() command and then you can create your files and do the functions required. Again, I am not aware of the infra provided by Citrix.

Han Brinkman
2nd July 2013, 15:25
And create.local.file(), according to the manual you should be able to use $BSE_TMP. Not sure if that works with citrix.

Or perhaps you can use a path that uses the users loginname? E.g. the users home dir?

mark_h
2nd July 2013, 16:06
On this citrix server are they all launching the baan client from the same directory? Can you use the temp directory in that location? I know you can set a variable to be used on the server side in the .bwc file, but I do not know how to set it based off a windows variable. For example in the command line of the bwc file I can enter -set LTEMP="c:\temp". Then on our baan server I have a unix environment variable called LTEMP. Now what I do not know how to do is set it to a windows variable that could change depending on the user.

mark_h
2nd July 2013, 16:15
Here is the one of the threads (http://www.baanboard.com/baanboard/showthread.php?t=95&highlight=bshell+options&page=5) that talks about the bwc startup options. It links to multiple other threads. I don't know if something in there will give you a hint or clue how to solve this.

NPRao
3rd July 2013, 04:31
Here is a snippet from our code -

target = "${BSE_TMP}\" & filename & str$(utc.num())
e = server2client(fpath, target, false, true)
if e = 0 then
if flagwait <> 0 then
ret = start.application.local(target, true, exitcode)
remove.local.file(target)
else
ret = start.application.local(target, false, exitcode)
endif
if not ret then
mess("zmadms0113", 1) |* Application failed to start
endif
else
mess("zmadms0020", 1)
|* Error - source file not copied to the destination file
endif

We have Citrix VMs too and it works.

You have to give full write access to the folder (for owners, administrator & users) -

C:\Users\nprao\AppData\Local\Infor\BW\ERPLN\tmp

I think they changed the tmp path in between the versions it used to be -

C:\Program Files (x86)\Infor\BW\ERPLN\tmp

andy2609
3rd July 2013, 14:30
Hi all. Thanks for all your contributions. In the end, I solved this by trial and error and also by checking other threads:
(http://www.baanboard.com/baanboard/showthread.php?t=7329&highlight=temp+path)

The solution is ridiculously simple. The client temporary variable '%TEMP% is resolved automatically in the Baan 'server2client' function - something which I originally looked at, but the syntax has to be as below:
ret = server2client(baan.server.path.and.filename, "${TEMP}\" & filename.to.create.in.client.temp.folder, false, false).

This creates a copy of the file that originates on the Baan O/S in the temporary directory of any user that opens it, irrespective of the location of that directory. (I then used 'app_start', enabling editing and 'client2server' to copy it back to the Baan O/S.)

Thanks again!

baanhp
24th July 2013, 16:18
Thanks a lot
I was stuk at a point and ur code snippet helped a lot


thanks a lot

andy2609
25th July 2013, 12:20
Glad you found this useful.

BaanInOhio
26th July 2013, 16:40
Don't know if the original poster was using LN or not, but I have encountered issues when using "${TEMP}" in LN. It operated as expected from the menu browser, but webUI appears to change the "$(TEMP}" to a java-related location, even though the environment variable that LN can read still referred to the non-webUI location. I haven't tried it on the lastest webUI yet, but versions from late 2012 had this issue.