Start c# program before windows logon

Posted on 2010-11-29
Medium Priority
Last Modified: 2012-08-13
Hello Fellow Experts!

I have written a program in C# which requires user interaction before the logon process is initiated. I have successfully added a service to invoke the program, but this only works after the user has logged in.

I have a laptop provided by one of my clients where a dialogue box appears stright after the user hits CTRL+ALT+DELETE and after clicking OK, the dialogue box disappears and the windows logon box appears, so I know it is possible. (there is no secondary desktop, it is just a dialogue box.)

I realise there is something called GINA which can be manipulated, but I wish to avoid this if I can, unless someone can provide me with a working example to manipulate the process after the CTRL+ALT+DELETE function.

Thanks for the help!
Question by:Zoooink
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
  • 6
  • 2
LVL 42

Expert Comment

ID: 34229476

If you want your program to start as a service before anyone logs on, then it's going to need to be installed and run as an admin user. There's not getting round this fact.

There's a Microsoft Knowledge Base article on creating a service which should get you started (http://support.microsoft.com/kb/251192)

There's a project template for a Windows Service installed by default in Visual Studio 2008:
"File > New > Project > Visual C# > Windows > Windows Service"


Author Comment

ID: 34229790
Thank you for replying Sedgwick, but as I have stated above, I already have the service in place, which is of no use wtih this program as it starts AFTER the user logs in, I need the program to start after pressing CTRL+ALT+DELETE and BEFORE the windows logon prompt.

Will sc.exe allow me to configure the service to run in this way?

Expert Comment

ID: 34230774
I think sedgwick was pointing out that you probably have the service configured wrong for your purpose. It is certainly possible to configure a service to start immediately after windows starts and before anyone logs in. Sedgwick was wrong that a service has to run as an "admin user". In fact most services run in the Local System account, NOT an admin account.

For example, I have the apache web server configured as a service, and It runs in the Local System Account as soon as windows starts. I never even have to log in at all.

The important issue is WHICH user account the service is configured to run as. If you configure it to run as the LOCAL SYSTEM, then you can easily have it start when windows starts, before anyone logs in.

You can see change a service's account using the "Services" administrative tool as follows:

1) Run "services.msc" to open the Services admin tool.
2) Find your service in the list.
3) Right-Click and click "Properties"
4) On the "Log On" tab, choose the account to use:
   FIrst try "Local System Account" and check the box "Allow Service to Interact with the Desktop"
   If that doesn't work, then try the Local Service account: click "This account" (in windows 7) and then type NT AUTHORITY\LocalService  (the password is ignored for this account).

Also, make sure that the "Startup Type" on the "General" tab is set to "Automatic".

I'll go ahead and build a test service in C# to make sure all of this works. Can you please tell me your operating system? XP or Vista or Windows 7?
Building an interactive eFuture classroom

Watch and learn how ATEN provided a total control system solution including seamless switching matrix switch, HDBaseT extenders, PDU, lighting control to build an interactive eFuture classroom.


Author Comment

ID: 34231563
Hi ricovox,

Thank you for your input, as far as I am aware, the service already runs, I have installed the service, edited the registry to point to the program I want started, and that is all fine, though I do have to log on as LocalSystem with the desktop option checked. I have also tried with the Local Service account to no avail.

The program is an application, not a service application. and, again... it runs as soon as the user has logged on..

Is it possible to write a service application to run a dialogue box before the windows logon screen comes up? I have searched online, and cannot find anything to interrupt the CTRL+ALT+DELETE process except with a GINA.. but that looks ever so complicated!!

Author Comment

ID: 34231597
Also GINA dll is ignored by vista, so it's not really an option for me, I want to run this on all three operating systems, though the majority are XP, I have one that is Vista, and three running Windows 7

Expert Comment

ID: 34231953
Hi Zoooink,

Just to make sure I understand what is happening:
You say the service is running, but your application dialog does not appear until the user has logged on.

Do you know if the service itself is running before you login?
Perhaps the service does run your program BEFORE you login, but it is just not able to display a dialog box at the login screen.  Do you think that could be the case?

I will try to look into this...

Author Comment

ID: 34237691
Hi ricovox,

You understand correctly!

Is there a way to test if a service starts before logging in? The actual services tool doesn't really give you much to play with on the service properties page, which is quite annoying.

You must be able to thoug surely, iPass Connect displays a Yes/No dialogue? and also starts the full program for you to connect to a VPN well before logging in to windows.

Thanks for your help!

Accepted Solution

Zoooink earned 0 total points
ID: 34333294
Any joy with this issue?

I've managed to find a work around for what I require in the way of a security dialogue box built in to Windows, but that's not really what I want..

Author Closing Comment

ID: 34652411
This issue was resolved using GPo and setting security vaues in windows 2008

Featured Post

Manage your data center from practically anywhere

The KN8164V features HD resolution of 1920 x 1200, FIPS 140-2 with level 1 security standards and virtual media transmissions at twice the speed. Built for reliability, the KN series provides local console and remote over IP access, ensuring 24/7 availability to all servers.

Question has a verified solution.

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

An introduction to the wonderful sport of Scam Baiting.  Learn how to help fight scammers by beating them at their own game. This great pass time helps the world, while providing an endless source of entertainment. Enjoy!
In this modest contribution, I want to share with the IT community (especially system administrators, IT Support Engineers and IT Help Desks) about Windows crashes/hangs and how to deal with these particular problems.
This video Micro Tutorial explains how to clone a hard drive using a commercial software product for Windows systems called Casper from Future Systems Solutions (FSS). Cloning makes an exact, complete copy of one hard disk drive (HDD) onto another d…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

770 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