You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The WMI provider is a published interface that is used by [!INCLUDE[msCoName](../../../includes/msconame-md.md)] Management Console (MMC) to manage the [!INCLUDE[ssNoVersion](../../../includes/ssnoversion-md.md)] services and network protocols. In SMO, the <xref:Microsoft.SqlServer.Management.Smo.Wmi.ManagedComputer> object represents the WMI Provider.
20
-
21
-
The <xref:Microsoft.SqlServer.Management.Smo.Wmi.ManagedComputer> object operates independently of the connection established with the <xref:Microsoft.SqlServer.Management.Smo.Server> object to an instance of [!INCLUDE[ssNoVersion](../../../includes/ssnoversion-md.md)], and uses Windows credentials to connect to the WMI service.
22
-
23
-
## Example
24
-
To use any code example that is provided, you will have to choose the programming environment, the programming template, and the programming language in which to create your application. For more information, see [Create a Visual C# SMO Project in Visual Studio .NET](../../../relational-databases/server-management-objects-smo/how-to-create-a-visual-csharp-smo-project-in-visual-studio-net.md).
25
-
26
-
27
-
For programs that use the [!INCLUDE[ssNoVersion](../../../includes/ssnoversion-md.md)] WMI provider, you must include the **Imports** statement to qualify the WMI namespace. Insert the statement after the other **Imports** statements, before any declarations in the application, such as:
28
-
29
-
`Imports Microsoft.SqlServer.Management.Smo`
30
-
31
-
`Imports Microsoft.SqlServer.Management.Common`
32
-
33
-
`Imports Microsoft.SqlServer.Management.Smo.Wmi`
34
-
35
-
## Stopping and Restarting the Microsoft SQL Server Service to the Instance of SQL Server in Visual Basic
36
-
This code example shows how to stop and start services by using the SMO <xref:Microsoft.SqlServer.Management.Smo.Wmi.ManagedComputer> object. This provides an interface to the WMI Provider for Configuration Management.
37
-
38
-
```VBNET
39
-
'Declare and create an instance of the ManagedComputer object that represents the WMI Provider services.
21
+
The WMI provider is a published interface that is used by [!INCLUDE[msCoName](../../../includes/msconame-md.md)] Management Console (MMC) to manage the [!INCLUDE[ssNoVersion](../../../includes/ssnoversion-md.md)] services and network protocols. In SMO, the <xref:Microsoft.SqlServer.Management.Smo.Wmi.ManagedComputer> object represents the WMI provider.
22
+
23
+
The <xref:Microsoft.SqlServer.Management.Smo.Wmi.ManagedComputer> object operates independently of the connection established with the <xref:Microsoft.SqlServer.Management.Smo.Server> object to an instance of [!INCLUDE[ssNoVersion](../../../includes/ssnoversion-md.md)], and uses Windows credentials to connect to the WMI service.
24
+
25
+
## Examples
26
+
27
+
To use any code example that is provided, choose the programming environment, template, and language in which to create your application. For more information, see [How to Create a Visual C# SMO Project in Visual Studio .NET](../how-to-create-a-visual-csharp-smo-project-in-visual-studio-net.md).
28
+
29
+
For programs that use the [!INCLUDE[ssNoVersion](../../../includes/ssnoversion-md.md)] WMI provider, you must include the `Imports` statement to qualify the WMI namespace. Insert the statement after the other `Imports` statements, before any declarations in the application, such as:
30
+
31
+
`Imports Microsoft.SqlServer.Management.Smo`
32
+
`Imports Microsoft.SqlServer.Management.Common`
33
+
`Imports Microsoft.SqlServer.Management.Smo.Wmi`
34
+
35
+
36
+
## Stop and restart the SQL Server service in Visual Basic
37
+
38
+
This code example shows how to stop and start services by using the SMO <xref:Microsoft.SqlServer.Management.Smo.Wmi.ManagedComputer> object. This provides an interface to the WMI provider for Configuration Management.
39
+
40
+
```vbnet
41
+
'Declare and create an instance of the ManagedComputer object that represents the WMI provider services.
40
42
DimmcAsManagedComputer
41
43
mc=NewManagedComputer()
42
-
'Iterate through each service registered with the WMI Provider.
44
+
'Iterate through each service registered with the WMI provider.
43
45
DimsvcAsService
44
46
ForEachsvcInmc.Services
45
47
Console.WriteLine(svc.Name)
46
48
Next
47
-
'Reference the Microsoft SQL Server service.
49
+
'Reference the SQL Server service.
48
50
svc=mc.Services("MSSQLSERVER")
49
51
'Stop the service if it is running and report on the status continuously until it has stopped.
50
52
Ifsvc.ServiceState=ServiceState.RunningThen
@@ -68,141 +70,147 @@ Else
68
70
Console.WriteLine("SQL Server service is not running.")
69
71
EndIf
70
72
```
71
-
72
-
## Enabling a Server Protocol using a URN String in Visual Basic
73
-
The code example shows how to identify a server protocol using a URN object, and then enable the protocol.
74
-
75
-
```VBNET
76
-
'This program must run with administrator privileges.
77
-
'Declare the ManagedComputer WMI interface.
78
-
DimmcAsNewManagedComputer()
79
-
80
-
'Create a URN object that represents the TCP server protocol.
0 commit comments