How to identify terminal server session in a log in script.

Hi fellow Experts!

I wonder if someone can help me with this.

I am managing Terminal Server in the Windows 2000 Domain.
I have users who sometimes log in to Windows 2000 Domain via Terminal Server. All users have a login script assign to them, but Terminal server users shouldn't execute most of the commands in the script. I would like to be able in the beginning of the script to find out if a user is coming via Terminal Server session and exit the script. If user is a "normal" user all script commands should be executed.

Thanks!
mkoganovAsked:
Who is Participating?
 
mscheurerConnect With a Mentor Commented:
check the variable %SESSIONNAME%. The variable is set when you log on via Terminal Services. Otherwise it is undefined.

Example:
if not %SESSIONNAME%. == . exit




0
 
darrenburkeCommented:
what is you logon script?  Are you using KIX, VBS or just a .BAT file.  There are lots of ways to do this but need to know your scripting format.
0
 
mkoganovAuthor Commented:
This is just a *.bat file.
0
Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

 
mkoganovAuthor Commented:
This is just a *.bat file.
0
 
LongbowCommented:
Hi,
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\ProductOptions\ProductType=?

use resource kit tool or any script to read this keyname so you know wich OS is running then add the condition to the script

Longbow
0
 
darrenburkeCommented:
an easier option is to check the value of %COMPUTERNAME%, this will be the terminal server name.
0
 
mkoganovAuthor Commented:
No Longbow, that is not going to work in all the cases.
When the user is participating in terminal session on Windows 2000 Terminal Server his/her ProductType is ServerNT, when the same user is logging from Windows NT 4.0 Server his/her Product Type is ... ServerNT as well.
0
 
mkoganovAuthor Commented:
yes, %COMPUTERNAME% would probably work, with the exception when I am logging into Terminal Server locally.
0
 
LongbowCommented:
Use any difference found in the Terminal Server.
These are surely specific registry keys.
If the difference is found the script may stop.

Longbow
0
 
matt023Commented:
how about creating a blank file with, let say, a name called "terminal.txt" in c: of the terminal server.

at the beginning of the script, include:

if exist c:\terminal.txt goto end

and toward the end of the file, include:

: end

call the file whatever you wish and put it where ever you want on the terminal server.

a tag file method..
0
 
mkoganovAuthor Commented:
Yes, %SESSIONNAME% variable is what I was actually looking for.

It is undefined if not in terminal session, it is equal =
Console if physically locally working at Terminal Server and it has some value if going via Terminal session.

Thanks to all contributors and points to mscheurer.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.