New Windows Service installed, fails to start: “System error 2 … system cannot find the file specified”

后端 未结 6 1780
广开言路
广开言路 2021-02-04 23:43

I have installed several other custom .Net windows services successfully. A new one I had recently written was very similar to the others and while it installed without error -

6条回答
  •  情话喂你
    2021-02-05 00:06

    In my case, I opened the Command Promt and navigated to the exe and installed it from there. So I did not enter the full path. Once I used the full path, it worked.

    1. So, you need to either install the service with the full path or add the exe file's path to PATH in system environment variables.

       SC CREATE "Service-Name" binpath="D:\full-path-to-service\service.exe"
      

      or add D:\full-path-to-service\ to PATH variable and use

       SC CREATE "Service-Name" binpath="service.exe"
      

    1. Also, verify that the path is correct. Because, I once installed with the wrong path and it got successfully installed, but when I tried to start it, I got the same error.

提交回复
热议问题