Nota
El acceso a esta página requiere autorización. Puede intentar iniciar sesión o cambiar directorios.
El acceso a esta página requiere autorización. Puede intentar cambiar los directorios.
Puede importar un controlador de Windows descrito por un archivo Txtsetup.oem, en Configuration Manager, mediante el método CreateFromOEM de la clase SMS_Driver. Configuration Manager puede crear automáticamente definiciones para la mayoría de los controladores a partir de un archivo .inf. Sin embargo, al instalar controladores de almacenamiento masivo en sistemas operativos anteriores a Windows Vista, Configuration Manager también deben tener cierta información contenida en el archivo Txtsetup.oem. Para facilitar esto, CreateFromOEM
crea SMS_Driver objetos de clase WMI de servidor para cada archivo .inf al que se hace referencia en el archivo Txtsetup.oem. A continuación, tiene la oportunidad de personalizar las propiedades del controlador antes de guardarlas.
Nota:
Si un fabricante de controladores ha proporcionado un archivo Txtsetup.oem, debe importar el controlador mediante este procedimiento en lugar de los archivos .inf si tiene previsto implementar Windows 2000, Windows XP o Windows Server 2003.
Para importar un controlador de Windows
Configure una conexión con el proveedor de SMS. Para obtener más información, consulte Aspectos básicos del proveedor de SMS.
Llame al método CreateFromOEM de la clase SMS_Driver para obtener una colección de objetos base de administración.
Para los objetos base de administración, cree un objeto SMS_Driver para cada controlador.
Rellene el objeto SMS_Driver.
Confirme el objeto SMS_Driver.
Ejemplo
El siguiente método de ejemplo crea un objeto SMS_Driver para un controlador de Windows mediante la ruta de acceso proporcionada y el nombre de archivo Txtsetup.oem. En el ejemplo también se habilita el controlador estableciendo el valor de la propiedad IsEnabled en true
. La función GetDriverName
auxiliar se usa para obtener el nombre del controlador del XML del paquete de controladores.
Nota:
El path
parámetro debe proporcionarse como una ruta de acceso de red de convención de nomenclatura universal (UNC), por ejemplo, \\localhost\Drivers\VMSCSI\.
En el ejemplo, la LocaleID
propiedad está codificada de forma rígida en inglés (EE. UU.). Si necesita la configuración regional para los estados que no son de EE. UU. instalaciones, puede obtenerla de la propiedad SMS_Identification ClaseLocaleID
WMI de servidor.
Para obtener información sobre cómo llamar al código de ejemplo, vea Llamar a fragmentos de código de Configuration Manager.
Sub ImportOemDriver(connection,path,name)
Dim inParams
Dim outParams
Dim driver
Dim driverClass
On Error Resume Next
Set driverClass = connection.Get("SMS_Driver")
Set inParams = driverClass.Methods_("CreateFromOEM").inParameters.SpawnInstance_()
' Set the driver path and INF file.
inParams.Properties_.item("DriverPath") = path
inParams.Properties_.item("OEMFile") = name
' Execute the method.
Set outParams = driverClass.ExecMethod_("CreateFromOEM", inParams)
If Err <> 0 Then
Wscript.Echo "Failed to import driver: " + path +"\" + name
Exit Sub
End If
For Each driver In outParams.Drivers
' Set driver name and enable the driver.
Dim LocalizedSettings
LocalizedSettings = array(0)
Set LocalizedSettings(0) = connection.Get("SMS_CI_LocalizedProperties").SpawnInstance_()
LocalizedSettings(0).Properties_.item("LocaleID") = 1033
LocalizedSettings(0).Properties_.item("DisplayName") = _
GetDriverName(driver.Properties_.item("SDMPackageXML"), "//DisplayName", "Text")
LocalizedSettings(0).Properties_.item("Description") = ""
driver.Properties_.item("LocalizedInformation") = LocalizedSettings
driver.Properties_.item("IsEnabled") = true
driver.Put_
Next
End Sub
Function GetDriverName(xmlContent, nodeName, attributeName)
' Load the XML Document
Dim attrValue
Dim XMLDoc
Dim objNode
Dim displayNameNode
attrValue = ""
Set XMLDoc = CreateObject("Microsoft.XMLDOM")
XMLDoc.async = False
XMLDoc.loadXML(xmlContent)
'Check for a successful load of the XML Document.
If xmlDoc.parseError.errorCode <> 0 Then
WScript.Echo vbcrlf & "Error loading XML Document. Error Code : 0x" & hex(xmldoc.parseerror.errorcode)
WScript.Echo "Reason: " & xmldoc.parseerror.reason
WScript.Echo "Parse Error line " & xmldoc.parseError.line & ", character " & _
xmldoc.parseError.linePos & vbCrLf & xmldoc.parseError.srcText
GetXMLAttributeValue = ""
Else
' Select the node
Set objNode = xmlDoc.SelectSingleNode(nodeName)
If Not objNode Is Nothing Then
' Found the element, now just pick up the Text attribute value
Set displayNameNode = objNode.attributes.getNamedItem(attributeName)
If Not displayNameNode Is Nothing Then
attrValue = displayNameNode.value
Else
WScript.Echo "Attribute not found"
End If
Else
WScript.Echo "Failed to locate " & nodeName & " element."
End If
End If
' Save the results
GetDriverName = attrValue
End Function
public void ImportOemDriver(
WqlConnectionManager connection,
string path,
string name)
{
try
{
Dictionary<string, object> inParams = new Dictionary<string, object>();
// Set up parameters for the path and file name.
inParams.Add("DriverPath", path);
inParams.Add("OEMFile", name);
// Import the INF file.
IResultObject outParams = connection.ExecuteMethod("SMS_Driver", "CreateFromOEM", inParams);
// Create the driver instance from the management base object returned in result["Drivers"].
foreach (object obj in outParams["Drivers"].ObjectArrayValue)
{
IResultObject driver = connection.CreateInstance(obj);
driver["IsEnabled"].BooleanValue = true;
List<IResultObject> driverInformationList = driver.GetArrayItems("LocalizedInformation");
// Set up the display name and other information.
IResultObject driverInfo = connection.CreateEmbeddedObjectInstance("SMS_CI_LocalizedProperties");
driverInfo["DisplayName"].StringValue = GetDriverName(driver);
driverInfo["LocaleID"].IntegerValue = 1033;
driverInfo["Description"].StringValue = "";
driverInformationList.Add(driverInfo);
driver.SetArrayItems("LocalizedInformation", driverInformationList);
// Commit the SMS_Driver object.
driver.Put();
}
}
catch (SmsException e)
{
Console.WriteLine("Failed to import driver: " + e.Message);
throw;
}
}
public string GetDriverName(IResultObject driver)
{
// Extract
XmlDocument sdmpackage = new XmlDocument();
sdmpackage.LoadXml(driver.Properties["SDMPackageXML"].StringValue);
// Iterate over all the <DisplayName/> tags.
foreach (XmlNode displayName in sdmpackage.GetElementsByTagName("DisplayName"))
{
// Grab the first one with a Text attribute not equal to null.
if (displayName != null && displayName.Attributes["Text"] != null
&& !string.IsNullOrEmpty(displayName.Attributes["Text"].Value))
{
// Return the DisplayName text.
return displayName.Attributes["Text"].Value;
}
}
// Default the driverName to the UniqueID.
return driver["CI_UniqueID"].StringValue;
}
El método de ejemplo tiene los parámetros siguientes:
Parámetro | Tipo | Descripción |
---|---|---|
Connection |
-Administrado: WqlConnectionManager - VBScript: SWbemServices |
Una conexión válida al proveedor de SMS. |
path |
-Administrado: String -Vbscript: String |
Ruta de acceso de red UNC válida a la carpeta que contiene el contenido del controlador. Por ejemplo, \\Servers\Driver\VideoDriver. |
name |
-Administrado: String -Vbscript: String |
Nombre del archivo Txtsetup.oem. Por ejemplo, puede tener \\server\drivers\Video for path y Txtsetup.oem para name . |
Compilar el código
Este ejemplo de C# requiere:
Espacios de nombres
System
System.Collections.Generic
System.Text
Microsoft. ConfigurationManagement.ManagementProvider
Microsoft. ConfigurationManagement.ManagementProvider.WqlQueryEngine
Ensamblado
microsoft.configurationmanagement.managementprovider
adminui.wqlqueryengine
Programación sólida
Para obtener más información sobre el control de errores, consulte Acerca de los errores de Configuration Manager.
Seguridad de .NET Framework
Para obtener más información sobre la protección de aplicaciones Configuration Manager, consulte Configuration Manager administración basada en roles.
Vea también
Cómo especificar las plataformas admitidas para un controlador