Is library running on Citrix or Terminal Server? - Testing on existence/value of environment variable SESSIONNAME - Solution

Doug Easterbrook doug at artsman.com
Sat Jan 27 10:27:43 EST 2018


hi Bub (and Phil)


interesting — so it seems bout personalization and multi use of the same exe.


we had that kind of issue years ago until  we embraced the firstruninstall folder — and all of our concerns went away.


I use two other features of omnis to save preferences into the person’s own data directory (since they have to have one in terminal server for each login).


this gets me the directory of the localappdata folder and specified by windows environment variables (which may, or may not be where you think it is — but this always gets it).

Calculate PersonalDir as getenv('LOCALAPPDATA’)

and I make my own folder in there to store anything we want — as per windows guidelines
Calculate PreferencesFolder as con(PersonalDir,sys(9),'TheatreManager')




and if I want to know where Studio put my library files from the ‘firstRunInstall’ folder


sys(115) does the trick — which gets the pathname of the omnis writeable files, including any config stuff

eg.
Do FileOps.$splitpathname(sys(115),Disk,Path,Filename,Extension) Returns ErrorCode





with those two things — my preferences are always in the right place and I just let omnis do the heavy lifting.


it means that our app works on terminal server, citrix and even when multiple people log into the same common workstation






the firstruninstall also works on macs …     but the env variable is found using

Calculate personalDirectory as getenv('HOME')


so the code/approach is all cross platform.





Doug Easterbrook
Arts Management Systems Ltd.
mailto:doug at artsman.com
http://www.artsman.com
Phone (403) 650-1978




see you at the third annual users conference
https://tickets.proctors.org/TheatreManager/95/online?performance=29086 <https://tickets.proctors.org/TheatreManager/95/online?performance=29086>

> On Jan 27, 2018, at 7:41 AM, bub <buppeke at gmail.com> wrote:
> 
> Hi Dough,
> 
> We have some personal settings that are saved as txt file in the
> application folder.  This folder is shared on Terminal Server so settings
> are less personal to say the least.  Even if i move my settings file to a
> 'home directory', i have issues as they make a kind of group login for
> Terminal Server and further user login is through my app.  I am currently
> looking into this, i don't know if i can insist with the hosting guys that
> all login is 100% individual
> 
> All the best
> Bruno
> 
> On Jan 27, 2018 1:25 PM, "Doug Easterbrook" <doug at artsman.com> wrote:
> 
> hi Phil/Bruno…
> 
> Just out of interest……  what reasons make you want to know if you are
> running on terminal services???
> 
> 
> A number of our customers run under terminal services — and we have had no
> reason in the past to want to know.   so the underlying purpose is of
> interest to me — in case I should want to know :)
> 
> thanks in advance.
> 
> 
> 
> Doug Easterbrook
> Arts Management Systems Ltd.
> mailto:doug at artsman.com
> http://www.artsman.com
> Phone (403) 650-1978
> 
> 
> 
> 
> see you at the third annual users conference
> https://tickets.proctors.org/TheatreManager/95/online?performance=29086 <
> https://tickets.proctors.org/TheatreManager/95/online?performance=29086>
> 
>> On Jan 27, 2018, at 4:45 AM, Phil (OmnisList) via omnisdev-en <
> omnisdev-en at lists.omnis-dev.com> wrote:
>> 
>> Hi Bruno,
>> 
>> I had this code lingering, not used recently:
>> 
>> Register DLL ('user32','GetSystemMetrics','AJ')      ;; jf - 21 aug 03 --
> detect if running under Terminal Server
>> Call DLL ('user32','GetSystemMetrics',4096) Returns
> lbUsingTerminalServices     ;; 4096 = SM_REMOTESESSION
>> 
>> May help you... or point you in a different direction...
>> 
>> regards
>> Phil Potter
>> Based in Chester in the UK.
>> 
>> On 26/01/2018 15:40, bub wrote:
>>> Hey all,
>>> 
>>> I would love to find out if my library is running on Citrix or Terminal
> Server.
>>> 
>>> Apparently, the environment variable SESSIONNAME is only defined on
> Citrix or Terminal Server so that would be a way to find it out, even more
> specific
>>> 
>>> Citrix client => SESSIONNAME starts with ICA
>>> Rdp client => SESSIONNAME starts with rdp
>>> Console session => SESSIONNAME starts with console
>>> 
>>> Is there any DLL that can provide the value of an envirnoment variable
> like SESSIONNAME?
>>> 
>>> Ok, just did some more effort in scrolling through historic posts and
> found similar construction to get username (which i changed now to
> sessionname)
>>> 
>>> Register DLL ('kernel32','GetEnvironmentVariableA','ICCM')
>>> Call DLL ('kernel32','GetEnvironmentVariableA','
> SESSIONNAME',%%SESSIONNAME,255)
>>> 
>>> So solution found, happy to share, might me be interesting for some
>>> 
>>> Bruno.
>>> 
>>> 
>>> 
>>> 
>>> 
>>> ---
>>> This email has been checked for viruses by Avast antivirus software.
>>> https://www.avast.com/antivirus
>>> 
>>> _____________________________________________________________
>>> Manage your list subscriptions at http://lists.omnis-dev.com
>>> 
>> _____________________________________________________________
>> Manage your list subscriptions at http://lists.omnis-dev.com
> 
> 
> _____________________________________________________________
> Manage your list subscriptions at http://lists.omnis-dev.com
> _____________________________________________________________
> Manage your list subscriptions at http://lists.omnis-dev.com



More information about the omnisdev-en mailing list