Solved

Start c# program before windows logon

Posted on 2010-11-29
9
2,036 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
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"

(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
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?
0
 
LVL 4

Expert Comment

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

Author Comment

by:Zoooink
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!!
0
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 
LVL 3

Author Comment

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

Expert Comment

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

Author Comment

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

Accepted Solution

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

Author Closing Comment

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

Featured Post

The curse of the end user strikes again      

You’ve updated all your end user’s email signatures. Hooray! But guess what? They’re playing around with the HTML, adding stupid taglines and ruining the imagery. Find out how you can save your signatures from end users today.

Question has a verified solution.

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

Suggested Solutions

A Bare Metal Image backup allows for the restore of an entire system to a similar or dissimilar hardware. They are highly useful for migrations and disaster recovery. Bare Metal Image backups support Full and Incremental backups. Differential backup…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
In this video, we discuss why the need for additional vertical screen space has become more important in recent years, namely, due to the transition in the marketplace of 4x3 computer screens to 16x9 and 16x10 screens (so-called widescreen format). …
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…

867 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

22 Experts available now in Live!

Get 1:1 Help Now