Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1489
  • Last Modified:

Windows XP launch visible program before logon

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 vb.net, 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.
  • 4
  • 2
1 Solution
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.
LawlessOneAuthor Commented:
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.
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.

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

LawlessOneAuthor Commented:
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.  
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.
LawlessOneAuthor Commented:
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!
LawlessOneAuthor Commented:
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.

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now