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
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= ] ...
CREATE OPTIONS:
NOTE: The option name includes the equal sign.
type=
(default = own)
start=
(default = demand)
error=
(default = normal)
binPath=
group=
tag=
depend=
obj=
(default = LocalSystem)
DisplayName=
password=