Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

How to make a service start after logon ?

Posted on 2007-07-25
8
Medium Priority
?
897 Views
Last Modified: 2012-06-21
I have created a service in delphi which runs another application. The reason for this is because the application it runs needs to run as a more privileged user. The problem I am having is that the service runs and executes the application before the logon.

The question is; how can I make the service wait until a user has logged on ?
0
Comment
Question by:marhk51
  • 3
  • 3
  • 2
8 Comments
 
LVL 21

Expert Comment

by:ziolko
ID: 19564639
you can't user may never logon but all services with automatic startup must be started thats why user logon is independent from service startup.

i've seen somwhere in MSDN methods for signup for login/logoff notifications

ziolko.
0
 

Author Comment

by:marhk51
ID: 19564651
so is there a way I can check if there is a user logged on from within the service before launching the app ?
0
 
LVL 21

Expert Comment

by:ziolko
ID: 19564693
about notifications see here:
http://msdn2.microsoft.com/en-us/library/aa380543.aspx
but it aint easy task.

you can make your service to go in loop until someone will logon.

ziolko.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:marhk51
ID: 19564727
yes, where can I download these notification dlls and supporting documentation ?
0
 
LVL 21

Expert Comment

by:ziolko
ID: 19564788
if you know name and pass of user you want to be owner of process you might try createprocessasuser or createprocesswithlogon

ziolko
0
 
LVL 21

Accepted Solution

by:
developmentguru earned 200 total points
ID: 19565060
 I would start by trying to respond to the message WM_WTS_SESSION change.  I believe the value you would be waiting to see is WTS_CONSOLE_CONNECT.  Then fire up your application.  There are many places to find info on how to add a message method to your objects so I will not clutter this post with it.  Here is a link to the msdn info.
http://msdn2.microsoft.com/en-us/library/Aa383828.aspx

You must register to get these notification messages:
http://msdn2.microsoft.com/en-us/library/aa383841.aspx

Here is some more reading:
http://www.experts-exchange.com/Programming/Languages/Pascal/Delphi/Q_20525770.html
http://www.delphiresources.com/documentations/tips-tricks/system/how-can-i-receive-session-switch-notifications-xp/viewlink.html

Let me know if you need more info
0
 
LVL 21

Expert Comment

by:developmentguru
ID: 19565085
(Your service will start like it always has, but you can wait to start the applicatioon until a user is logged in - or delay another 30 seconds... whatever you need)
0
 

Author Comment

by:marhk51
ID: 19572671
Thanks to everyone who responded.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses
Course of the Month21 days, 1 hour left to enroll

810 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