Improve company productivity with a Business Account.Sign Up


Windows XP launch visible program before logon

Posted on 2009-04-10
Medium Priority
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
  • 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.
What Kind of Coding Program is Right for You?

There are many ways to learn to code these days. From coding bootcamps like Flatiron School to online courses to totally free beginner resources. The best way to learn to code depends on many factors, but the most important one is you. See what course is best for you.


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 2000 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

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

When we want to run, execute or repeat a statement multiple times, a loop is necessary. This article covers the two types of loops in Python: the while loop and the for loop.
Native ability to set a user account password via AD GPO was removed because the passwords can be easily decrypted by any authenticated user in the domain. Microsoft recommends LAPS as a replacement and I have written an article that does something …
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…

579 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