Can not see my service under services after installing with Topshelf
Asked Answered
A

2

8

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?

Abutter answered 19/9, 2013 at 11:25 Comment(0)
L
22

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
Lyingin answered 19/9, 2013 at 11:44 Comment(3)
Thanks, that works to install the service but one question. As Travis pointed out I shouldn't be installing my service with sc.exe and MyExecutable.exe install starts it but it doesn't appear in Windows Services. Any idea?Abutter
@Abutter Installing it with sc.exe it appears in services.msc ? I really don't know why not in the other way.. I'm sorry..Lyingin
Ok this solved my problem. MyExecutable.exe service install. I was missing 'service' in betweenAbutter
E
2

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.

Estrada answered 19/9, 2013 at 13:57 Comment(2)
Thats true but why doesn't it appear on the list after starting. Anyway let me look a little more.Abutter
Enable logging and get the log. If it's failing, it will tell you why.Estrada

© 2022 - 2024 — McMap. All rights reserved.