问题
I have my service under this folder path
C:\Users\Documents\Visual Studio 2012\TestServices\TestServices\InboundMessage.ServiceHost\bin\Debug --- > here is were all my dlls and .exe is
I use this command to install to my local box
sc create "Receiver Services" binPath= "C:\Users\Documents\Visual Studio 2012\TestServices\TestServices\InboundMessage.ServiceHost\InboundMessage.ServiceHost.exe" displayname= "*Receiver Services"
sc description "Receiver Services" "Receiver Services."
sc delete "Receiver Services" "Receiver Services."
I opened my cmd(c:\windows\System32) and execute the above command.
the service is installed but i am not able to start it because it throw the error: Windows couldn't start the service on local machine Error 2:the system couldn't find the file specified.
EDIT: I right click and check the property of the service installed to check the path. and it matches the one I put in the command
回答1:
You can use InstallUtil.exe.
Execute the Developer Command Prompt for VS2012 with high privileges and then run:
installutil yourWithAWindowsService.exe
回答2:
there is one spelling error. Now my service is up and running.
来源:https://stackoverflow.com/questions/22416910/unable-to-install-service-using-sc-command