Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Getting the client name
Message
From
18/04/2015 12:56:33
 
 
To
18/04/2015 03:48:15
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows Server 2012
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01618480
Message ID:
01618677
Views:
38
>>Hi All
>>
>>Running an app under terminal services / remote desktop and if I use the Windows Remote desktop Services Manager and look at a logged in user I can see various info about the user such as their log in name but also the "client name" which appears to be the name of the computer that the user is using. For an example see the screenshot attached. Does anyone know an API routine to get that info from within a VFP program?
>
>
>Just as an FYI for anyone interested The solution is incredibly simply and does not require accessing any API. You can retrieve the users computer name under a terminal services session simply using Windows Scripting Host in 2 lines ("doh!"):
>
>
>objShell = CreateObject("WScript.Shell")
>strClient = objShell.ExpandEnvironmentStrings("%clientname%")
>? strClient
>
>
>NB: This will only return a valid client name if it is run under a terminal services session. Otherwise you get just "%clientname%".

For your information, WSH is only a wrapper around the APIs. And it's also worth noting that many companies have a policy of blocking WSH, so it's a usually better solution to use the APIs directly..
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform