Win32_PerfRawData_Tcpip_NetworkInterface - Windows 7 Alternative

  • Mon zusammen,

    ist zwar kein wirkliches AutoIt Problem, weis aber sonst nicht wo ich fragen könnte :(

    Kennt jemand eine Alternative zu Win32_PerfRawData_Tcpip_NetworkInterface (WMI)?

    Sinn ist, dass ich die Netzwerkauslastung einzelner Adapter auslesen möchte. Früher gings ja mit Win32_PerfRawData_Tcpip_NetworkInterface nur finde ich keine Alternative bei Win7

    Wäre echt dankbar, wenn mir da einer helfen könnte

    Gruß
    MrB

  • Sollte unter Win 7 eigentlich noch funktionieren. zumindest sagt mir das Google.

    Ich selbst habe keine Ahnung wovon du sprichst aber per Google habe ich nen Script für Winddows 7 in gefunden wo "Win32_PerfRawData_Tcpip_NetworkInterface" benutzt wird.

    (http://globales-irc.net/index.php?page=Thread&threadID=118)

    Dieser Beitrag wurde 9521 mal editiert, zum letzten Mal von Blubkuh: Morgen, 02:28.

    [autoit]

    If Not $Elephant Then $Irelephant = True

    [/autoit]
  • Hi,
    eben per AutoIt Scriptomatic folgendes Script erstellen lassen

    Spoiler anzeigen
    [autoit]

    ; Generated by AutoIt Scriptomatic

    [/autoit] [autoit][/autoit] [autoit]

    $wbemFlagReturnImmediately = 0x10
    $wbemFlagForwardOnly = 0x20
    $colItems = ""
    $strComputer = "localhost"

    [/autoit] [autoit][/autoit] [autoit]

    $Output=""
    $Output = $Output & "Computer: " & $strComputer & @CRLF
    $Output = $Output & "==========================================" & @CRLF
    $objWMIService = ObjGet("winmgmts:\" & $strComputer & "")
    $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_PerfRawData_Tcpip_NetworkInterface", "WQL", _
    $wbemFlagReturnImmediately + $wbemFlagForwardOnly)

    [/autoit] [autoit][/autoit] [autoit]

    If IsObj($colItems) then
    For $objItem In $colItems
    $Output = $Output & "BytesReceivedPersec: " & $objItem.BytesReceivedPersec & @CRLF
    $Output = $Output & "BytesSentPersec: " & $objItem.BytesSentPersec & @CRLF
    $Output = $Output & "BytesTotalPersec: " & $objItem.BytesTotalPersec & @CRLF
    $Output = $Output & "Caption: " & $objItem.Caption & @CRLF
    $Output = $Output & "CurrentBandwidth: " & $objItem.CurrentBandwidth & @CRLF
    $Output = $Output & "Description: " & $objItem.Description & @CRLF
    $Output = $Output & "Frequency_Object: " & $objItem.Frequency_Object & @CRLF
    $Output = $Output & "Frequency_PerfTime: " & $objItem.Frequency_PerfTime & @CRLF
    $Output = $Output & "Frequency_Sys100NS: " & $objItem.Frequency_Sys100NS & @CRLF
    $Output = $Output & "Name: " & $objItem.Name & @CRLF
    $Output = $Output & "OffloadedConnections: " & $objItem.OffloadedConnections & @CRLF
    $Output = $Output & "OutputQueueLength: " & $objItem.OutputQueueLength & @CRLF
    $Output = $Output & "PacketsOutboundDiscarded: " & $objItem.PacketsOutboundDiscarded & @CRLF
    $Output = $Output & "PacketsOutboundErrors: " & $objItem.PacketsOutboundErrors & @CRLF
    $Output = $Output & "PacketsPersec: " & $objItem.PacketsPersec & @CRLF
    $Output = $Output & "PacketsReceivedDiscarded: " & $objItem.PacketsReceivedDiscarded & @CRLF
    $Output = $Output & "PacketsReceivedErrors: " & $objItem.PacketsReceivedErrors & @CRLF
    $Output = $Output & "PacketsReceivedNonUnicastPersec: " & $objItem.PacketsReceivedNonUnicastPersec & @CRLF
    $Output = $Output & "PacketsReceivedPersec: " & $objItem.PacketsReceivedPersec & @CRLF
    $Output = $Output & "PacketsReceivedUnicastPersec: " & $objItem.PacketsReceivedUnicastPersec & @CRLF
    $Output = $Output & "PacketsReceivedUnknown: " & $objItem.PacketsReceivedUnknown & @CRLF
    $Output = $Output & "PacketsSentNonUnicastPersec: " & $objItem.PacketsSentNonUnicastPersec & @CRLF
    $Output = $Output & "PacketsSentPersec: " & $objItem.PacketsSentPersec & @CRLF
    $Output = $Output & "PacketsSentUnicastPersec: " & $objItem.PacketsSentUnicastPersec & @CRLF
    $Output = $Output & "Timestamp_Object: " & $objItem.Timestamp_Object & @CRLF
    $Output = $Output & "Timestamp_PerfTime: " & $objItem.Timestamp_PerfTime & @CRLF
    $Output = $Output & "Timestamp_Sys100NS: " & $objItem.Timestamp_Sys100NS & @CRLF
    if Msgbox(1,"WMI Output",$Output) = 2 then ExitLoop
    $Output=""
    Next
    Else
    Msgbox(0,"WMI Output","No WMI Objects Found for class: " & "Win32_PerfRawData_Tcpip_NetworkInterface" )
    Endif

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit]

    funktioniert bei mir Win7/64 einwandfrei

  • Kannst mir bitte mal einen Link zu Scriptomatic geben?

    Meine Version zeigt das noch nicht mal mehr an! Hmmm, scheint da wohl was nicht zu stimmen

  • Hi,

    LINK Scriptomatic

    Ich mache das sonst nicht, aber hier der von mir modifizierte Code von Scriptomatic. Ich habe einen Filter eingebaut, welcher innerhalb der WMI-Class nach dem eingegebenen Begriff filtert.
    Will ich nur die Netzwerk-Classes, gebe ich in der Inputbox net ein, und in der Auswahl erscheinen nur Classes, welche diesen Begriff im Namen haben.
    Beim Start braucht Scriptomatic etwas Zeit, um sämtliche registrierten Classes zu laden.

    Spoiler anzeigen
    [autoit]

    #Region ;**** Directives created by AutoIt3Wrapper_GUI ****
    #AutoIt3Wrapper_outfile=scriptomatic.exe
    #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>
    ; AutoIt ScriptOMatic
    ; -------------------
    ;
    ; AutoIt's counterpart of Microsoft's Scriptomatic
    ;
    ; Author: SvenP
    ; Date/version: 2005-04-17
    ; See also: http://www.microsoft.com/technet/script…s/scripto2.mspx
    ; Requires: AutoIt beta version 3.1.1.8 or higher (COM support!!)
    ;
    ; GUI generated by AutoBuilder 0.5 Prototype

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    ;************************
    ;* Global State Variables
    ;************************
    $g_strCurrentNamespace = "\root\CIMV2"
    $g_iCurrentNamespaceIndex = 0
    $g_strWMISource = "localhost"
    $g_strOutputFormat = "Dialog"
    Global $objClassDictionary
    ;************************
    ;* Main GUI
    ;************************

    [/autoit] [autoit][/autoit] [autoit]

    GuiCreate("AutoIt Scriptomatic Tool", 684, 561,(@DesktopWidth-684)/2, (@DesktopHeight-561)/2 , $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)

    [/autoit] [autoit][/autoit] [autoit]

    $GUI_AST_MainGroup = GuiCtrlCreateGroup("", 10, 10,660,530)
    $GUI_WMI_NamespaceLabel = GuiCtrlCreateLabel("WMI Namespace", 20, 30,150, 20)
    $GUI_WMI_Namespace = GuiCtrlCreateCombo("WMI_Namespaces", 20, 50,280, 80)
    $GUI_WMI_ClassLabel = GuiCtrlCreateLabel("WMI Class", 320, 30,80, 20)
    $GUI_WMI_Classes = GuiCtrlCreateCombo("WMI_Classes", 320, 50,340, 80)
    $GUI_WMI_Filter = GUICtrlCreateButton("Filter",450,25,70,20)

    [/autoit] [autoit][/autoit] [autoit]

    $GUI_AST_ButtonGroup = GuiCtrlCreateGroup("", 10, 80,660, 50)
    $GUI_AST_Run = GuiCtrlCreateButton("Run", 20,100, 50, 20)
    $GUI_AST_CIMv2 = GuiCtrlCreateButton("CIMv2", 80,100, 50, 20)
    $GUI_AST_WMISource = GuiCtrlCreateButton("WMISource", 140,100, 70, 20)
    $GUI_AST_Open = GuiCtrlCreateButton("Open", 220,100, 60, 20)
    $GUI_AST_Save = GuiCtrlCreateButton("Save", 290,100, 60, 20)
    $GUI_AST_Quit = GuiCtrlCreateButton("Quit", 360,100, 60, 20)
    $GUI_AST_OptionGroup = GuiCtrlCreateGroup("Output", 430, 80,240, 50)
    $GUI_AST_RadioDialog = GuiCtrlCreateRadio("Dialog", 440,100, 50, 20)
    $GUI_AST_RadioText = GuiCtrlCreateRadio("Text", 510,100, 50, 20)
    $GUI_AST_RadioHTML = GuiCtrlCreateRadio("HTML", 570,100, 50, 20)
    $GUI_AST_ScriptCode = GuiCtrlCreateEdit("One moment...", 20,140,640,390)

    [/autoit] [autoit][/autoit] [autoit]

    GuiSetState()

    [/autoit] [autoit][/autoit] [autoit]

    ; Initial GUI Settings
    GUICtrlSetState($GUI_AST_RUN, $GUI_DISABLE)
    GUICtrlSetState($GUI_AST_SAVE, $GUI_DISABLE)
    GUICtrlSetState($GUI_AST_RadioDialog,$GUI_CHECKED)

    [/autoit] [autoit][/autoit] [autoit]

    GUICtrlSetState($GUI_WMI_Filter, $GUI_DISABLE)

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    ; Fill the WMI_Namespaces Combobox
    LoadWMINamespaces()

    [/autoit] [autoit][/autoit] [autoit]

    ; Fill the WMI_Classes Combobox
    HandleNamespaceChange()
    GUICtrlSetState($GUI_WMI_Filter, $GUI_ENABLE)

    [/autoit] [autoit][/autoit] [autoit]

    While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
    ExitLoop
    Case $msg = $GUI_AST_QUIT
    ExitLoop
    Case $msg = $GUI_WMI_Filter
    filter()
    Case $msg = $GUI_WMI_Namespace
    HandleNameSpaceChange()
    Case $msg = $GUI_WMI_Classes
    ComposeCode()
    Case $msg = $GUI_AST_Run
    RunScript()
    Case $msg = $GUI_AST_Save
    SaveScript()
    Case $msg = $GUI_AST_Open
    OpenScript()
    Case $msg = $GUI_AST_CIMv2
    SetNamespaceToCIMV2()
    Case $msg = $GUI_AST_WMISource
    SetWMIRepository()
    Case $msg = $GUI_AST_RadioDialog or _
    $msg = $GUI_AST_RadioText or _
    $msg = $GUI_AST_RadioHTML
    HandleOutputChange()
    EndSelect
    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    GUIDelete()

    [/autoit] [autoit][/autoit] [autoit]

    Exit

    [/autoit] [autoit][/autoit] [autoit]

    ;********************************************************************
    ;* LoadWMINamespaces
    ;********************************************************************
    Func LoadWMINamespaces()
    $strCsvListOfNamespaces = ""
    $strNameSpacesCombo=""

    [/autoit] [autoit][/autoit] [autoit]

    $strWaitNamespaces="Please wait, Loading WMI Namespaces"
    GUICtrlSetData($GUI_WMI_Namespace,$strWaitNamespaces,$strWaitNamespaces)

    [/autoit] [autoit][/autoit] [autoit]

    EnumNameSpaces("root", $strCsvListOfNamespaces)

    [/autoit] [autoit][/autoit] [autoit]

    $arrNamespaces = StringSplit($strCsvListOfNamespaces, ",")

    [/autoit] [autoit][/autoit] [autoit]

    For $strNamespace in $arrNamespaces
    $strNameSpacesCombo = $strNameSpacesCombo & "|" & $strNamespace
    Next

    [/autoit] [autoit][/autoit] [autoit]

    GUICtrlSetData($GUI_WMI_Namespace,$strNameSpacesCombo,"ROOT\CIMV2")

    [/autoit] [autoit][/autoit] [autoit]

    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    ;********************************************************************
    ;* EnumNamespaces
    ;********************************************************************
    Func EnumNamespaces($strNamespace, ByRef $tmpCsvListOfNamespaces)

    [/autoit] [autoit][/autoit] [autoit]

    If $tmpCsvListOfNamespaces = "" Then
    $tmpCsvListOfNamespaces = $strNamespace
    Else
    $tmpCsvListOfNamespaces = $tmpCsvListOfNamespaces & "," & $strNamespace
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    $strComputer = $g_strWMISource
    $objWMIService = ObjGet("winmgmts:" & $g_strWMISource & "" & $strNameSpace)

    [/autoit] [autoit][/autoit] [autoit]

    If not @error Then

    [/autoit] [autoit][/autoit] [autoit]

    $colNameSpaces = $objWMIService.InstancesOf("__NAMESPACE")

    [/autoit] [autoit][/autoit] [autoit]

    For $objNameSpace In $colNameSpaces
    EnumNamespaces($strNameSpace & "" & $objNameSpace.Name, $tmpCsvListOfNamespaces)
    Next
    Else
    $tmpCsvListOfNamespaces=""
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    ;********************************************************************
    ;* HandleNamespaceChange
    ;********************************************************************
    Func HandleNamespaceChange()

    [/autoit] [autoit][/autoit] [autoit]

    ;'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    ; Clear the WMI classes pulldown location.
    ;'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    $strSelectedNamespace = GUICtrlRead ( $GUI_WMI_Namespace )

    [/autoit] [autoit][/autoit] [autoit]

    ; Disable the namespace combobox until class load has been completed
    GUICtrlSetState($GUI_WMI_Namespace, $GUI_DISABLE)

    [/autoit] [autoit][/autoit] [autoit]

    $strWMIWaitMsg = "Please wait, trying to load WMI Classes in namespace " & $strSelectedNamespace
    GUICtrlSetData($GUI_WMI_Classes, $strWMIWaitMsg, $strWMIWaitMsg)
    GUICtrlSetData($GUI_AST_ScriptCode,"One moment...","")

    [/autoit] [autoit][/autoit] [autoit]

    LoadWMIClasses()
    $g_strCurrentNamespace = "" & $strSelectedNamespace

    [/autoit] [autoit][/autoit] [autoit]

    ;'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    ; Clear the code textarea and disable run and save.
    ;'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    GUICtrlSetData($GUI_AST_ScriptCode,"","")

    [/autoit] [autoit][/autoit] [autoit]

    GUICtrlSetState($GUI_WMI_Namespace, $GUI_ENABLE)
    GUICtrlSetState($GUI_AST_RUN, $GUI_DISABLE)
    GUICtrlSetState($GUI_AST_SAVE, $GUI_DISABLE)

    [/autoit] [autoit][/autoit] [autoit]

    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    ;********************************************************************
    ;* LoadWMIClasses
    ;*
    ;* Fetch all the classes in the currently selected namespace, and
    ;* populate the keys of a dictionary object with the names of all
    ;* dynamic (non-association) classes. Then we transfer the keys to
    ;* an array, sort the array, and finally use the sorted array to
    ;* populate the WMI classes pulldown.
    ;********************************************************************
    Func LoadWMIClasses()

    [/autoit] [autoit][/autoit] [autoit]

    Const $SORT_KEYS = 1
    Const $SORT_ITEMS = 2

    [/autoit] [autoit][/autoit] [autoit]

    $objClassDictionary = ObjCreate("Scripting.Dictionary")
    ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $objClassDictionary = ' & $objClassDictionary & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console
    $objQualifierDictionary = ObjCreate("Scripting.Dictionary")
    ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $objQualifierDictionary = ' & $objQualifierDictionary & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console

    [/autoit] [autoit][/autoit] [autoit]

    $strComputer = "."
    $objWMIService = ObjGet("winmgmts:" & $strComputer & $g_strCurrentNamespace)
    ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $objWMIService = ' & $objWMIService & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console

    [/autoit] [autoit][/autoit] [autoit]

    If not @error Then

    [/autoit] [autoit][/autoit] [autoit]

    For $objClass in $objWMIService.SubclassesOf()

    [/autoit] [autoit][/autoit] [autoit]

    For $objQualifier In $objClass.Qualifiers_() ; Dummy (), because it ends with an underscore !
    $objQualifierDictionary.Add(StringLower($objQualifier.Name), "")
    ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : StringLower($objQualifier.Name) = ' & StringLower($objQualifier.Name) & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console
    Next

    [/autoit] [autoit][/autoit] [autoit]

    If $objQualifierDictionary.Exists("dynamic") Then

    [/autoit] [autoit][/autoit] [autoit]

    ;$TempVar = $objClass.Path_.Class
    ;$objClassDictionary.Add($TempVar, "") ; Can't use object in arguments ?!!

    [/autoit] [autoit][/autoit] [autoit]

    $objClassDictionary.Add($objClass.Path_.Class, "")

    [/autoit] [autoit][/autoit] [autoit]

    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    $objQualifierDictionary.RemoveAll

    [/autoit] [autoit][/autoit] [autoit]

    Next

    [/autoit] [autoit][/autoit] [autoit]

    $objQualifierDictionary = ""

    [/autoit] [autoit][/autoit] [autoit]

    ;'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    ; If the current namespace contains dynamic classes...
    ;'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    If $objClassDictionary.Count Then

    [/autoit] [autoit][/autoit] [autoit]

    ;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    ; Sort the dictionary.
    ;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    SortDictionary($objClassDictionary, $SORT_KEYS)

    [/autoit] [autoit][/autoit] [autoit]

    ;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    ; Populate the WMI classes pulldown with the sorted dictionary.
    ;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

    [/autoit] [autoit][/autoit] [autoit]

    $strClassesCombo="|Select a WMI class"

    [/autoit] [autoit][/autoit] [autoit]

    For $strWMIClass in $objClassDictionary ; method .Keys is not an object ??

    [/autoit] [autoit][/autoit] [autoit]

    $strClassesCombo = $strClassesCombo & "|" & $strWMIClass

    [/autoit] [autoit][/autoit] [autoit]

    Next

    [/autoit] [autoit][/autoit] [autoit]

    GUICtrlSetData($GUI_WMI_Classes,$strClassesCombo,"Select a WMI class")

    [/autoit] [autoit][/autoit] [autoit]

    EndIf
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    If @error Or $objClassDictionary.Count = 0 Then
    ;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    ; And if the current namespace doesn't contain dynamic classes.
    ;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    GUICtrlSetData($GUI_WMI_Classes,"|No dynamic classes found in current namespace.|Select a different namespace","")

    [/autoit] [autoit][/autoit] [autoit]

    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    ;$objClassDictionary = ""

    [/autoit] [autoit][/autoit] [autoit]

    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    ;********************************************************************
    ;* SortDictionary
    ;*
    ;* Shell sort based on:
    ;* http://support.microsoft.com/support/kb/articles/q246/0/67.asp
    ;********************************************************************
    Func SortDictionary(ByRef $objDict, $intSort)

    [/autoit] [autoit][/autoit] [autoit]

    Const $dictKey = 1
    Const $dictItem = 2

    [/autoit] [autoit][/autoit] [autoit]

    Dim $strDict[1][3]

    [/autoit] [autoit][/autoit] [autoit]

    $intCount = $objDict.Count

    [/autoit] [autoit][/autoit] [autoit]

    If $intCount > 1 Then

    [/autoit] [autoit][/autoit] [autoit]

    ReDim $strDict[$intCount][3]

    [/autoit] [autoit][/autoit] [autoit]

    $i = 0
    For $objKey In $objDict

    [/autoit] [autoit][/autoit] [autoit]

    $strDict[$i][$dictKey] = String($objKey)
    $strDict[$i][$dictItem] = String($objDict($objKey))

    [/autoit] [autoit][/autoit] [autoit]

    $i = $i + 1
    Next

    [/autoit] [autoit][/autoit] [autoit]

    ;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    ; Perform a shell sort of the 2D string array
    ;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    For $i = 0 To ($intCount - 2)
    For $j = $i To ($intCount - 1)
    If $strDict[$i][$intSort] > $strDict[$j][$intSort] Then
    $strKey = $strDict[$i][$dictKey]
    $strItem = $strDict[$i][$dictItem]
    $strDict[$i][$dictKey] = $strDict[$j][$dictKey]
    $strDict[$i][$dictItem] = $strDict[$j][$dictItem]
    $strDict[$j][$dictKey] = $strKey
    $strDict[$j][$dictItem] = $strItem
    EndIf
    Next
    Next

    [/autoit] [autoit][/autoit] [autoit]

    ;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    ; Erase the contents of the dictionary object
    ;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    $objDict.RemoveAll

    [/autoit] [autoit][/autoit] [autoit]

    ;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    ; Repopulate the dictionary with the sorted information
    ;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    For $i = 0 To ($intCount - 1)
    $objDict.Add($strDict[$i][$dictKey], $strDict[$i][$dictItem])
    Next

    [/autoit] [autoit][/autoit] [autoit]

    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    ;********************************************************************
    ;* ComposeCode
    ;********************************************************************
    Func ComposeCode()

    [/autoit] [autoit][/autoit] [autoit]

    $objClass=""

    [/autoit] [autoit][/autoit] [autoit]

    $strSelectedClass = GUICtrlRead ( $GUI_WMI_Classes )
    ; Check if a valid class has been selected
    If stringinstr($strSelectedClass,"Select a WMI class")=0 Then

    [/autoit] [autoit][/autoit] [autoit]

    $bHasDates = false ; Flag: output has date fields
    $strHeaderStart=Chr(34)
    $strRowStart=Chr(34)
    $strColumnSeparator=": "
    $strRowEnd=" & @CRLF"

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    $strComputerCommand = "$strComputer = " & Chr(34) & $g_strWMISource & Chr(34)

    [/autoit] [autoit][/autoit] [autoit]

    $objWMIService = ObjGet("winmgmts:{impersonationLevel=impersonate}!" & @COMPUTERNAME & $g_strCurrentNamespace)
    $objClass = $objWMIService.Get($strSelectedClass)

    [/autoit] [autoit][/autoit] [autoit]

    If IsObj($objClass) Then

    [/autoit] [autoit][/autoit] [autoit]

    $strScriptCode = ""
    $strScriptCode = $strScriptCode & "; Generated by AutoIt Scriptomatic" & @CRLF & @CRLF
    $strScriptCode = $strScriptCode & "$wbemFlagReturnImmediately = 0x10" & @CRLF
    $strScriptCode = $strScriptCode & "$wbemFlagForwardOnly = 0x20" & @CRLF
    $strScriptCode = $strScriptCode & '$colItems = ""' & @CRLF
    $strScriptCode = $strScriptCode & $strComputerCommand & @CRLF & @CRLF
    $strScriptCode = $strScriptCode & '$Output=""' & @CRLF

    [/autoit] [autoit][/autoit] [autoit]

    If $g_strOutputFormat = "HTML" then
    $strScriptCode = $strScriptCode & "$Output = $Output & '<html><head><title>Scriptomatic HTML Output</title></head><body> " & _
    "<style>table {font-size: 10pt; font-family: arial;} th {background-color: buttonface; font-decoration: bold;} " & _
    "</style><table BORDER=" & Chr(34) & "1" & Chr(34) & "><tr><th>Property</th><th>Value</th></tr>'" & @CRLF
    $strRowStart = Chr(34) & "<tr><td>"
    $strHeaderStart = "'<tr bgcolor=" & Chr(34) & "yellow" & Chr(34) & "><td>' & " & Chr(34)
    $strColumnSeparator = "</td><td>&nbsp;"
    $strRowEnd = " & " & Chr(34) & "</td></tr>" & Chr(34) & " & @CRLF"
    EndIf

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    $strScriptCode = $strScriptCode & "$Output = $Output & " & $strHeaderStart & "Computer" & $strColumnSeparator & Chr(34) & " & $strComputer " & $strRowEnd & @CRLF

    [/autoit] [autoit][/autoit] [autoit]

    If $g_strOutputFormat = "Dialog" then
    $strScriptCode = $strScriptCode & "$Output = $Output & " & Chr(34) & "==========================================" & Chr(34) & $strRowEnd & @CRLF
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    $strScriptCode = $strScriptCode & "$objWMIService = ObjGet(" & Chr(34) & "winmgmts:" & Chr(34) & " & $strComputer & " & Chr(34) & $g_strCurrentNamespace & Chr(34) & ")" & @CRLF
    $strScriptCode = $strScriptCode & "$colItems = $objWMIService.ExecQuery(" & Chr(34) & "SELECT * FROM " & $strSelectedClass & Chr(34) & ", " & Chr(34) & "WQL" & Chr(34) & ", _" & @CRLF
    $strScriptCode = $strScriptCode & " $wbemFlagReturnImmediately + $wbemFlagForwardOnly)" & @CRLF & @CRLF
    $strScriptCode = $strScriptCode & "If IsObj($colItems) then" & @CRLF
    $strScriptCode = $strScriptCode & " For $objItem In $colItems" & @CRLF

    [/autoit] [autoit][/autoit] [autoit]

    For $objProperty in $objClass.Properties_() ; Must use (), because method ends with an underscore

    [/autoit] [autoit][/autoit] [autoit]

    If $objProperty.IsArray = True Then
    $strScriptCode = $strScriptCode & " $str" & $objProperty.Name & " = $objItem." & $objProperty.Name & "(0)" & @CRLF
    $strScriptCode = $strScriptCode & " $Output = $Output & " & $strRowStart & $objProperty.Name & $strColumnSeparator & Chr(34) & " & $str" & $objProperty.Name & $strRowEnd & @CRLF
    ElseIf $objProperty.CIMTYPE = 101 Then
    $bHasDates = True
    $strScriptCode = $strScriptCode & " $Output = $Output & " & $strRowStart & $objProperty.Name & $strColumnSeparator & Chr(34) & " & WMIDateStringToDate($objItem." & $objProperty.Name & ")" & $strRowEnd & @CRLF
    Else
    $strScriptCode = $strScriptCode & " $Output = $Output & " & $strRowStart & $objProperty.Name & $strColumnSeparator & Chr(34) & " & $objItem." & $objProperty.Name & $strRowEnd & @CRLF
    EndIf
    Next

    [/autoit] [autoit][/autoit] [autoit]

    If $g_strOutputFormat = "Dialog" then
    $strScriptCode = $strScriptCode & ' if Msgbox(1,"WMI Output",$Output) = 2 then ExitLoop' & @CRLF
    $strScriptCode = $strScriptCode & ' $Output=""' & @CRLF
    Endif
    $strScriptCode = $strScriptCode & " Next" & @CRLF

    [/autoit] [autoit][/autoit] [autoit]

    if $g_strOutputFormat = "Text" then
    $strScriptCode = $strScriptCode & ' ConsoleWrite($Output)' & @CRLF
    $strScriptCode = $strScriptCode & ' FileWrite(@TempDir & "\' & $strSelectedClass & '.TXT", $Output )' & @CRLF
    $strScriptCode = $strScriptCode & ' Run(@Comspec & " /c start " & @TempDir & "\' & $strSelectedClass & '.TXT" )' & @CRLF
    Elseif $g_strOutputFormat = "HTML" then
    $strScriptCode = $strScriptCode & ' FileWrite(@TempDir & "\' & $strSelectedClass & '.HTML", $Output )' & @CRLF
    $strScriptCode = $strScriptCode & ' Run(@Comspec & " /c start " & @TempDir & "\' & $strSelectedClass & '.HTML" )' & @CRLF
    Endif

    [/autoit] [autoit][/autoit] [autoit]

    $strScriptCode = $strScriptCode & "Else" & @CRLF
    $strScriptCode = $strScriptCode & ' Msgbox(0,"WMI Output","No WMI Objects Found for class: " & ' & Chr(34) & $strSelectedClass & Chr(34) & ' )' & @CRLF

    [/autoit] [autoit][/autoit] [autoit]

    $strScriptCode = $strScriptCode & "Endif" & @CRLF
    $strScriptCode = $strScriptCode & @CRLF & @CRLF

    [/autoit] [autoit][/autoit] [autoit]

    If $bHasDates Then
    $strScriptCode = $strScriptCode & "Func WMIDateStringToDate($dtmDate)" & @CRLF
    $strScriptCode = $strScriptCode & @CRLF
    $strScriptCode = $strScriptCode & Chr(9) & "Return (StringMid($dtmDate, 5, 2) & ""/"" & _" & @CRLF
    $strScriptCode = $strScriptCode & Chr(9) & "StringMid($dtmDate, 7, 2) & ""/"" & StringLeft($dtmDate, 4) _" & @CRLF
    $strScriptCode = $strScriptCode & Chr(9) & "& "" "" & StringMid($dtmDate, 9, 2) & "":"" & StringMid($dtmDate, 11, 2) & "":"" & StringMid($dtmDate,13, 2))" & @CRLF
    $strScriptCode = $strScriptCode & "EndFunc"
    EndIf
    Else
    $strScriptCode = "Error: No Class properties found for " & $g_strCurrentNamespace & "" & $strSelectedClass
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    GUICtrlSetData($GUI_AST_ScriptCode,$strScriptCode)

    [/autoit] [autoit][/autoit] [autoit]

    ;'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    ; Once the code is successfully composed and put into the
    ; textarea, ensure that the run and save buttons are enabled.
    ;'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    GUICtrlSetState($GUI_AST_RUN, $GUI_ENABLE)
    GUICtrlSetState($GUI_AST_SAVE, $GUI_ENABLE)

    [/autoit] [autoit][/autoit] [autoit]

    Else
    ; Disable Run and Save buttons, because no valid code has been generated
    GUICtrlSetState($GUI_AST_RUN, $GUI_DISABLE)
    GUICtrlSetState($GUI_AST_SAVE, $GUI_DISABLE)
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    EndFunc

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    ;********************************************************************
    ;* RunScript
    ;********************************************************************
    Func RunScript()

    [/autoit] [autoit][/autoit] [autoit]

    ;'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    ; Create a temporary script file named "temp_script.au3".
    ;'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

    [/autoit] [autoit][/autoit] [autoit]

    $strTmpName = @TempDir & "\temp_script.au3"

    [/autoit] [autoit][/autoit] [autoit]

    if FileExists($strTmpName) then FileDelete($strTmpName)

    [/autoit] [autoit][/autoit] [autoit]

    FileWrite($strTmpName,GUICtrlRead($GUI_AST_Scriptcode))

    [/autoit] [autoit][/autoit] [autoit]

    ;'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    ; Start constructing the command line that will run the script...
    ;'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    $strCmdLine = "c:\programme\autoit3\autoit3.exe" & " " & $strTmpName

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    RunWait($strCmdLine)

    [/autoit] [autoit][/autoit] [autoit]

    FileDelete($strTmpName)

    [/autoit] [autoit][/autoit] [autoit]

    EndFunc

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    ;********************************************************************
    ;* SaveScript
    ;********************************************************************
    Func SaveScript()

    [/autoit] [autoit][/autoit] [autoit]

    $strTmpName=FileSaveDialog("Save Script",@DesktopDir,"AutoIt3 Scripts (*.au3)",16, GUICtrlRead ( $GUI_WMI_Classes ))

    [/autoit] [autoit][/autoit] [autoit]

    if not @error and $strTmpName <> "" then
    if StringRight($strTmpName,4) <> ".AU3" then $strTmpName=$strTmpName & ".AU3"
    if FileExists($strTmpName) then FileDelete($strTmpName)
    FileWrite($strTmpName,GUICtrlRead($GUI_AST_Scriptcode))
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    EndFunc

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    ;********************************************************************
    ;* OpenScript
    ;********************************************************************

    [/autoit] [autoit][/autoit] [autoit]

    Func OpenScript()

    [/autoit] [autoit][/autoit] [autoit]

    $strTmpName=FileOpenDialog("Open Script",@DesktopDir,"AutoIt3 Scripts (*.au3)")

    [/autoit] [autoit][/autoit] [autoit]

    If not @error and $strTmpName <> "" then
    If FileExists($strTmpName) then
    GUICtrlSetData($GUI_AST_ScriptCode,FileRead($strTmpName,FileGetSize($strTmpName)))
    EndIf
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    EndFunc

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    ;****************************************************************************
    ;* SetNamespaceToCIMV2
    ;****************************************************************************
    Func SetNamespaceToCIMV2()
    If StringUpper(GUICtrlRead($GUI_WMI_Namespace)) <> "ROOT\CIMV2" Then
    GUICtrlSetData($GUI_WMI_Namespace,"ROOT\CIMV2","ROOT\CIMV2")
    HandleNamespaceChange()
    EndIf
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    ;****************************************************************************
    ;* SetWMIRepository
    ;****************************************************************************
    Func SetWMIRepository()

    [/autoit] [autoit][/autoit] [autoit]

    $strWMISourceName = InputBox("Set WMI Repository Source", _
    "Please enter the computer whose WMI repository you want to read from: ", _
    $g_strWMISource)
    If $strWMISourceName <> "" Then

    [/autoit] [autoit][/autoit] [autoit]

    $g_strWMISource = StringStripWS($strWMISourceName,1+2)
    ;target_computers.Value = $g_strWMISource
    LoadWMINamespaces()
    Endif
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    ;****************************************************************************
    ;* HandleOutputChange
    ;****************************************************************************
    Func HandleOutputChange()

    [/autoit] [autoit][/autoit] [autoit]

    $ChosenFormat = $g_strOutputFormat
    if GUICtrlRead($GUI_AST_RadioDialog)=$GUI_CHECKED then $ChosenFormat="Dialog"
    if GUICtrlRead($GUI_AST_RadioText)=$GUI_CHECKED then $ChosenFormat="Text"
    if GUICtrlRead($GUI_AST_RadioHTML)=$GUI_CHECKED then $ChosenFormat="HTML"
    if $ChosenFormat <> $g_strOutputFormat Then
    $g_strOutputFormat = $ChosenFormat
    ComposeCode()
    EndIf
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    Func Filter()
    $filter =InputBox("Class Filter","Filter","","",200,150)
    if @error then
    msgbox(0,"Error in Function Filter","Filter Error or no Filter selected",2)
    else
    $strClassesCombo="|Select a WMI class filtered with "&$filter
    For $strWMIClass in $objClassDictionary ; method .Keys is not an object ??
    if $filter="" or stringinstr($strWMIClass,$filter) then
    $strClassesCombo = $strClassesCombo & "|" & $strWMIClass
    EndIf
    Next
    endif
    if $filter="" then
    GUICtrlSetData($GUI_WMI_Classes,$strClassesCombo,"Select a WMI class")
    Else
    GUICtrlSetData($GUI_WMI_Classes,$strClassesCombo,"Select a WMI class filtered with "&$filter)
    endif
    endfunc

    [/autoit]

    //EDIT
    Durch die Forensoftware werden in den Scripten Backslashes "gefressen". Diese gehören zu

    Code
    winmgmts://

    ciao
    Andy


    "Schlechtes Benehmen halten die Leute doch nur deswegen für eine Art Vorrecht, weil keiner ihnen aufs Maul haut." Klaus Kinski
    "Hint: Write comments after each line. So you can (better) see what your program does and what it not does. And we can see what you're thinking what your program does and we can point to the missunderstandings." A-Jay

    Wie man Fragen richtig stellt... Tutorial: Wie man Script-Fehler findet und beseitigt...X-Y-Problem

    Einmal editiert, zuletzt von Andy (17. März 2014 um 16:23)

  • Das mit dem Filter ist sinnvoll. Leider bringt dein Code folgende Fehlermeldung:

    Code
    @@ Debug(200) : $objClassDictionary = 
    >Error code: 0
    @@ Debug(202) : $objQualifierDictionary = 
    >Error code: 0

    Hab grad leider keine Zeit genauer dabei zu schauen

  • Wie kommst du darauf, dass das eine Fehlermeldung ist?

  • Weil ich Depp nur die Hälfte kopiert hatte! Sry

    Code
    @@ Debug(200) : $objClassDictionary = 
    >Error code: 0
    @@ Debug(202) : $objQualifierDictionary = 
    >Error code: 0
    @@ Debug(206) : $objWMIService = 
    >Error code: -2147217375
    "C:\Users\viso\Desktop\ISN AutoIt Studio\Projects\Scriptomatic 2\Scriptomatic.au3" (210) : ==> Variable must be of type "Object".:
    For $objClass in $objWMIService.SubclassesOf()
    For $objClass in $objWMIService^ ERROR
  • Zitat

    "C:\Users\viso\Desktop\ISN AutoIt Studio\Projects\

    Ich benutze Scite ohne Fehlermeldung....Win7/64 und XP/32
    So wie du das schreibst, tritt der Fehler nur beim von mir geposteten Script auf, und nicht bei dem im Link geposteten Orginalcode?

  • Genau richtig erkannt. Der Originalcode läuft ohne Probs. Hab grad mal auf die Schnelle geschaut, die gesuchte WMI Class wird mit nicht angezeigt!
    Kann man da was falsch machen (weis doofe Frage, ich schaff aber so manches)?

    P.S.: Das von dir mit Scriptomatic erstellte Script läuft auch nicht !?

    Die WMI Class scheint es wirklich nicht zu geben (bei mir)

  • Interessant, denn Scriptomatic sammelt ja die nur die aus der Windows-eigenen Datenbank möglichen Classes für den Namespace.
    Vista....ggf. kann das mal ein anderer Vista-User verifizieren?

    Zitat

    Kann man da was falsch machen (weis doofe Frage, ich schaff aber so manches)?

    Nein, ich glaube nicht, dass man da etwas falsch machen kann...so wie deine Fehlermeldung aussieht, wird schon die Anfrage an die Datenbank verhindert.
    Ggf. ein Rechte-Problem? Hast du es mal als Administrator versucht?

    //EDIT poste mal bitte die beiden Scripte, einmal das vom Orginal erstellte, und das mit dem Filter erstellte

    ciao
    Andy


    "Schlechtes Benehmen halten die Leute doch nur deswegen für eine Art Vorrecht, weil keiner ihnen aufs Maul haut." Klaus Kinski
    "Hint: Write comments after each line. So you can (better) see what your program does and what it not does. And we can see what you're thinking what your program does and we can point to the missunderstandings." A-Jay

    Wie man Fragen richtig stellt... Tutorial: Wie man Script-Fehler findet und beseitigt...X-Y-Problem

    Einmal editiert, zuletzt von Andy (8. März 2014 um 17:28)

  • Adminrechte vorhanden und das ist Win7 64 Ultimate.
    KA warum das als Vista erkannt wird.

    Weis einer wodurch/von wem die Klasse erzeugt wird oder zählt die zu den "Standard" Klassen?

  • Das gepostete Script läuft nicht, da die Forensoftware die Backslashes "frisst"!
    s.EDIT in Post #5