ManagementScope Construtores
Definição
Inicializa uma nova instância da classe ManagementScope.Initializes a new instance of the ManagementScope class.
Sobrecargas
| ManagementScope() |
Inicializa uma nova instância da classe ManagementScope, com valores padrão.Initializes a new instance of the ManagementScope class, with default values. Esse é o construtor sem parâmetros.This is the parameterless constructor. |
| ManagementScope(ManagementPath) |
Inicializa uma nova instância da classe ManagementScope que representa o caminho do escopo especificado.Initializes a new instance of the ManagementScope class representing the specified scope path. |
| ManagementScope(String) |
Inicializa uma nova instância da classe ManagementScope que representa o caminho do escopo especificado.Initializes a new instance of the ManagementScope class representing the specified scope path. |
| ManagementScope(ManagementPath, ConnectionOptions) |
Inicializa uma nova instância da classe ManagementScope que representa o caminho do escopo especificado, com as opções especificadas.Initializes a new instance of the ManagementScope class representing the specified scope path, with the specified options. |
| ManagementScope(String, ConnectionOptions) |
Inicializa uma nova instância da classe ManagementScope que representa o caminho do escopo especificado, com as opções especificadas.Initializes a new instance of the ManagementScope class representing the specified scope path, with the specified options. |
ManagementScope()
Inicializa uma nova instância da classe ManagementScope, com valores padrão.Initializes a new instance of the ManagementScope class, with default values. Esse é o construtor sem parâmetros.This is the parameterless constructor.
public:
ManagementScope();
public ManagementScope ();
Public Sub New ()
Comentários
Se o objeto não tiver nenhuma propriedade definida antes da conexão, ele será inicializado com valores padrão (por exemplo, o computador local e o namespace root\cimv2).If the object does not have any properties set before connection, it is initialized with default values (for example, the local machine and the root\cimv2 namespace).
Segurança do .NET Framework.NET Framework Security
Confiança total para o chamador imediato.Full trust for the immediate caller. Este membro não pode ser usado pelo código parcialmente confiável.This member cannot be used by partially trusted code. Para obter mais informações, consulte usando bibliotecas de código parcialmente confiável.For more information, see Using Libraries from Partially Trusted Code.
Aplica-se a
ManagementScope(ManagementPath)
Inicializa uma nova instância da classe ManagementScope que representa o caminho do escopo especificado.Initializes a new instance of the ManagementScope class representing the specified scope path.
public:
ManagementScope(System::Management::ManagementPath ^ path);
public ManagementScope (System.Management.ManagementPath path);
new System.Management.ManagementScope : System.Management.ManagementPath -> System.Management.ManagementScope
Public Sub New (path As ManagementPath)
Parâmetros
- path
- ManagementPath
Um ManagementPath que contém o caminho para um servidor e um namespace para o ManagementScope.A ManagementPath containing the path to a server and namespace for the ManagementScope.
Comentários
Segurança do .NET Framework.NET Framework Security
Confiança total para o chamador imediato.Full trust for the immediate caller. Este membro não pode ser usado pelo código parcialmente confiável.This member cannot be used by partially trusted code. Para obter mais informações, consulte usando bibliotecas de código parcialmente confiável.For more information, see Using Libraries from Partially Trusted Code.
Aplica-se a
ManagementScope(String)
Inicializa uma nova instância da classe ManagementScope que representa o caminho do escopo especificado.Initializes a new instance of the ManagementScope class representing the specified scope path.
public:
ManagementScope(System::String ^ path);
public ManagementScope (string path);
new System.Management.ManagementScope : string -> System.Management.ManagementScope
Public Sub New (path As String)
Parâmetros
- path
- String
O servidor e caminho do namespace do ManagementScope.The server and namespace path for the ManagementScope.
Exemplos
O exemplo a seguir inicializa um novo ManagementScope com um caminho específico e, em seguida, conecta o objeto de escopo a um namespace WMI.The following example initializes a new ManagementScope with a specific path and then connects the scope object to a WMI namespace. O exemplo se conecta a um namespace em um computador remoto.The example connects to a namespace on a remote computer.
using System;
using System.Management;
public class RemoteConnect
{
public static void Main()
{
/*// Build an options object for the remote connection
// if you plan to connect to the remote
// computer with a different user name
// and password than the one you are currently using
ConnectionOptions options =
new ConnectionOptions();
// and then set the options.Username and
// options.Password properties to the correct values
// and also set
// options.Authority = "ntlmdomain:DOMAIN";
// and replace DOMAIN with the remote computer's
// domain. You can also use Kerberos instead
// of ntlmdomain.
*/
// Make a connection to a remote computer.
// Replace the "FullComputerName" section of the
// string "\\\\FullComputerName\\root\\cimv2" with
// the full computer name or IP address of the
// remote computer.
ManagementScope scope =
new ManagementScope(
"\\\\FullComputerName\\root\\cimv2");
scope.Connect();
// Use this code if you are connecting with a
// different user name and password:
//
// ManagementScope scope =
// new ManagementScope(
// "\\\\FullComputerName\\root\\cimv2", options);
// scope.Connect();
//Query system for Operating System information
ObjectQuery query = new ObjectQuery(
"SELECT * FROM Win32_OperatingSystem");
ManagementObjectSearcher searcher =
new ManagementObjectSearcher(scope,query);
ManagementObjectCollection queryCollection = searcher.Get();
foreach ( ManagementObject m in queryCollection)
{
// Display the remote computer information
Console.WriteLine("Computer Name : {0}",
m["csname"]);
Console.WriteLine("Windows Directory : {0}",
m["WindowsDirectory"]);
Console.WriteLine("Operating System: {0}",
m["Caption"]);
Console.WriteLine("Version: {0}", m["Version"]);
Console.WriteLine("Manufacturer : {0}",
m["Manufacturer"]);
}
}
}
Imports System.Management
Public Class RemoteConnect
Public Overloads Shared Function Main( _
ByVal args() As String) As Integer
' Build an options object for the remote connection
' if you plan to connect to the remote
' computer with a different user name
' and password than the one you are currently using
' Dim options As ConnectionOptions
' options = new ConnectionOptions()
' Then set the options.Username and
' options.Password properties to the correct values
' and also set
' options.Authority = "ntlmdomain:DOMAIN"
' and replace DOMAIN with the remote computer's
' domain. You can also use Kerberos instead
' of ntlmdomain.
' Make a connection to a remote computer.
' Replace the "FullComputerName" section of the
' string "\\FullComputerName\root\cimv2" with
' the full computer name or IP address of the
' remote computer.
Dim scope As ManagementScope
scope = New ManagementScope( _
"\\FullComputerName\root\cimv2")
scope.Connect()
' Use this code if you are connecting with a
' different user name and password:
'
' Dim scope As ManagementScope
' scope = New ManagementScope( _
' "\\FullComputerName\root\cimv2", options)
' scope.Connect()
' Query system for Operating System information
Dim query As ObjectQuery
query = New ObjectQuery( _
"SELECT * FROM Win32_OperatingSystem")
Dim searcher As ManagementObjectSearcher
searcher = _
New ManagementObjectSearcher(scope, query)
Dim queryCollection As ManagementObjectCollection
queryCollection = searcher.Get()
Dim m As ManagementObject
For Each m In queryCollection
' Display the remote computer information
Console.WriteLine("Computer Name : {0}", _
m("csname"))
Console.WriteLine("Windows Directory : {0}", _
m("WindowsDirectory"))
Console.WriteLine("Operating System: {0}", _
m("Caption"))
Console.WriteLine("Version: {0}", m("Version"))
Console.WriteLine("Manufacturer : {0}", _
m("Manufacturer"))
Next
Return 0
End Function
End Class
Comentários
Segurança do .NET Framework.NET Framework Security
Confiança total para o chamador imediato.Full trust for the immediate caller. Este membro não pode ser usado pelo código parcialmente confiável.This member cannot be used by partially trusted code. Para obter mais informações, consulte usando bibliotecas de código parcialmente confiável.For more information, see Using Libraries from Partially Trusted Code.
Aplica-se a
ManagementScope(ManagementPath, ConnectionOptions)
Inicializa uma nova instância da classe ManagementScope que representa o caminho do escopo especificado, com as opções especificadas.Initializes a new instance of the ManagementScope class representing the specified scope path, with the specified options.
public:
ManagementScope(System::Management::ManagementPath ^ path, System::Management::ConnectionOptions ^ options);
public ManagementScope (System.Management.ManagementPath path, System.Management.ConnectionOptions options);
new System.Management.ManagementScope : System.Management.ManagementPath * System.Management.ConnectionOptions -> System.Management.ManagementScope
Public Sub New (path As ManagementPath, options As ConnectionOptions)
Parâmetros
- path
- ManagementPath
Um ManagementPath que contém o caminho para o servidor e o namespace para o ManagementScope.A ManagementPath containing the path to the server and namespace for the ManagementScope.
- options
- ConnectionOptions
O ConnectionOptions que contém opções para a conexão.The ConnectionOptions containing options for the connection.
Comentários
Segurança do .NET Framework.NET Framework Security
Confiança total para o chamador imediato.Full trust for the immediate caller. Este membro não pode ser usado pelo código parcialmente confiável.This member cannot be used by partially trusted code. Para obter mais informações, consulte usando bibliotecas de código parcialmente confiável.For more information, see Using Libraries from Partially Trusted Code.
Aplica-se a
ManagementScope(String, ConnectionOptions)
Inicializa uma nova instância da classe ManagementScope que representa o caminho do escopo especificado, com as opções especificadas.Initializes a new instance of the ManagementScope class representing the specified scope path, with the specified options.
public:
ManagementScope(System::String ^ path, System::Management::ConnectionOptions ^ options);
public ManagementScope (string path, System.Management.ConnectionOptions options);
new System.Management.ManagementScope : string * System.Management.ConnectionOptions -> System.Management.ManagementScope
Public Sub New (path As String, options As ConnectionOptions)
Parâmetros
- path
- String
O servidor e o namespace do ManagementScope.The server and namespace for the ManagementScope.
- options
- ConnectionOptions
Um ConnectionOptions que contém opções para a conexão.A ConnectionOptions containing options for the connection.
Exemplos
O exemplo a seguir inicializa um novo ManagementScope com um caminho específico e, em seguida, conecta o objeto de escopo a um namespace WMI.The following example initializes a new ManagementScope with a specific path and then connects the scope object to a WMI namespace. O exemplo se conecta a um namespace em um computador remoto.The example connects to a namespace on a remote computer.
using System;
using System.Management;
public class RemoteConnect
{
public static void Main()
{
/*// Build an options object for the remote connection
// if you plan to connect to the remote
// computer with a different user name
// and password than the one you are currently using
ConnectionOptions options =
new ConnectionOptions();
// and then set the options.Username and
// options.Password properties to the correct values
// and also set
// options.Authority = "ntlmdomain:DOMAIN";
// and replace DOMAIN with the remote computer's
// domain. You can also use Kerberos instead
// of ntlmdomain.
*/
// Make a connection to a remote computer.
// Replace the "FullComputerName" section of the
// string "\\\\FullComputerName\\root\\cimv2" with
// the full computer name or IP address of the
// remote computer.
ManagementScope scope =
new ManagementScope(
"\\\\FullComputerName\\root\\cimv2");
scope.Connect();
// Use this code if you are connecting with a
// different user name and password:
//
// ManagementScope scope =
// new ManagementScope(
// "\\\\FullComputerName\\root\\cimv2", options);
// scope.Connect();
//Query system for Operating System information
ObjectQuery query = new ObjectQuery(
"SELECT * FROM Win32_OperatingSystem");
ManagementObjectSearcher searcher =
new ManagementObjectSearcher(scope,query);
ManagementObjectCollection queryCollection = searcher.Get();
foreach ( ManagementObject m in queryCollection)
{
// Display the remote computer information
Console.WriteLine("Computer Name : {0}",
m["csname"]);
Console.WriteLine("Windows Directory : {0}",
m["WindowsDirectory"]);
Console.WriteLine("Operating System: {0}",
m["Caption"]);
Console.WriteLine("Version: {0}", m["Version"]);
Console.WriteLine("Manufacturer : {0}",
m["Manufacturer"]);
}
}
}
Imports System.Management
Public Class RemoteConnect
Public Overloads Shared Function Main( _
ByVal args() As String) As Integer
' Build an options object for the remote connection
' if you plan to connect to the remote
' computer with a different user name
' and password than the one you are currently using
' Dim options As ConnectionOptions
' options = new ConnectionOptions()
' Then set the options.Username and
' options.Password properties to the correct values
' and also set
' options.Authority = "ntlmdomain:DOMAIN"
' and replace DOMAIN with the remote computer's
' domain. You can also use Kerberos instead
' of ntlmdomain.
' Make a connection to a remote computer.
' Replace the "FullComputerName" section of the
' string "\\FullComputerName\root\cimv2" with
' the full computer name or IP address of the
' remote computer.
Dim scope As ManagementScope
scope = New ManagementScope( _
"\\FullComputerName\root\cimv2")
scope.Connect()
' Use this code if you are connecting with a
' different user name and password:
'
' Dim scope As ManagementScope
' scope = New ManagementScope( _
' "\\FullComputerName\root\cimv2", options)
' scope.Connect()
' Query system for Operating System information
Dim query As ObjectQuery
query = New ObjectQuery( _
"SELECT * FROM Win32_OperatingSystem")
Dim searcher As ManagementObjectSearcher
searcher = _
New ManagementObjectSearcher(scope, query)
Dim queryCollection As ManagementObjectCollection
queryCollection = searcher.Get()
Dim m As ManagementObject
For Each m In queryCollection
' Display the remote computer information
Console.WriteLine("Computer Name : {0}", _
m("csname"))
Console.WriteLine("Windows Directory : {0}", _
m("WindowsDirectory"))
Console.WriteLine("Operating System: {0}", _
m("Caption"))
Console.WriteLine("Version: {0}", m("Version"))
Console.WriteLine("Manufacturer : {0}", _
m("Manufacturer"))
Next
Return 0
End Function
End Class
Comentários
Segurança do .NET Framework.NET Framework Security
Confiança total para o chamador imediato.Full trust for the immediate caller. Este membro não pode ser usado pelo código parcialmente confiável.This member cannot be used by partially trusted code. Para obter mais informações, consulte usando bibliotecas de código parcialmente confiável.For more information, see Using Libraries from Partially Trusted Code.