Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting Info from Terminal Services.

Status
Not open for further replies.

klander2k

Programmer
May 5, 2003
14
0
0
US
Hello all,

Just a question, Does anyone know how to retreive information from Terminal Services using VFP. What I am looking for is either the Machine Name of the session or the Session # itself.

Any information would be helpful.

Thanks
Keith

Thanks

Keith Lander
klander@prosofttech.com
 
I dun know if this help you :

GETENV('Clientname')

Above command is to retrieve the Client's PC name.

rgds
 
we have users logging in to an application locally from workstations and remotely using terminal services.

to identify terminal services sessions we use

Code:
upper(left(getenv("sessionname"),3)) = "RDP"

works for us [smile]

Pete Bloomfield
Down Under
 
Thanks

I think the GetEnv("ClientName") will work fine.

Just out of curiosity, is there a function that will return the Terminal Server Session ID. Not the Session Name, but the ID itself?

Thanks again.
Keith

Thanks

Keith Lander
klander@prosofttech.com
 
Keith

we couldn't find an environment variable that just returns the session ID, which is what we were after also.

i don't have a terminal services session available to me to test the following, so apologies if i am off the mark, but try

Code:
if not empty(getenv("sessionname")
     answer = right(getenv("sessionname"),1)
else
     answer = 'no session ID available'
endif

?answer

this should work if you have less that 10 TS sessions, otherwise you could modify it a bit if you had more than 10 TS sessions.


Pete Bloomfield
Down Under
 
Thanks.

I could not find a way to get the session ID either.

BUT....

The whole reason for doing this is to limit the printers to only printers that are part of your current session. By using the two following commands:

GETENV("ClientName") (which returns the Client Machine Name)
SET("printer",2) (which returns the default printer, which holds the session ID)

you can check the default printer for the "ClientName" and then from the default printer use the following:

substr(dp, at("/SESSION", u(a(dp)),1)+1) (which returns "SESSION ##")

to get the session ID. The problem with this is a timing issue with the way terminal services loads the printers. Sometimes you will have a default printer that is correct(90%), sometimes you get a default printer that is incorrect(5%), and sometimes you do not have a default printer at all(5%).

Anyway, thanks for all of you help. You alteast got me to 90% from 0%.

Thanks

Keith Lander
klander@prosofttech.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top