Click here to Skip to main content
12,885,654 members (42,657 online)
Rate this:
Please Sign up or sign in to vote.
See more: C++ C# VB VB.NET
Hello Everyone,

Here is what I want to do:
1) When the computer boots, I want a service to start before anyone could login and automatically log into a specific account.

2) I have been able to make windows service but I dont know how to logon...

3) I have Windows 7 and various accounts have already been configured, but I would like to log into a specific account.


If it is, can someone please guide me to the process? I DONT NEED CODE, but the workflow or functions that might help!

Thanks in Advance
Posted 11-Feb-13 22:52pm
Rate this: bad
Please Sign up or sign in to vote.

Solution 3

Read this article published by microsoft and you will have a good idea on what to do:[^]
Dave Kreskowiak 12-Feb-13 8:12am
That's nice and all, but he hasn't really explain what the point of this is. We have no idea what he's trying to do or why.
videepmishraa 12-Feb-13 8:16am
I actually want to start computers by sending magic packets...then after boot, I want to run an application which will do a specific task. Hope now you understand why I am doing this.
shiny13 12-Feb-13 8:17am
Well if you said that in the beginning you would have had a whole of different answers and suggestions!
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

I'm not exactly sure what you want to achieve. To get the service, which will start before the interactive user logon is complete, to logon all it has to do is call the LogonUser Win32 API from any capable language. The service will then be logged on as that user but that will not remove or bypass the interactive logon screen.
If you want the interactive logon screen to be effectively bypassed by the details being entered automatically then there are registry hacks for that google "automatic logon Windows 7" and you will get the info you need. No service or extra software is required in this case.
videepmishraa 12-Feb-13 5:27am
Thank You Matthew,
First Case:
Is it possible for the service to run programs without bypassing the logon screen?

Second Case:
I tried the following which returned an error:


The error it threw was UNHANDLED Exception at 0x76B2C1BC (advapi32.dll)
0xC0000005: Access Violation writing location 0x00000000
Dave Kreskowiak 12-Feb-13 8:10am
What are you trying to do with this??

Services cannot run programs that display any kind of user interface. The user logged on at the console, if anyone IS logged in, will never see the interface because services and console users see different desktops.
Dave Kreskowiak 12-Feb-13 8:13am
Your initial post doesn't really make sense as when you setup a service, you have to tell the service manager what account to use to start the service. So why is your service trying to login again?? What's the point of all this??
videepmishraa 13-Feb-13 3:36am
I have a program which is used for rendering in 3d. What I found was that services can run programs in their specified logins...BUT HOW to make the service start at boot?
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

Is it possible for the service to run programs without bypassing the logon screen?

Yes. It certainly is. The service itself is such a program and given enough permissions it can in principle launch just about anything.
I don't think what your trying to do will work though. Trying to do an interactive logon from the service doesn't make sense, use the LOGON32_LOGON_SERVICE type, you can still launch other processes provided that the user you logon as has sufficient permissions.

I am a little surprised that it threw an unhandled exception so there might be another bug in there that's not obvious from what you pasted, check for buffer overruns or heap corruption in the preceding lines if you continue to get this error.

It could just be because you need to pass the address of a handle not just a null pointer for the out parameter. The API is supposed to be robust to that but this is Microsoft we're talking about.

BOOL bResult = LogonUser( L"xyz", L"xyz", L"xyz", LOGON32_LOGON_SERVICE, LOGON32_PROVIDER_DEFAULT, &hToken );

and remember to check with GetLastError() if FALSE is returned.

Debugging anything you can't see or attach to when its running is difficult. You might consider investing the time to set up detailed logging to a file if this is going to be a substantial piece of work.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

    Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170424.1 | Last Updated 12 Feb 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100