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
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
You could use the Terminal Services Manager. You'll find
it under the server's Admin Tools.
See if this helps:
http://dev.remotenetworktechnology.c.../lib/tslib.htm
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.
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
Try query.exe (on the TS server):
C:\>query
Invalid parameter(s)
QUERY { FARM | PROCESS | SERVER | SESSION | TERMSERVER | USER }
C:\>query session
SESSIONNAME USERNAME ID STATE TYPE DEVICE
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".
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"
WScript.Quit
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.
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?
Bookmarks