Torna al Thread
Dim wmiComputer As Object = GetObject("winmgmts:" & "\\.\root\Microsoft\SqlServer\ComputerManagement")
Dim tcpProperties As Object = wmiComputer.ExecQuery("select * from ServerNetworkProtocolProperty " & "where InstanceName='SQLEXPRESS'")
For Each tcpProperty In tcpProperties
Dim setValueResult, requestedValue
Dim agisci As Boolean = False
requestedValue = ""
If tcpProperty.PropertyName = "TcpPort" Then
requestedValue = "1433"
agisci = True
ElseIf tcpProperty.PropertyName = "TcpDynamicPorts" Then
requestedValue = ""
agisci = True
End If
If agisci = True Then
setValueResult = tcpProperty.SetStringValue(requestedValue)
If setValueResult = 0 Then
MessageBox.Show(tcpProperty.PropertyName & " set.")
Else
MessageBox.Show(tcpProperty.PropertyName & " failed!")
End If
End If
Next