Can't see my service under services after installation using Topshelf

I'm sure the answer is so simple, but here it is:

I use TopShelf to install my service, and I can successfully install and run it from the command line as

Install MyExecutable.Daemon MyExecutable.Daemon start

This is good, but it should be among the Services, and it was not the way I tried;

sc create "MyExecutable.Daemon" binPath= "C:\'Program Files (x86)'\MyExecutable.Daemon.exe" DisplayName= "MyExecutable.Daemon" start= auto 

but got

 Set-Content : A positional parameter cannot be found that accepts argument 'binpath='. At line:1 char:1 + sc create MyExecutable.Daemon binpath= "C:\'Program Files (x86)'\... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidArgument: (:) [Set-Content], ParameterBindingException + FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.SetContentCommand 

So, I'm stuck here. What am I missing here?

+8
windows powershell install service topshelf
source share
2 answers

sc in powershell is an alias for set-Content using cmdlet sc.exe .

Try (not verified)

 sc.exe create "MyExecutable.Daemon" binPath="C:\'Program Files (x86)'\MyExecutable.Daemon.exe" DisplayName="MyExecutable.Daemon" start=auto 
+22
source share

You must do MyExecutable.Daemon install start . I think I did this successfully from the PowerShell prompt, but I probably need to check. If this does not work, you need to enable logging with one of the logging plugins and provide a log file. You should not use sc to install the Topshelf service. It will not succeed.

+2
source share

All Articles