Share via


Classe Service

The Service class represents an instance of the SQL Server service.

Hierarquia de herança

System.Object
  Microsoft.SqlServer.Management.Smo.SmoObjectBase
    Microsoft.SqlServer.Management.Smo.Wmi.WmiSmoObject
      Microsoft.SqlServer.Management.Smo.Wmi.Service

Namespace:  Microsoft.SqlServer.Management.Smo.Wmi
Assembly:  Microsoft.SqlServer.SqlWmiManagement (em Microsoft.SqlServer.SqlWmiManagement.dll)

Sintaxe

'Declaração
Public NotInheritable Class Service _
    Inherits WmiSmoObject _
    Implements IAlterable
'Uso
Dim instance As Service
public sealed class Service : WmiSmoObject, 
    IAlterable
public ref class Service sealed : public WmiSmoObject, 
    IAlterable
[<SealedAttribute>]
type Service =  
    class 
        inherit WmiSmoObject 
        interface IAlterable 
    end
public final class Service extends WmiSmoObject implements IAlterable

O tipo Service expõe os membros a seguir.

Propriedades

  Nome Descrição
Propriedade pública AcceptsPause Gets the Boolean property value that specifies whether the SQL Server service can be paused.
Propriedade pública AcceptsStop Gets the Boolean property value that specifies whether the SQL Server service can be stopped.
Propriedade pública AdvancedProperties Represents a collection of Property objects. Each Property object represents an advanced property defined on the SQL Server service.
Propriedade pública Dependencies Returns a list of services that are dependent on the referenced SQL Server service.
Propriedade pública Description Gets a textual description of the SQL Server service.
Propriedade pública DisplayName Gets the display name of the SQL Server service.
Propriedade pública ErrorControl Gets the severity of the error if the SQL Server service fails to start during startup.
Propriedade pública ExitCode Gets the Win32 error code that defines problems encountered when starting and stopping the SQL Server service.
Propriedade pública IsHadrEnabled Gets whether the High Availability/Disaster Recovery is enabled.
Propriedade pública Name Gets or sets the name of the referenced Windows Management Instrumentation (WMI) object. (Herdado de WmiSmoObject.)
Propriedade pública Parent Gets the ManagedComputer object that is the parent of the Service object.
Propriedade pública PathName Gets the path and file name of the binary file that implements the SQL Server service.
Propriedade pública ProcessId Gets the process ID that uniquely identifies the SQL Server service.
Propriedade pública Properties Represents a collection of Property objects. Each Property object represents a property defined on the Windows Management Instrumentation (WMI) object. (Herdado de WmiSmoObject.)
Propriedade pública ServiceAccount Gets the system account under which the SQL Server service is running.
Propriedade pública ServiceState Gets the state of the SQL Server service, such as running, stopped, or paused.
Propriedade pública StartMode Gets or sets the method by which the SQL Server service is started.
Propriedade pública StartupParameters Gets or sets any startup parameters for the SQL Server service.
Propriedade pública State Gets the state of the referenced object. (Herdado de SmoObjectBase.)
Propriedade pública Type Gets the type of service, such as Microsoft Search service, SQL Server Agent service, or SQL Server service.
Propriedade pública Urn Gets the Uniform Resource Name (URN) address that represents the Windows Management Instrumentation (WMI) object. (Herdado de WmiSmoObject.)
Propriedade pública UserData Gets or sets user-defined data associated with the referenced object. (Herdado de SmoObjectBase.)

Início

Métodos

  Nome Descrição
Método público Alter Updates any Service object property changes on an instance of SQL Server.
Método público ChangeHadrServiceSetting Changes the HA/DR service settings.
Método público ChangePassword Changes the password for the system account under which the SQL Server service is running.
Método público Equals (Herdado de Object.)
Método público GetHashCode (Herdado de Object.)
Método público GetType (Herdado de Object.)
Método público Initialize Initializes the referenced object. (Herdado de WmiSmoObject.)
Método protegido IsObjectInitialized Specifies whether the referenced object is initialized. (Herdado de WmiSmoObject.)
Método público Pause Pauses the SQL Server service.
Método público Refresh Refreshes the SQL Server service. (Substitui WmiSmoObject.Refresh().)
Método público Resume Resumes the SQL Server service.
Método protegido SetName Sets the name of the referenced object. (Herdado de WmiSmoObject.)
Método protegido SetParentImpl Sets the parent of the referenced object. (Herdado de WmiSmoObject.)
Método público SetServiceAccount Sets the account under which the SQL Server service runs.
Método público Start Starts the SQL Server service.
Método público Stop Stops the SQL Server service.
Método público ToString (Herdado de Object.)
Método público Validate Validates the state of an object. (Herdado de SmoObjectBase.)

Início

Eventos

  Nome Descrição
Evento público ManagementStateChange An event that occurs when the management state changes.

Início

Comentários

The Service object is used to programmatically manage the SQL Server service. With the Service object you can:

  • Connect to the service.

  • Modify the account and password used to connect to the service.

  • Start, stop, pause, and resume the service.

  • Check the properties of the service.

Thread Safety

Qualquer membro público estático (Compartilhado no Microsoft Visual Basic) desse tipo é seguro para operações multi-threaded. Não há garantia de que qualquer membro de instância seja seguro para threads.

Exemplos

Gerenciando serviços e configurações de rede através do provedor do WMI

Segurança de thread

Qualquer membro público static (Shared no Visual Basic) desse tipo é seguro para threads. Não há garantia de que qualquer membro de instância seja seguro para threads.

Consulte também

Referência

Namespace Microsoft.SqlServer.Management.Smo.Wmi

Outros recursos

WMI and SQL Server