I downloaded and built the above service on Win7 Ultimate (64bi) VS 2010. All seemed to go well and I was able to install the service using the Command Prompt. However, attempting to start the service was not possible, even when opening the Control Panel/Administrative Tools/Services as Administrator. Attempts to use the Start command were invariably met with:
Windows could not start the CppWindowService Sample Service service on Local COmputer.
Error 2: The system cannot find the file specified.
Oddly, looking at the Properties Page of the service, the path of the service is correct.
Please advise what I am doing wrong or what I am missing.
Re: Windows Service in Win7 would be nice ... but ...
IMO, easiest way to create a C++ based Windows Service is to use the ATL project and #define _ATL_NO_COM_SUPPORT if you don't want the service to host COM.
Re: Windows Service in Win7 would be nice ... but ...
if your path is:
- a network path
- a SUBSTed path
- a Junctioned path
- a path that lies under the user profile
- ...
Services run in the service context with a different user account that you are typically "SYSTEM" or "LOCAL SYSTEM", that system account may not have the same network mappings, substs, junctions, or may not have access in user folders.
Re: Windows Service in Win7 would be nice ... but ...
Originally Posted by OReubens
if your path is:
- a network path
- a SUBSTed path
- a Junctioned path
- a path that lies under the user profile
- ...
Services run in the service context with a different user account that you are typically "SYSTEM" or "LOCAL SYSTEM", that system account may not have the same network mappings, substs, junctions, or may not have access in user folders.
For this reason, I generally setup my service code to be able to be run as a service and as a regular user. That way, if the service can function as a user, but not as a service, it's generally a permissions issue (which I can confirm by running the service account as a user). Not solving world hunger here, but just a simple technique that makes developing services easier.
Bookmarks