473,725 Members | 2,246 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Logged on desktop user?

GTi
Is there any way I can find out if there is any user logged on the
desktop from a service?

Jan 4 '06 #1
4 2113
GTi,

Yes, but you shouldn't do this. First, there might not be a logged in
user, and second, there may be multiple logged in users.

What you want to do is have your service expose a remoting endpoint, and
then have a program that runs in the client space which connects to the
service and passes/gets the appropriate information.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"GTi" <tu****@gmail.c om> wrote in message
news:11******** ************@g4 4g2000cwa.googl egroups.com...
Is there any way I can find out if there is any user logged on the
desktop from a service?

Jan 4 '06 #2
GTi

Nicholas Paldino [.NET/C# MVP] wrote:
GTi,

Yes, but you shouldn't do this. First, there might not be a logged in
user, and second, there may be multiple logged in users.

What you want to do is have your service expose a remoting endpoint, and
then have a program that runs in the client space which connects to the
service and passes/gets the appropriate information.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"GTi" <tu****@gmail.c om> wrote in message
news:11******** ************@g4 4g2000cwa.googl egroups.com...
Is there any way I can find out if there is any user logged on the
desktop from a service?


Nicholas,
Yeah - after walking round the blocks a while I ended with the same
conclusion.
Since my NT Service application is almost always depended on other
programs that only can run on the users desktop, I will change my
program to do the same as a icon by the clock.
(Note to me self: how do I do that?)

Jan 4 '06 #3
GTi wrote:
Yeah - after walking round the blocks a while I ended with the same
conclusion.
Since my NT Service application is almost always depended on other
programs that only can run on the users desktop, I will change my
program to do the same as a icon by the clock.
(Note to me self: how do I do that?)


If you do a google search for "system tray C#" you'll find lots of
hits, including
http://www.developer.com/net/csharp/article.php/3336751

Jon

Jan 4 '06 #4

"GTi" <tu****@gmail.c om> wrote in message
news:11******** ************@g4 4g2000cwa.googl egroups.com...
Is there any way I can find out if there is any user logged on the
desktop from a service?


Yep, using System.Manageme nt classes.

...

ManagementScope msc = new ManagementScope ("root\\cimv2") ;
// get the number of interactive logons (logontype = 2)
string queryString = "select LogonId from win32_logonsess ion where
logontype = 2";
using(Managemen tObjectSearcher query = new ManagementObjec tSearcher(msc,
new SelectQuery(que ryString)))
{
if (query.Get().Co unt == 0) // 0 = no interactive user logon
...
else
...
}

Willy.
Jan 4 '06 #5

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

Similar topics

2
4568
by: RickPowell | last post by:
I wrote a VB .NET Service to restart the computer when certain business rules are triggered (such as not being rebooted in x days, no users logged on, time is 1-3 am, etc.). I am currently using a sloppy technique of checking the Registry to determine if and who is logged on. I would like to use a Microsoft sanctioned best-practice method of determining if anyone is logged on (and their Username and all Process Names that the User is...
0
364
by: gswitz | last post by:
I have written a Windows Service that watches a Lotus Notes InBox for emails, detaches attachments from the emails and attaches them to a different Lotus Notes Database. The service works properly until I log off of the server. At that point, this call begins returning nothing - not an error - just nothing... LnView_Mail = LnDb_Mail.GetView("($InBox)") Once this problem begins, logging back into the server does not resolve it.
0
4289
by: John Whitmer | last post by:
I am trying to put together a web page to show remote users which PC's are available for RDP so they can use. The page work's fine except for when the goes to the pc to pull the info on if anybody is logged in or not it seems to have trouble. here is the blurb from the temp file that gets created on the webserver. "Error opening Terminal server Computer-01 Error :Access is denied." The webserver Anon account is using a Domain account that...
2
2102
by: Vaj | last post by:
hi, i would be very thankful if u can help me in solving this problem. my problem is i 've a page in that i'm displaying the creation dates of all files. these dates are like server dates . now i've to display these creationdates in the current logged in user desktop timezone. thanks
1
1051
by: Philip Carnstam | last post by:
Hi, I know I've seen this thread around here somewhere before, but I can't seem to find it, so I'm asking the question anew. When trying to connect to my Terminal Server (Windows 2003) I get logged out before I have even seen the desktop. I log in and the dialog for personal settings shows up and is immidiately followed by "logging out" and "saving your settings".
40
2984
by: Jeff | last post by:
I have a system on a network and want to determine if anyone is currently connected to the back-end files. An interesting twist is that I have noticed that some users can be connected (have the front end open at the first form) and even though this links to the back-end files, there are no ldb files created. This is so I know when it is safe to compact the back-end files without going round to make sure everyone is logged off. User...
1
1126
by: Carl Woodward | last post by:
Dear all, I am writing an that performs automatic updates for one of our products. In order to ensure that the app can update \Program Files\Xxxx and SystemRoot\Drivers and use MoveFileEx to update in use files on reboot, we need to be running at Admin or Local System. So, we are planning to create a service to do this. ..NET makes the whole process very simple, but, how do we interact with the currently logged on user? Specifically,...
0
1473
by: nrworld | last post by:
Hi, I have a requirement to find the users logged in to a XP system using a C# service which is running as SYSTEM service. An additional requirement is to start an application on the Active Desktop users as that user. The application should be spawned by the service, is this possible if the user account is password protected and The service doesn't know the password of that user ?? Please help.
15
2702
by: paul814 | last post by:
Is it possible to display the logged in user that is accessing the form, in a textbox? so say I have txtname I want to display the username of the person that is logged in to the PC in that box, can I do this? How would this be done?
0
8882
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
8749
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9398
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
9165
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
9098
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...
1
6699
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
4507
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3216
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2627
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.