Installing using sc.exe

1,684 views
Skip to first unread message

Taylor Johnson

unread,
Jan 12, 2016, 4:24:23 PM1/12/16
to topshelf-discuss
Hi,

I have used topshelf to install our service several times and everything works great, but I have a client that requires it be installed using sc.exe via the command line. They installed the service and everything seemed to work correctly, except for when we go to start the service it times out and throws an exception saying Topshelf.TopshelfException: The Topshelf.Runtime.Windows.WindowsHostSettings service has not been installed yet. Please run 'Name.Of.My.Service, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null install'. Is there a way to prevent topshelf from throwing this error or do I have to make a new project and not use topshelf for it.

Here is the command they are using to install the service:

sc create Name.Of.MyService.DevA binpath= Name.Of.My.Service.exe start= auto

Dru Sellers

unread,
Jan 12, 2016, 4:32:03 PM1/12/16
to topshelf...@googlegroups.com
I'm not sure if anyone has used SC to install a topshelf project since it does it itself. Ultimately they (TS / SC) call the same code. I understand that there can be requests. I'd ask you to understand why the want to install SC when you can just say program install. That said, i'd study what program.exe install does in the service console and then compare what SC is doing. 

My guess is that to get SC.exe to work you would have to get a PR into TS (one I'm sure we would accept). Seems like you are getting "tripped up" here https://github.com/Topshelf/Topshelf/blob/develop/src/Topshelf/Runtime/Windows/WindowsServiceHost.cs#L68



--
You received this message because you are subscribed to the Google Groups "topshelf-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to topshelf-discu...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Taylor Johnson

unread,
Jan 12, 2016, 5:43:42 PM1/12/16
to topshelf-discuss
Thanks. Yeah, I saw that was where the error was coming. I recompiled the code to do a better job of logging that _settings object. I bet I can get it to work if my service name matches what they install using sc install.

The reason they use sc install is because everything they do is automated deployment and that is what their automated deployment tool is coded to do. So they don't like to make exceptions. 

Dru Sellers

unread,
Jan 12, 2016, 6:40:16 PM1/12/16
to topshelf...@googlegroups.com
roger that.

Chris Patterson

unread,
Jan 13, 2016, 7:17:48 AM1/13/16
to topshelf...@googlegroups.com
Usually the problem with sc.exe is that the service name (as it is registered in the SCM) does not match what Topshelf itself uses, so when Topshelf starts it can't find itself registered. Make sure to pass the service name to SC so that it is properly able to locate the service.

You also don't get the "admin level" methods that run OnInstall(), so if you're doing any setup of the registry, etc. in those methods, they're not going to be called by sc.exe.

Reply all
Reply to author
Forward
0 new messages