Windows XP launch visible program before logon

Posted on 2009-04-10
Last Modified: 2012-05-06
Hello Experts -

I looking for general guidance here as well as whatever other help anyone can supply, I'm going to supply probably more information than you want because I'm not sure what exactly is significant:

I have written two programs in, a monitoring process which looks for a cookie and an interactive keyboard which the monitoring process launches when it detects the cookie.  The process works fine on XP when the monitoring program is running - for instance, if I drop the monitoring program in startup for all users.

However, the box on which I need to run this setup normally does not logon - it start services which (I'm guessing) launch the interactive programs, which is some sort of program hosting an embedded explorer window.  If I start task manager i can see the logon window process "waiting" as well as other programs under the System User.

I would like to launch the monitoring process as a service as well, and have it display my interactive keyboard in the viewable "instance", or viewport, or whatever that the explorer type program is in... but I can't figure out what that might be since nobody is logged in.  

Am I on the right track trying to do this as a service?  I have written services before but haven't dealt with this type of scenario.  I have been messing around with CreateProcessAsUser but there seems to be the need for a logged on user for this to work?  I have researched this somewhat but am in a little over my head here.

Thanks for any help and your patience with my explanation.  I will supply any particulars that might be useful.
Question by:LawlessOne
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
LVL 15

Expert Comment

ID: 24116060
As far as I'm aware, the login dialog is the only gui allowed to exist before loging on. The (now mostly unused) Ctrl+Alt+Delete before login was there for exactly that reason: Only windows is allowed to capture Ctrl+Alt+Delete, so by forcing a user to hold that combination of keys meant that if the dialog displaying the prompt was replaced with login dialog, the user could be sure that it was legitimate.

I can't imagine any modern OS allowing user input before authentication.

I'm afraid what you're asking for sounds disturbingly like a keylogger or a fake login dialog.

If you really need to be able to monitor the machine while it's not logged in, then I'd suggest creating something like a webservice that you can poll for the required data.

Author Comment

ID: 24116167
oobayly, For what it is worth, I assure you I'm not trying to do anything like keylogging or a make a fake login dialog.  No keyboard is attached to these boxes and nobody logs into them normally - they are XP boxes that launch services which spawn process on the screen that a user can interact with.

What I'm trying to do is present a virtual keyboard on a touch screen.  To do that I'm popping the keyboard when requested from a monitoring process, which I would normally put in Startup, but Startup programs don't run on this setup normally - there is a process launched that puts some sort of embedded internet explorer type program on screen, like IE in kiosk mode but embedded in some kind of other window.
LVL 15

Expert Comment

ID: 24117402
That makes it much clearer. I'n a little bit incredulous that the apps are running with a gui while no user has been logged in, but anyhow.
I'm afraid I can't offer any advice as to your question

The only way I can see this settup running is like some of those supermarket self scan kiosks you get. XP is configured to login automatically, and then the app runs full screen, hooking low-level keyboard events so that focus can't be taken from it.
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users


Author Comment

ID: 24118098
Thanks for trying anyway.

Unfortunately for me it does not do an auto login (and it would cause headaches for me to switch the box to this), because then I would be able to use the startup to run my monitor.  

Accepted Solution

JMoon5FTM earned 500 total points
ID: 24174822
If you're familiar with building service applications, then this shouldn't be too difficult.

This isn't supported by Microsoft, but here's the gist of what you need to do.

NOTE:  I've only tried this on Windows XP.  I'm pretty sure it should work in 2000 as well.  I have no idea whether this needs modifying for Windows Vista.

Your service must be marked as "interactive", and set to run as the LocalSystem user.  This is required in order for Windows to give you permission to do UI stuff from a service.  This can't be set from within Visual Studio using the configuration stuff Microsoft gives you.  In theory you could extend ServiceInstaller to support this, but that's a bunch of extra work I haven't done yet.  So let's go ahead and install it the Microsoft-sanctioned way, and then use RegEdit to tweak the registration:

    Go to HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\YourServiceName.
    Ensure that ObjectName is set to "LocalSystem".
    Change Type from 0x10 to 0x110 or from 0x20 to 0x120.

Since we're editing the registry instead of using the API, you will need to restart your computer for these changes to take effect.

Now that your service has permission to do UI... well the road forks depending on whether you're trying to show that UI directly from the service or start it up as a separate application.  Or of course you could do both.

If you're showing UI from the service itself, you need two p-invoke calls.  First, you need OpenDesktop("Winlogon", 0, 0, 0xff).  You can do that one from Main() and store it in a static variable for the lifetime of the EXE.  Then when you go to create a thread to serve as the UI thread for the service, you need to call SetThreadDesktop using the handle you got from OpenDesktop.  Once a thread has called SetThreadDesktop, it can use Forms and such with relative impunity.  Be advised that the pre-logon desktop isn't exactly like a user desktop and some things will have subtle issues - for example, ToolStrip and derived controls won't look very snazzy, and System.Windows.Forms.Timer won't work at all.  (Use System.Timers.Timer instead.)  And as always, you should mark your UI thread with the [STAThread] attribute.

If you're just trying to launch another application and show its UI, you need to call CreateProcess.  In your StartupInfo structure, set lpDesktop to @"WinSta0\Winlogon".  Many programs will work just fine, but once again be advised that the pre-logon desktop isn't exactly like a user desktop and as such some programs may have issues.  For example, I've had a lot of trouble getting media player-type programs to work in this environment.

Let me know where you need additional help.

Author Comment

ID: 24226935
JMoon5FTM, I apologize - for some reason I never saw a notify on your comment as I did on the earlier ones, and I finally just came back to abandon the question.

Your approach is very close to what I have been trying... I'm going to check particulars against what you describe here and I will comment back.

Again my apologies - I appreciate your comment!

Author Closing Comment

ID: 31568905
Good answer, thanks for the help.

Featured Post

Technology Partners: 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!

Question has a verified solution.

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

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

624 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