Question

I am pretty sure the answer is so simple but here it is;

I'm using TopShelf to install my service and I can succesfully install and run it from command line as

MyExecutable.Daemon install MyExecutable.Daemon start

This is fine but it has to be amongst the Services and it wasn't so 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?

Was it helpful?

Solution

sc in powershell is the alias for set-Content cmdlet use sc.exe instead.

Try this (not tested)

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

OTHER TIPS

You should do MyExecutable.Daemon install start. I think I've done that successfully from a PowerShell prompt before but I guess I would have to verify. If that doesn't work, you need to enable logging with one of the logging plugins and provide the log file. You shouldn't use sc to install a Topshelf service. That will fail.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top