Re: How to make sure a Service starts BEFORE a user logs on?

From: Ray Trent (ratrent_at_nospam.nospam)
Date: 05/27/05


Date: Fri, 27 May 2005 13:47:00 -0700

Yes, there are tons of better ways to determine that the machine has
just booted. Probably the easiest really reliable way is to write a
non-unloadable kernel driver that starts during boot. Its DriverEntry
routine will be called exactly.

If you need a service, another poster suggested just using the start of
the service as a flag for this. That works too and is probably even
easier if you already have a service that does something you want it to
do. Services aren't normally restarted, and you can prevent that with
access controls if you're worried about a non-administrator restarting
it. If you're worried about an admin restarting your service, well,
there's not a lot you can do about that in the general case, so don't try.

BTW, detecting a "reboot" (as in a warm boot vs. a cold boot) is
somewhat harder (and a lot harder if not impossible if it has to
determine this with 100% reliability), but it doesn't sound like that's
what you're trying to do.

In any event, the "logged on user count" can be 1 in a large number of
circumstances, so I wouldn't use this as a key for anything.

Polaris wrote:
> Thanks for the info.
>
> Within the service program, I need to "detect" the event that the machine
> has JUST rebooted. So I look for (each second) the change of logged on user
> count: right after reboot, the logged on user count should be one (which is
> the "System" account, assuming the service starts before any user has logged
> on the machine). After the user logs on the machine, the service will notice
> that the user count increased to 2 and get a "conclution" that the machine
> must have JUST been rebooted. It works fine as long as the user did not log
> on to the machine before the service starts.
>
> May be there is other way to detect a reboot event?
>
> Polaris
>
> "Ray Trent" <ratrent@nospam.nospam> wrote in message
> news:OHb4mguYFHA.2160@TK2MSFTNGP10.phx.gbl...
>
>>Services can, of course, take an arbitrary and unpredictable amount of
>>time to "start up". Off the top of my head, the only way I can think of to
>>do what you want here would be to write a GINA and synchronize its passing
>>on of credentials with completion of your service startup.
>>
>>Ugly job, and nasty if there turns out to be a bug in your code :-).
>>
>>Why does your service need to run before a user logs on? This sounds
>>suspiciously like you're asking the wrong question.
>>
>>Polaris wrote:
>>
>>>Hi:
>>>
>>>I have a regular Windows Service program (not a kernel driver) which must
>>>start BEFORE a user logs into his machine (XP or W2K). It works most of
>>>the time, but sometimes, I noticed that it started AFTER I log on the
>>>machine; especially if I logged in the machine fast right after a reboot.
>>>
>>>Is there a way in the service program, I can do something to make sure
>>>that, after reboot, the service starts before a user logs in the machine
>>>(no matter how fast the user is trying to complete his logon process)?
>>>
>>>Thanks In Advance !
>>>Polaris
>>
>>--
>>../ray\..
>
>
>

-- 
../ray\..


Relevant Pages

  • Re: Paused? I dont have no stinking time for pausing!
    ... > I am not sure what you mean by restarted in your original post? ... I would reboot your server to see if this clears the ... Well, restarted means just that, stopping and restarting all the services in ... >>> Looking for a SQL Server replication book? ...
    (microsoft.public.sqlserver.fulltext)
  • Re: Paused? I dont have no stinking time for pausing!
    ... I would reboot your server to see if this clears the ... >> Well, restarted means just that, stopping and restarting all the ... >>> Hilary Cotter ... >>> Looking for a SQL Server replication book? ...
    (microsoft.public.sqlserver.fulltext)
  • Re: [kde] How to save the desktop applets settings?
    ... saves the config, and the next time it starts, it uses the saved config. ... The problem is that when I reboot the computer it will restart again ... mode) without X. Shutting down KDE, or all of X, is therefore not the ... you're restarting the KDE user session and thus the KDE ...
    (KDE)
  • Re: Printers Disappear from computer. networked and local
    ... the print spooler service on your machine has stopped. ... it again or just restarting the service without a reboot is sufficient. ... Most spooler failures are caused by faulty or corrupted print drivers. ...
    (microsoft.public.windows.vista.print_fax_scan)
  • Re: SSH, remote X-applications and 9.1
    ... Restarting the X server (done via kdm at the login window) was not enough (I ... I did try a reboot before, but apparently something else was different ...
    (alt.os.linux.suse)