Hintergrund:
http://www.mcseboard.de/windows-foru...ic-132144.html
Vorweg, ich bin kein Entwickler, daher brauche ich euere Hilfe beim Erstellen eines Scripts. Das Script soll ein VLAN auf einem PC erstellen. Das kann ich nur per WMI machen.
Ich habe mit dem WMI Code Creator (von Microsoft ein Tool) folgenden Code erstellt:
Code für C#
Code:
using System;
using System.Management;
using System.Windows.Forms;
namespace WMISample
{
public class CallWMIMethod
{
public static void Main()
{
try
{
ManagementObject classInstance =
new ManagementObject("root\\IntelNCS2",
"IANet_802dot1QVLANService.CreationClassName='IANet_802dot1QVLANService',Name='{8AAEE732-49A0-43B3-A5C1-B36CDD16E79E}',SystemCreationClassName='Win32_ComputerSystem',SystemName='W-4DE-0004'",
null);
// Obtain in-parameters for the method
ManagementBaseObject inParams =
classInstance.GetMethodParameters("CreateVLAN");
// Add the input parameters.
inParams["Name"] = "VLAN1";
inParams["VLANNumber"] = 1;
// Execute the method and obtain the return values.
ManagementBaseObject outParams =
classInstance.InvokeMethod("CreateVLAN", inParams, null);
// List outParams
Console.WriteLine("Out parameters:");
Console.WriteLine("ReturnValue: " + outParams["ReturnValue"]);
Console.WriteLine("VLANpath: " + outParams["VLANpath"]);
}
catch(ManagementException err)
{
MessageBox.Show("An error occurred while trying to execute the WMI method: " + err.Message);
}
}
}
}
Code mit VBS:
Code:
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\IntelNCS2")
' Obtain an instance of the the class
' using a key property value.
Set objShare = objWMIService.Get("IANet_802dot1QVLANService.CreationClassName='IANet_802dot1QVLANService',Name='{8AAEE732-49A0-43B3-A5C1-B36CDD16E79E}',SystemCreationClassName='Win32_ComputerSystem',SystemName='W-4DE-0004'")
' Obtain an InParameters object specific
' to the method.
Set objInParam = objShare.Methods_("CreateVLAN"). _
inParameters.SpawnInstance_()
' Add the input parameters.
objInParam.Properties_.Item("Name") = "VLAN1"
objInParam.Properties_.Item("VLANNumber") = 1
' Execute the method and obtain the return status.
' The OutParameters object in objOutParams
' is created by the provider.
Set objOutParams = objWMIService.ExecMethod("IANet_802dot1QVLANService.CreationClassName='IANet_802dot1QVLANService',Name='{8AAEE732-49A0-43B3-A5C1-B36CDD16E79E}',SystemCreationClassName='Win32_ComputerSystem',SystemName='W-4DE-0004'", "CreateVLAN", objInParam)
' List OutParams
Wscript.Echo "Out Parameters: "
Wscript.echo "ReturnValue: " & objOutParams.ReturnValue
Wscript.echo "VLANpath: " & objOutParams.VLANpath
Ich erhalte leider nur folgende Meldung:
---------------------------
---------------------------
An error occurred while trying to execute the WMI method: Allgemeiner Fehler
---------------------------
OK
---------------------------
Intel stellt folgendes Dokument für die Entwicklung bereit:
(muss ich erst raussuchen, in dem Wildwuchs von Schrott finde ich das da jetzt nicht auf die Schnelle)