473,799 Members | 3,832 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to detect Terminal Server in VB.NET

Hi,
I need code in VB.Net to detect if the application is running on Terminal
Server.
I am using the following code. Please let me know if you see any issues in
it or if you have some better code to achieve this functionality:

Dim sTemp As String = Environment.Get EnvironmentVari able("SESSIONNA ME")
Dim IsTSSession As String
If (sTemp <> "") And (sTemp.IndexOf( "RDP-") = 0) Then
IsTSSession = True
Else
IsTSSession = False
End If

Thanks,
Hitesh
Mar 2 '06 #1
2 8582
I am using the following code. Please let me know if you see any issues in
it or if you have some better code to achieve this functionality:


In .NET 2.0 you can check
System.Windows. Forms.SystemInf ormation.Termin alServerSession . In
earlier versions you can call the GetSystemMetric s(SM_REMOTESESS ION)
API.
Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Mar 2 '06 #2
Thanks very much for replying..
But can you please let me know how to use GetSystemMetric s(SM_REMOTESESS ION)
in Vb.Net code.
Also do you see any issues in the code that I am using?...

"Mattias Sjögren" wrote:
I am using the following code. Please let me know if you see any issues in
it or if you have some better code to achieve this functionality:


In .NET 2.0 you can check
System.Windows. Forms.SystemInf ormation.Termin alServerSession . In
earlier versions you can call the GetSystemMetric s(SM_REMOTESESS ION)
API.
Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.

Mar 4 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
2743
by: OHM | last post by:
Hi peoples, I dont know where to place this question, so as I know you guys are all resourceful experts, I thought I would try here. I am writing some code which will be run usingh remote desktop ( On windows 2003 Server ), I need to determine in the code the machine name and username. If I use GetUsername and GetMachineName, it simply gives me the name of the currently logged on user ( at the Server ) and the Servers Machine Name.
2
1859
by: Kevin Hodgson | last post by:
Is there any way in a .NET App to detect if it is being run under Terminal Server? I have some functions of my program (like launching emails, and saving files) that need to be handled differently if the user is running it locally, or if they're running under Terminal Server.
6
4047
by: Atley | last post by:
I have a Terminal Services server running Windows 2000 Server. I need to be able to identify, in my application on that server, which client computer is addressing that server and running that application. it can be by IP or by machine network name... Doesn't matter. I am using Visual Basic .Net 2003 Any help would be greatly appreciated.
2
4084
by: Oenone | last post by:
Is it possible to detect whether my application is running within a Terminal Server session or not? I'd like to automatically switch off some of my graphics rendering under this environment as they can be quite slow to transfer over a terminal server session. The graphics should still be displayed when running directly on a local session. Thanks,
9
13239
by: Tim | last post by:
Hi Guys, I was wondering if there is a way to detect from with a C# app if it is being started in a remote session? i.e. someone has connected via remote desktop or terminal services... Thanks Tim
6
1816
by: Smokey Grindle | last post by:
is there any way to detect if yoru app is runnign on a terminal server in ..net? so we can slim down graphics and such for it? thanks!
2
1329
by: Robin Becker | last post by:
I'm using subprocess to carry out svn commands (probably should use the svn api package, but that's a dependency too far). Anyhow my code looks like from subprocess import Popen, PIPE p = Popen((svn,'ls',u),stdout=PIPE,stderr=PIPE) i = p.wait() and this sort of thing works well under most circumstances. However, when this code is executed for the very first time by a particular user it hangs waiting on user input.
7
3051
by: mike | last post by:
We have numerous Access 97 apps that we run on our Terminal Server, but two apps in particular is giving us a problem. The problem we are running into is when you select a drop down menu, it errors out saying the SQL server cannot be found. This is through the terminal session and when logged on the server locally. If I run the apps on my workstation they work fine. In one of the problem apps, it runs flawless except for a similar...
16
4000
by: =?Utf-8?B?RHdlZWJlcmVsbGE=?= | last post by:
I created an Access 2007 application for my customer. The application is shared by three employees on a server. It maintains a contact list including financial data and social security numbers. Only the office manager generates reports in Access from this client data. Now they want to share this Access application with employees at a remote office. They expect to have a maximum of 30 employees editing the client list in both the...
0
9687
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10488
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10237
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10029
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9077
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7567
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6808
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5588
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2941
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.