Go Back   TechArena Community > Technical Support > Computer Help > Windows Server > Windows Server Help
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Sponsored Links

Client name terminal server

Windows Server Help

Thread Tools Search this Thread
Old 22-05-2008
Posts: n/a
Client name terminal server

Our environment is working with terminal services.
Does anybody have an example of a vbs that I can run on the client and on
the server to see the client name (or Ip adres) of the computer that is
connected to the terminal server

Reply With Quote
Old 22-05-2008
Pegasus \(MVP\)
Posts: n/a
Re: Client name terminal server

You could use the Terminal Services Manager. You'll find
it under the server's Admin Tools.
Reply With Quote
Old 22-05-2008
Shay Levi
Posts: n/a
See if this helps:


Terminal Services Manager is showing me the info I need but i want this info
from a script. Need this to help me map printers when a user logs in on an
other PC.
Reply With Quote
Old 22-05-2008
Posts: n/a
Thx but in the script :
>> Set Sh = CreateObject("WScript.Shell")
>> sys = Sh.ExpandEnvironmentStrings("%CLIENTNAME%")

the %CLIENTNAME% is showing the client name from where the user logged on to
the session, not the client where the user is connected from. Example: log on
from PC1, disconnect, reconnect from PC2. %CLIENTNAME% is showing PC1
Reply With Quote
Old 22-05-2008
Shay Levi
Posts: n/a
Try query.exe (on the TS server):


Invalid parameter(s)

C:\>query session

console administrator 0 Active wdcon
rdp-tcp 65536 Listen rdpwd
ica-tcp 65537 Listen wdica
ica-tcp#412 user2 6 Active wdica
ica-tcp#464 user3 15 Active wdica
ica-tcp#475 user4 21 Active wdica
ica-tcp#528 user5 2 Active wdica
ica-tcp#531 user6 4 Active wdica
ica-tcp#537 user7 3 Active wdica
ica-tcp#542 user8 9 Active wdica
ica-tcp#545 user9 1 Active wdica
ica-tcp#546 user10 8 Active wdica
ica-tcp#547 user11 11 Active wdica
>rdp-tcp#548 administrator 12 Active rdpwd

how about :/>net session

Try "query.exe session".
Reply With Quote
Old 15-07-2008
Join Date: Jul 2008
Posts: 1
Map client printers based on TS client name

This script will read the 4 leftmost characters of the clientname and maps a printer that matches the leftmost characters of the printername. Notice I used a "13" in the mid string for the printername because the UNC \\spooler01 is 13 characters long you will have to adjust this value based on your names. It will also log an event.

PS. If you get up and change locations and disconnect without logging off the session, when you sit down at the new location it will not remap printers you must logoff and log back in to work.

Dim LeftString, netPrinter, UNCpath, Midstring
Set Sh = CreateObject("WScript.Shell")
sys = Sh.ExpandEnvironmentStrings("%CLIENTNAME%")
User = CreateObject("WScript.Network").Username
Sh.LogEvent 4, "Logon by " & User & " from " & sys
LeftString = Left(sys, 4)
WScript.echo leftstring
if leftstring = "yourclientcomputersname" then
UNCpath = "\\spooler01\theprinteryouwanttomap"
Set netPrinter = CreateObject("WScript.Network")
netPrinter.AddWindowsPrinterConnection UNCpath
WScript.Echo "Your printer is mapped from : " & UNCpath
end if
Midstring = Mid(UNCpath,13,4)
Wscript.echo Midstring
Wscript.echo "If you have changed location since starting this session Please Logoff and Logon again for correct devices and printers"

replace yourclientcomputersname with the client name you want to map the corresponding printer
replace \\spooler01\theprinteryouwanttomap with the UNC of your spooler and printer.
Remove all Wscript.echo commands if you dont want to see dialog boxes
this will also log events for you look at your event viewer to see messages.
Delete this paragraph when running this script.
Reply With Quote
Old 30-01-2010
Join Date: Jan 2010
Posts: 2
Re: Client name terminal server

This looks like something that I can use in my login script to determine if the %computername% is from this office or another office I manage.
The naming convention of the pc's start with the letters of the state.
LA, SF, NY, SE, MO, TX, etc.
How would I tweak it to read the computername and then determine based on the first 2 characters whether to continue the script or GOTOEND?
Reply With Quote

  TechArena Community > Technical Support > Computer Help > Windows Server > Windows Server Help
Tags: , , , , ,

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Similar Threads for: "Client name terminal server"
Thread Thread Starter Forum Replies Last Post
No Terminal Server Client access licenses available...Error -Wamil- Operating Systems 5 19-10-2010 06:50 AM
How to Migrate user Profiles from 2003 Terminal Server 32bit to 2008 Terminal Server 64bit Zweena Operating Systems 5 22-08-2010 02:39 AM
install a xp pro terminal server with windows server 2003 server rossen Operating Systems 3 13-03-2009 05:12 PM
Linux Terminal Client Greger Operating Systems 2 16-02-2009 03:22 PM
RWW - Terminal Services Active X Web Client iShree Small Business Server 3 09-08-2007 11:44 PM

All times are GMT +5.5. The time now is 12:12 PM.