Start service Before Login
-
Hello All., How can i make my service to run before log in? .. Following is my code to create the service...
BOOL InstallService()
{
char strDir[1024];
SC_HANDLE schSCManager,schService;
GetCurrentDirectory(1024,strDir);
strcat(strDir,"\\Session_Service.exe");schSCManager = OpenSCManager(NULL,NULL,SC\_MANAGER\_ALL\_ACCESS); if (schSCManager == NULL) return false; LPCTSTR lpszBinaryPathName = strDir; schService = CreateService(schSCManager, szServiceName, szServiceName, SERVICE\_ALL\_ACCESS, // Desired access SERVICE\_WIN32\_OWN\_PROCESS, //Service Type SERVICE\_AUTO\_START, // Start Type SERVICE\_ERROR\_NORMAL, // Error Control Type lpszBinaryPathName, // Service Binary "Base", // No Load Ordering Group NULL, // No Tag Identifier NULL, // No depenencies NULL, //Local System Account NULL); // No password if (schService == NULL) return false; CloseServiceHandle(schService); return true;
}
-
Hello All., How can i make my service to run before log in? .. Following is my code to create the service...
BOOL InstallService()
{
char strDir[1024];
SC_HANDLE schSCManager,schService;
GetCurrentDirectory(1024,strDir);
strcat(strDir,"\\Session_Service.exe");schSCManager = OpenSCManager(NULL,NULL,SC\_MANAGER\_ALL\_ACCESS); if (schSCManager == NULL) return false; LPCTSTR lpszBinaryPathName = strDir; schService = CreateService(schSCManager, szServiceName, szServiceName, SERVICE\_ALL\_ACCESS, // Desired access SERVICE\_WIN32\_OWN\_PROCESS, //Service Type SERVICE\_AUTO\_START, // Start Type SERVICE\_ERROR\_NORMAL, // Error Control Type lpszBinaryPathName, // Service Binary "Base", // No Load Ordering Group NULL, // No Tag Identifier NULL, // No depenencies NULL, //Local System Account NULL); // No password if (schService == NULL) return false; CloseServiceHandle(schService); return true;
}
If the
CreateService
returns success, this is all you need for the service to start before log in. What is the problem here? Does it not start?«_Superman_»
I love work. It gives me something to do between weekends. -
If the
CreateService
returns success, this is all you need for the service to start before log in. What is the problem here? Does it not start?«_Superman_»
I love work. It gives me something to do between weekends.Yes it return success, I'm sure about this, I'm actually handling session change notifications including Logon, Logoff, Lock and Unlock... When i restart my machine then it didn't catch the logon notofication, But when i logoff and then logon again it catches and write log to support that user has logged on..
-
Yes it return success, I'm sure about this, I'm actually handling session change notifications including Logon, Logoff, Lock and Unlock... When i restart my machine then it didn't catch the logon notofication, But when i logoff and then logon again it catches and write log to support that user has logged on..
You could try without defining a load order group.
«_Superman_»
I love work. It gives me something to do between weekends. -
You could try without defining a load order group.
«_Superman_»
I love work. It gives me something to do between weekends.I was doing that initially, But then i saw This thread which makes me to change the CreateService...