Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Installing a windows service on remote machine using given username

What is the best way to install a windows service written in C# (in the standard way) on a remote machine, where I need to provide the username and password it should run as?

I am going to run it from MSBuild as part of integration tests.

EDIT: I don't have an msi and I don't want to create one.

like image 250
Grzenio Avatar asked Jul 21 '09 12:07

Grzenio


1 Answers

You can use the SC command.

sc.exe \\remotecomputer create newservice binpath= C:\Windows\System32\Newserv.exe start= auto obj= DOMAIN\username password= pwd

(Note the spaces after the equals signs are important)

Creates a service entry in the registry and Service Database.
SYNTAX: 
sc create [service name] [binPath= ] <option1> <option2>...
CREATE OPTIONS:
NOTE: The option name includes the equal sign.
 type= <own|share|interact|kernel|filesys|rec>
       (default = own)
 start= <boot|system|auto|demand|disabled>
       (default = demand)
 error= <normal|severe|critical|ignore>
       (default = normal)
 binPath= <BinaryPathName>
 group= <LoadOrderGroup>
 tag= <yes|no>
 depend= <Dependencies(separated by / (forward slash))>
 obj= <AccountName|ObjectName>
       (default = LocalSystem)
 DisplayName= <display name>
 password= <password> 
like image 188
Patrick McDonald Avatar answered Oct 04 '22 01:10

Patrick McDonald