Page 1 of 1 1
Topic Options
#91748 - 2003-03-13 11:09 PM Kixforms: WmiExplorer with resizable form
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
This is the updated WMI Explorer script that allows one to enumerate WMI objects on Windows 2K and XP machines. It has been updated to provide for a resizable form.

This script requires the lastest Beta build of Kixforms available here:

Kixforms Download Page

and can only be run on Windows 2K and XP - or on NT/9x that have the WMI Runtimes installed.

Screenshot:

 -

Sourcecode:



;
; KIXTART 4.12
; KIXFORMS BUILD 36
;
 
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



-Shawn

[ 13. March 2003, 23:16: Message edited by: Shawn ]

Top
#91749 - 2003-03-14 11:42 PM Re: Kixforms: WmiExplorer with resizable form
Schuliebug Offline
Hey THIS is FUN
*****

Registered: 2002-01-18
Posts: 379
Loc: Netherlands
Man,this is great. Till now the forms were all fixed, but since this update (ok, beta) users can resize, drag, minimize, maximize their KiX app! Totally great!!!!! I'm very impressed, will be of great impact on the KiXforms community!
_________________________
Kind regards,

Top
#91750 - 2003-03-15 09:17 AM Re: Kixforms: WmiExplorer with resizable form
masken Offline
MM club member
*****

Registered: 2000-11-27
Posts: 1222
Loc: Gothenburg, Sweden
Shawn is amazing, always has been [Smile]

Keep up the good work m8 [Smile]
_________________________
The tart is out there

Top
#91751 - 2003-03-15 11:19 AM Re: Kixforms: WmiExplorer with resizable form
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Great thing as always Shawn [Wink]

Hey, I just sit here in the office in front of my NT Box and have some time to update PostPrep for resizable form, tried to take this gem here as reference ...
Somehow I must've missed to install the WMI core to it (All I have here is the WMI SDK that cries first to install the core [Roll Eyes] )

So I tried to follow the link in that Messagebox but got a 404; Search on M$ only referenced some 'Why to upgrade from NT to MS Server 2003 and how to do so' - links following the motto "No Hands - No Cookies" [Mad] [Mad] [Mad]

Long speech short sense, can someone link me to WMI Core for NT (download) ??? Please :,(
_________________________



Top
#91752 - 2003-03-15 11:51 AM Re: Kixforms: WmiExplorer with resizable form
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Never mind ... found the link in Conrads WMIQuery() post [Embarrassed]
_________________________



Top
#91753 - 2003-03-16 12:18 AM Re: Kixforms: WmiExplorer with resizable form
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11634
Loc: Space
found it eh...

Well, here are some links:
http://www.kixhelp.com/downloads.htm

http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=A111FDFA-9733-47E0-9787-2E9B5999BDC5

http://www.kixtart.org/board/ultimatebb.php?ubb=get_topic;f=10;t=000048

Windows Management Instrumentation (WMI) SNMP Provider 1.5 Build 1085.0005 (Windows NT 4.0 and 2000)
http://www.microsoft.com/downloads/details.aspx?FamilyID=c6b30755-6d20-4107-82c5-089e3dfe4fee&DisplayLang=en

WMI Administrative Tools
http://www.microsoft.com/downloads/details.aspx?FamilyID=6430f853-1120-48db-8cc5-f2abdc3ed314&DisplayLang=en

Windows Management Instrumentation (WMI) CORE 1.5 (Windows 95/98/NT 4.0)
http://www.microsoft.com/downloads/details.aspx?FamilyID=afe41f46-e213-4cbf-9c5b-fbf236e0e875&DisplayLang=en

Direct Download Link:
http://download.microsoft.com/download/platformsdk/wmicore/1.5/W9XNT4/EN-US/wmicore.EXE

Kent or Les Can one of you guys update the WMI FAQ... doesn't appear to have all the links for WMI downloads.

Top
Page 1 of 1 1


Moderator:  Shawn, ShaneEP, Ruud van Velsen, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 1046 anonymous users online.
Newest Members
fgarcia, Viginette, ManuvdWielNL, Sir_Barrington, batdk82
17889 Registered Users

Generated in 0.054 seconds in which 0.024 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org