A Windows service using "Local System" account fails to start when converted to "Network Service" account - "Error 1053: The service did not respond to the start or control request in a timely fashion"
I have a WIN32 service written in C++. Currently, it runs under the "Local System" account. This is fine except when the service needs to access a remote resource on another Windows machine like a shared drive - it fails with "Access Denied". Reading through the literature I see that I should convert my service to run under the "Network Service" account. However, when I convert my service to run under this account & try & start it from the SCM control panel I get an error message saying:
"Error 1053: The service did not respond to the start or control request in a timely fashion".
Putting a "hard" break point (int 3) on the first line of code under _tmain(), I see that my code is never even called. That is, the service code itself doesn't even get a chance to run. It starts (& runs) just fine when configured to run under the "Local System" account but not when I switch configuration to the "Network Service" account. There must be some configuration issue that I'm missing. The service installs fine (under the "Network Service" account), it just never runs. This happens on Vista (UAC turned on) & XP SP3. In both cases I have WIndows Firewall turned OFF. The service code opens tcp/ip & udp sockets (read/write) & accesses the local file system (read/write). It also needs to (read) access remote file systems.
I even created a barebones WIN32 service with nothing in it except the standard WIN32 service infrastructure & I still couldn't get it to start as a NetworkService. The code (i.e. _tmain()) just never gets called. How do other people do it? What am I doing wrong.