Solved

Start c# program before windows logon

Posted on 2010-11-29
9
2,019 Views
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!
0
Comment
Question by:Zoooink
  • 6
  • 2
9 Comments
 
LVL 42

Expert Comment

by:sedgwick
Comment Utility

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"

(http://stackoverflow.com/questions/2850618/getting-program-to-run-at-start-up-from-c-code-setting-registry-run-to-true)
0
 
LVL 3

Author Comment

by:Zoooink
Comment Utility
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?
0
 
LVL 4

Expert Comment

by:ricovox
Comment Utility
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?
0
 
LVL 3

Author Comment

by:Zoooink
Comment Utility
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!!
0
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
LVL 3

Author Comment

by:Zoooink
Comment Utility
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
0
 
LVL 4

Expert Comment

by:ricovox
Comment Utility
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...
0
 
LVL 3

Author Comment

by:Zoooink
Comment Utility
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!
0
 
LVL 3

Accepted Solution

by:
Zoooink earned 0 total points
Comment Utility
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..
0
 
LVL 3

Author Closing Comment

by:Zoooink
Comment Utility
This issue was resolved using GPo and setting security vaues in windows 2008
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Several part series to implement Internet Explorer 11 Enterprise Mode
When you start your Windows 10 PC and got an "Operating system not found" error or just saw  "Auto repair for startup". After a while, you have entered a loop for Auto repair which does not fix anything and you will be in a  panic as all your work w…
Windows 8 came with a dramatically different user interface known as Metro. Notably missing from that interface was a Start button and Start Menu. Microsoft responded to negative user feedback of the Metro interface, bringing back the Start button a…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

743 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now