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

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2367
  • Last Modified:

Start c# program before windows logon

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
Zoooink
Asked:
Zoooink
  • 6
  • 2
1 Solution
 
Meir RivkinFull stack Software EngineerCommented:

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
 
ZoooinkAuthor Commented:
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
 
ricovoxCommented:
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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
ZoooinkAuthor Commented:
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
 
ZoooinkAuthor Commented:
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
 
ricovoxCommented:
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
 
ZoooinkAuthor Commented:
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
 
ZoooinkAuthor Commented:
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
 
ZoooinkAuthor Commented:
This issue was resolved using GPo and setting security vaues in windows 2008
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

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