Start c# program before windows logon

Posted on 2010-11-29
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 (

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?
Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.


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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
No single Antivirus application (despite claims by manufacturers) will catch or protect you from all Virus / Malware or Spyware threats. That doesn't stop you from further protecting yourself however - and this article is to show you how.
Windows 8 comes with a dramatically different user interface known as Metro. Notably missing from the new interface is a Start button and Start Menu. Many users do not like it, much preferring the interface of earlier versions — Windows 7, Windows X…
This Micro Tutorial will give you a basic overview of Windows DVD Burner through its features and interface. This will be demonstrated using Windows 7 operating system.

696 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