; ; KIXTART 4.12 ; KIXFORMS BUILD 38 ; Break On $TITLE = "WmiExplorer" $VERSION = "2.00" $AUTHOR = "Shawn Tassie" $WIDTH = 700 $HEIGHT = 480 $MARGIN = 2 $LISTRATIO = 0.40 $VIEWRATIO = 0.50 $Form = CreateObject("Kixtart.Form") $Form.ClientSize = $WIDTH,$HEIGHT $Form.FontSize = 12 $Form.Text = $TITLE $Form.Resizable = 1 $Form.MaxButton = 1 $Form.ClipChildren = 1 $File = $Form.Menu.MenuItems.Add("File") $Exit = $File.MenuItems.Add("Exit","OnExitClick()") $Edit = $Form.Menu.MenuItems.Add("Edit") $Exclusions = $Edit.MenuItems.Add("Exclusions...","OnExclusionsClick()") $Help = $Form.Menu.MenuItems.Add("Help") $About = $Help.MenuItems.Add("About...","OnAboutClick()") $status = $form.label() $status.left = $margin $status.top = $form.clientheight - 25 $status.width = 0.6 * $form.clientwidth $status.bottom = $form.clientheight - $margin $status.borderstyle = 5 $status.anchor = 1+4+8 $progress = $form.progressbar() $progress.left = $status.right + $MARGIN $progress.top = $form.clientheight - 25 $progress.right = $form.clientwidth - $MARGIN $progress.bottom = $form.clientheight - $MARGIN $progress.borderstyle = 5 $progress.anchor = 4+8 $list = $form.listview $list.sorted = 1 $list.top = $MARGIN $list.left = $MARGIN $list.right = $LISTRATIO * $form.clientwidth $list.bottom = $status.Top - $margin $list.columns.add.text = "Classes" $list.columns(0).width = $list.clientwidth $list.onclick = "list_click()" $list.anchor = 1+2+8 $view = $form.listview $view.sorted = 1 $view.top = $list.top $view.left = $list.right + 5 $view.right = $form.clientwidth - 5 $view.bottom = $VIEWRATIO * $form.clientheight $view.gridlines = false $view.columns.add.text = "Instances" $view.columns(0).width = $view.clientwidth $view.onclick = "view_click()" $view.anchor = 1+2+4 $detail = $form.listview $detail.sorted = 1 $detail.top = $view.bottom + 5 $detail.left = $list.right + 5 $detail.right = $form.clientwidth - 5 $detail.bottom = $status.top - $margin $detail.sorted = true $detail.gridlines = true $detail.anchor = 1+2+4+8 $detail.columns.add.text = "Property" $detail.columns.add.text = "Value" $detail.columns(0).width = $detail.clientwidth/2 $detail.columns(1).width = $detail.clientwidth/2 $detail.scrollbars = 1 ; ; Setup application ... ; $form.center $form.show list_load() ; ; Run the application ... ; while $form.visible $= execute($form.doevents) loop exit 1 Function OnExitClick() $Form.Hide EndFunction Function OnExclusionsClick() EndFunction Function OnAboutClick() AboutBox($TITLE,$VERSION,$AUTHOR,"") EndFunction function list_load() dim $wmi dim $class dim $isq dim $qualifier $form.mousepointer = 11 $form.enabled = 0 $list.beginupdate $view.items.clear $wmi = getobject("winmgmts:\\.\root\cimv2") $progress.min = 0 $progress.max = 0 $count = 0 $progress.max = $wmi.subclassesof().count $progress.value = $count $status.text = "Loading classes ..." for each $class in $wmi.subclassesof() $count = $count+1 $progress.value = $count $isq = 0 if instr($class.path_.class,"win32_") For Each $qualifier in $class.Qualifiers_ If Instr($Qualifier.Name, "ASSOCIATION") $isq = 1 Endif Next If $isq = 0 $item = $list.items.add($class.Path_.Class) EndIf EndIf Next $progress.value = 0 $list.columns(0).width = -1 $status.text = "Ready" $form.mousepointer = 0 $form.enabled = 1 $list.endupdate $wmi = 0 EndFunction function list_click() dim $wmi,$query,$instance dim $class,$object dim $item $wmi = getobject("winmgmts:{impersonationLevel=impersonate}!//@wksta") $class = $list.focuseditem.subitems(0).text $form.mousepointer = 11 $form.enabled = 0 $view.beginupdate $detail.beginupdate $view.items.clear $detail.items.clear $query = $wmi.execquery("select name from $class") $progress.max = $query.count $progress.value = 0 if $query for each $instance in $query $progress.value = $progress.value + 1 if $instance.name $item = $view.items.add($instance.name) endif next endif $progress.value = 0 $wmi = getobject("winmgmts:\\.\root\cimv2") $object = $wmi.get($class) if $object for each $property in $object.properties_ $item = $detail.items.add($property.name) next endif $Detail.Columns(0).Width = -1 $Detail.Columns(1).Width = -1 $Detail.Columns(1).Width = -2 ; for each $column in $detail.columns ; $column.width = -1 ; $column.width = -2 ; next $form.mousepointer = 0 $form.enabled = 1 $view.endupdate $detail.endupdate endfunction function view_click() Dim $WMI Dim $Class Dim $Item if not $view.focuseditem.selected return endif $form.mousepointer = 11 $form.enabled = 0 $class = $list.focuseditem.text $name = $view.focuseditem.text $wmi = getobject("winmgmts:\\.\root\cimv2").instancesof("$class where name='$name'") for each $inst in $wmi $instance = $inst next $progress.max = $detail.items.count $progress.value = 0 for each $item in $detail.items $item.subitems(1).text = "" next if $instance for each $item in $detail.items $progress.value = $progress.value + 1 $item.subitems(1).text = $instance.properties_($item.text) next endif $Detail.Columns(0).Width = -1 $Detail.Columns(1).Width = -1 $progress.value = 0 $form.mousepointer = 0 $form.enabled = 1 EndFunction Function AboutBox($Name,$Version,$Author,$Message) ; ; AboutBox() - part of the Kixforms Toolkit. ; ; Displays a dialog box containing script name, version, ; author name and a general information. User must press ; the OK button to dismiss. ; ; Dim $Form Dim $Script,$Vers,$Auth,$Msg Dim $Ok $Form = CreateObject("Kixtart.Form") $Form.ClientWidth = 250 $Form.ClientHeight = 200 $Form.BorderStyle = 1 $Form.Center $Form.Caption = "About "+$Name $Form.FontName = "MS Sans Serif" $Form.FontSize = 10 $Form.Icon = 13 $Script = $Form.Label("",10,20,$Form.ClientWidth-20,40) $Script.FontSize = 18 $Script.FontBold = 1 $Script.Caption = $Name $Script.Alignment = 2 $Vers = $Form.Label("",10,60,$Form.ClientWidth-20,20) $Vers.Caption = "Version $version" $Vers.Alignment = 2 $Auth = $Form.Label("",10,90,$Form.ClientWidth-20,20) $Auth.Caption = $Author $Auth.Alignment = 2 $Msg = $Form.Label("",10,130,$Form.ClientWidth-20,80) $Msg.Caption = $Message $Msg.Alignment = 2 $Ok = $Form.CommandButton("OK",160,220,75,25) $Ok.OnClick = "$$Form.Hide" $Ok.Default = 1 $Form.Show While $Form.Visible $=Execute($Form.DoEvents) Loop EndFunction