Solved

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

Posted on 2001-08-30
11
314 Views
Last Modified: 2010-05-18
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!
0
Comment
Question by:mkoganov
  • 5
  • 2
  • 2
  • +2
11 Comments
 
LVL 4

Expert Comment

by:darrenburke
ID: 6441312
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
 

Author Comment

by:mkoganov
ID: 6441478
This is just a *.bat file.
0
 

Author Comment

by:mkoganov
ID: 6441524
This is just a *.bat file.
0
 
LVL 10

Expert Comment

by:Longbow
ID: 6441534
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
 
LVL 4

Expert Comment

by:darrenburke
ID: 6441659
an easier option is to check the value of %COMPUTERNAME%, this will be the terminal server name.
0
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

Author Comment

by:mkoganov
ID: 6441684
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
 

Author Comment

by:mkoganov
ID: 6441713
yes, %COMPUTERNAME% would probably work, with the exception when I am logging into Terminal Server locally.
0
 
LVL 10

Expert Comment

by:Longbow
ID: 6442358
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
 
LVL 5

Expert Comment

by:matt023
ID: 6443365
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
 

Accepted Solution

by:
mscheurer earned 100 total points
ID: 6444939
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
 

Author Comment

by:mkoganov
ID: 6444989
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

Featured Post

Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

Join & Write a Comment

NTFS file system has been developed by Microsoft that is widely used by Windows NT operating system and its advanced versions. It is the mostly used over FAT file system as it provides superior features like reliability, security, storage, efficienc…
What is Backup? Backup software creates one or more copies of the data on your digital devices in case your original data is lost or damaged. Different backup solutions protect different kinds of data and different combinations of devices. For e…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now