Search code examples
topshelf

How can I automate a Topshelf interactive service install?


I have a couple Topshelf services that run under a specific service account. If I install the services manually from a command line, I can use the --interactive flag, and a dialog box comes up allowing me to enter the username and password. I'd like to be able to automate this through a Powershell script.

Does anyone know how to do this? (Not concerned about Powershell specifically, but with how can I provide the username and password in any installation script.)

As Travis mentioned, I took a look at the command line options. Almost working for me, but now I have one escaping issue. To install, you can type, e.g., MyService.exe install -username:Foo -password:Bar.

However, I have to provide both the domain and username for the username option (I know this from doing the --interactive route): MyService.exe install -username:mydomain\$myusername -password:Bar

I cannot find a way to escape this that works! Sorry -- my question has morphed into something else, might need to mark it answered and open a different one.


Solution

  • Travis pointed me in the right direction with the command line options. I had one more problem with the service account username I had, which was prefixed with a "$": domain\$myuser. I could not find a way to escape it so the "install" command would accept it.

    We created a similar username "myuser" (without the $). Now this works just fine:

    MyService.exe install -username:domain\myuser -password:Bar