Share via


Service.SetServiceAccount Method

Sets the account under which the SQL Server service runs.

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

Syntax

'Declaration
Public Sub SetServiceAccount ( _
    userName As String, _
    password As String _
)
'Usage
Dim instance As Service 
Dim userName As String 
Dim password As String

instance.SetServiceAccount(userName, _
    password)
public void SetServiceAccount(
    string userName,
    string password
)
public:
void SetServiceAccount(
    String^ userName, 
    String^ password
)
member SetServiceAccount : 
        userName:string * 
        password:string -> unit
public function SetServiceAccount(
    userName : String, 
    password : String
)

Parameters

  • userName
    Type: System.String
    A String value that specifies the system account under which the SQL Server service runs.
  • password
    Type: System.String
    A String value that specifies the password for the system account.

Examples

Managing Services and Network Settings by Using WMI Provider

See Also

Reference

Service Class

Microsoft.SqlServer.Management.Smo.Wmi Namespace

Other Resources

WMI and SQL Server

Connecting to the SQL Server Database Engine