user1572522
user1572522

Reputation: 619

StartService(), and 'sc start', return ERROR_FILE_NOT_FOUND

My remote Service works fine on my Server 2008, 32 bit, but when I try to run it on my Windows 7 machine StartService() fails with ERROR_FILE_NOT_FOUND.

OpenSCManager(), CreateService(), QueryServiceStatus() and OpenService() all return success, but StartService() fails.

I even compiled the Service from the SDK Samples\WinBase\Service and copied it to Windows\system32 directory on my Win 7 machine, and ran it with '-install'. When I tried to start it with 'SC start' it returns the same error.

Here is the info from SC:

C:\Windows\System32>sc query SimpleService

SERVICE_NAME: SimpleService
        TYPE               : 10  WIN32_OWN_PROCESS
        STATE              : 1  STOPPED
        WIN32_EXIT_CODE    : 1077  (0x435)
        SERVICE_EXIT_CODE  : 0  (0x0)
        CHECKPOINT         : 0x0
        WAIT_HINT          : 0x0


C:\Windows\System32>sc qc SimpleService
[SC] QueryServiceConfig SUCCESS

SERVICE_NAME: SimpleService
        TYPE               : 10  WIN32_OWN_PROCESS
        START_TYPE         : 3   DEMAND_START
        ERROR_CONTROL      : 1   NORMAL
        BINARY_PATH_NAME   : C:\Windows\System32\ServiceSvc.exe
        LOAD_ORDER_GROUP   :
        TAG                : 0
        DISPLAY_NAME       : Simple Service
        DEPENDENCIES       :
        SERVICE_START_NAME : LocalSystem


C:\Windows\System32>sc start SimpleService
[SC] StartService FAILED 2:

The system cannot find the file specified.

I even ran xCmd.exe on my Win 7 machine, it runs a similar type of remote Service, it gives virus warnings, but even that returns the same error.

I'm sure that if it was a permissions issue that it would probably return ERROR_ACCESS_DENIED.

I've searched all over the net and can't find anything on why it's returning that.

Upvotes: 3

Views: 14223

Answers (2)

user6538989
user6538989

Reputation: 1

Run the service executable from \windows\system32

Upvotes: -2

user1572522
user1572522

Reputation: 41

I'm pretty sure I found the problem.

I found code to detect if the app was running in WOW64 and it returned true, it was running on a 64 bit Windows 7 machine.

When it's running in WOW64 it goes to Windows\SysWOW64 not system32.

Once I copied the 32 bit Service .exe into Windows\SysWOW64 and ran it the Service started! :-)

Upvotes: 4

Related Questions