Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C++C#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.
 
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 11-Feb-13 22:52pm
Rate this: bad
good
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.
 
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.
  Permalink  
Rate this: bad
good
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.
  Permalink  
Comments
videepmishraa at 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 at 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 at 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 at 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?
Rate this: bad
good
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:
http://support.microsoft.com/kb/180548/en-us?p=1[^]
  Permalink  
Comments
Dave Kreskowiak at 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 at 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 at 12-Feb-13 8:17am
   
Well if you said that in the beginning you would have had a whole of different answers and suggestions!

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

  Print Answers RSS
Your Filters
Interested
Ignored
     
0 Sergey Alexandrovich Kryukov 375
1 Abhinav S 333
2 OriginalGriff 330
3 sanket saxena 305
4 CPallini 175
0 Sergey Alexandrovich Kryukov 8,497
1 OriginalGriff 4,850
2 Peter Leow 3,839
3 Maciej Los 3,515
4 Er. Puneet Goel 3,107


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