public void InstallService(string serviceFileName, string serviceName, string displayName, BuiltInAccount builtInAccount, string description, bool autoStart, string[] dependencies) { switch (builtInAccount) { case BuiltInAccount.LocalSystem: WindowsImports.InstallService(theScHandle, serviceFileName, serviceName, displayName, null, null, autoStart, dependencies); break; case BuiltInAccount.LocalService: case BuiltInAccount.NetworkService: WindowsImports.InstallService(theScHandle, serviceFileName, serviceName, displayName, GetBuiltInAccountName(builtInAccount), null, autoStart, dependencies); break; } if (!String.IsNullOrEmpty(description)) { WindowsImports.SetServiceDescription(theScHandle, serviceName, description); } }
public void InstallService(BuiltInAccount account, bool isAutoStart, string[] dependances) { theServiceController.InstallService(AssemblyFileName, ServiceName, ServiceName, account, Description, isAutoStart, dependances); }
private string GetBuiltInAccountName(BuiltInAccount account) { switch (account) { case BuiltInAccount.LocalService: return @"NT AUTHORITY\LocalService"; case BuiltInAccount.NetworkService: return @"NT AUTHORITY\NetworkService"; } return null; }