Click here to Skip to main content
15,878,945 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.

IS IT POSSIBLE?

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
Videep
Posted

Read this article published by microsoft and you will have a good idea on what to do:
http://support.microsoft.com/kb/180548/en-us?p=1[^]
 
Share this answer
 
Comments
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    
Dave,
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!
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.
 
Share this answer
 
Comments
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:
[Code]
DWORD dwLogonType=LOGON32_LOGON_INTERACTIVE;
DWORD dwLogonProvider=LOGON32_PROVIDER_DEFAULT;
PHANDLE phToken = NULL;
LogonUser(L"xyz",L"xyz",L"xyz",dwLogonType,dwLogonProvider,phToken);

[/Code]

The error it threw was UNHANDLED Exception at 0x76B2C1BC (advapi32.dll)
0xC0000005: Access Violation writing location 0x00000000
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??
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.
videepmishraa 13-Feb-13 3:36am    
Dave,
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?
SQL
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.

HANDLE hToken = NULL;
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.
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900