WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

2004A and Older

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

WMI_Scripter

Keywords: WMI_Scripter WMI scripter utility	WMI Collections

IMPORTANT: If running WinBatch 2008E or newer please use the current copy of the WMI-Scripter located here: WMI_scripter


Notice: Requires at least WinBatch version 2002E in order to run.

WMI_Scripter is a learning tool for WMI and WinBatch. It enables users to generate and run scripts that use WMI to display properties available through the Win32_ classes.

;********************************************************************
;*
;*  File:           WMI_scripter.wbt 
;*  Created:        June 2003
;*  Version:        1.0
;*
;*  Description:    Learning tool. Enables users to generate and run 
;*                  scripts that use WMI to display properties available 
;*                    through the Win32_ classes. 
;*     
;*
;*
;*  Version I - June 11th, 2003 DRD
;*         Initial Release
;*
;*  Version II - June 14 2003  Assorted hacks MW
;*
;*
;*
;*
;********************************************************************
#DefineFunction udfMakeVar(p)
   v=StrClean(StrCat("var",p),"abcdefgjijklmnopqrstuvwxyz_0123456789","",@FALSE,2)
   If StrLen(v)>30 Then v=StrSub(v,1,30)
   Return(v)
#EndFunction




#DefineFunction WBOMATICCallbackProc(WBOMATIC_Handle,WBOMATIC_Message,WBOMATIC_ID,rsvd1,rsvd2)
   IntControl(73,1,0,0,0) ;Error Handling
   IntControl(72,1,0,0,0) ;Cancel Handling

   strTmpName = StrCat(FilePath(IntControl(1004,0,0,0,0)),"temp_script.wbt")


   strProg = StrCat(DirHome(),"winbatch.exe")
   ;DialogprocOptions Constants
   MSG_INIT=0                ; The one-time initilization
   MSG_TIMER=1               ; Timer event
   MSG_BUTTONPUSHED=2        ; Pushbutton or Picturebutton
   MSG_RADIOPUSHED=3         ; Radiobutton clicked
   MSG_CHECKBOX=4            ; Checkbox clicked
   MSG_EDITBOX=5             ; Editbox or Multilinebox
   MSG_FILESELECT=6          ; Filelistbox
   MSG_ITEMSELECT=7          ; Itembox
   MSG_COMBOCHANGE=8         ; Combobox/Droplistbox
   MSG_CALENDAR=9            ; Calendar date change
   MSG_SPINNER=10            ; Spinner number change
   MSG_CLOSEVIA49=11         ; Close clicked (Enabled via Intcontrol 49)
   MSG_FILEBOXDOUBLECLICK=12 ; Get double-click message on a FileListBox
   MSG_ITEMOXDOUBLECLICK=13  ; Get double-click message on an ItemBox
   DPO_DISABLESTATE=1000     ; codes -1=GetSetting 0=EnableDialog 1=DisableDialog
   DPO_CHANGEBACKGROUND=1001 ; -1=GetSetting otherise bitmap or color string
   ;DialogControlState Constants
   DCSTATE_SETFOCUS=1        ; Give Control Focus
   DCSTATE_QUERYSTYLE=2      ; Query control's style
   DCSTATE_ADDSTYLE=3        ; Add control style
   DCSTATE_REMOVESTYLE=4     ; Remove control style
   DCSTATE_GETFOCUS=5        ; Get control that has focus
   DCSTYLE_INVISIBLE=1       ; Set Control Invisible
   DCSTYLE_DISABLED=2        ; Set Control Disabled
   DCSTYLE_NOUSERDATA=4      ; Note: Setable via DialogControlState function ONLY SPINNER control only
   DCSTYLE_READONLY=8        ; Sets control to read-only (user cannot type in data) EDITBOX MULTILINEBOX SPINNER
   DCSTYLE_PASSWORD=16       ; Sets 'password mode' where only *'s are displayed EDITBOX
   DCSTYLE_DEFAULTBUTTON=32  ; Sets a button as a the default button PUSHBUTTON PICTUREBUTTON
   DCSTYLE_DIGITSONLY=64     ; Set edit box to accept digits only EDITMOX MULTILINEBOX
   DCSTYLE_FLAT=128          ; Makes a 'flat' hyperlink-looking button PUSHBUTTON PICTUREBUTTON
   ;DialogControlSet / DialogControlGet Constants
   DC_CHECKBOX=1             ; CHECKBOX
   DC_RADIOBUTTON=2          ; RADIOBUTTON
   DC_EDITBOX=3              ; EDITBOX MULTILINEBOX
   DC_TITLE=4                ; PICTURE RADIOBUTTON CHECKBOX PICTUREBUTTON VARYTEXT STATICTEXT GROUPBOX PUSHBUTTON
   DC_ITEMBOXCONTENTS=5      ; ITEMBOX FILELISTBOX DROPLISTBOX
   DC_ITEMBOXSELECT=6        ; ITEMBOX FILELISTBOX DROPLISTBOX
   DC_CALENDAR=7             ; CALENDAR
   DC_SPINNER=8              ; SPINNER
   DC_MULTITABSTOPS=9        ; MULTILINEBOX
   DC_ITEMSCROLLPOS=10       ; ITEMBOX FILELISTBOX
   DC_BACKGROUNDCOLOR=11     ; RADIOBUTTON CHECKBOX VARYTEXT STATICTEXT GROUPBOX PUSHBUTTON ITEMBOX FILELISTBOX DROPLISTBOX SPINNER EDITBOX MULTILINEBOX
   DC_PICTUREBITMAP=12       ; PICTURE PICTUREBUTTON
   DC_TEXTCOLOR=13           ; RADIOBUTTON CHECKBOX VARYTEXT STATICTEXT GROUPBOX PUSHBUTTON ITEMBOX FIELLISTBOX DROPLISTBOX SPINNER EDITBOX MULTILINEBOX
   DC_ITEMBOXADD=14          ; ITEMBOX FILELISTBOX DROPLISTBOX
   DC_ITEMBOXREMOVE=15       ; ITEMBOX FILELISTBOX DROPLISTBOX


   Switch WBOMATIC_Message
      Case MSG_INIT
         ;Select events to monitor
         DialogProcOptions(WBOMATIC_Handle,MSG_TIMER,1)
         DialogProcOptions(WBOMATIC_Handle,MSG_BUTTONPUSHED,@TRUE)
         DialogProcOptions(WBOMATIC_Handle,MSG_EDITBOX,@TRUE)
         DialogProcOptions(WBOMATIC_Handle,MSG_COMBOCHANGE,@TRUE)
         ;* disable the dropdown and run and save buttons because
         ;* they are not yet meaningful.
         DialogControlState(WBOMATIC_Handle,003,DCSTATE_ADDSTYLE,DCSTYLE_INVISIBLE)  ;  Set the invisible bit on dropbox
         DialogControlState(WBOMATIC_Handle,004,DCSTATE_ADDSTYLE,DCSTYLE_INVISIBLE)  ;  Set the invisible bit on editbox 
         DialogControlState(WBOMATIC_Handle,001,DCSTATE_ADDSTYLE,DCSTYLE_INVISIBLE)  ;  Set the invisible bit on RUN button 
         DialogControlState(WBOMATIC_Handle,005,DCSTATE_ADDSTYLE,DCSTYLE_INVISIBLE)  ;  Set the invisible bit on SAVE button 
         Return(-1)

     Case MSG_TIMER
         DialogProcOptions(WBOMATIC_Handle,MSG_TIMER,@FALSE);disable timer callback
         ;*********************************************
         ;* WHILE LOADING...
         ;*
         ;* As the application loads, we open a 
         ;* window to act as a crude progress dialog
         ;* while we wait for the enumeration of the WMI
         ;* classes to complete.
         ;*
         ;*********************************************
         ;Update multiline with progress and red text
         txt = StrCat("Loading WMI Classes. Please Wait ")
         DialogControlSet(WBOMATIC_Handle, 006, DC_TITLE, txt)


         ;****************************************************************************
         ;* enumerate the WMI classes in the cimv2 namespace, filling up list
         ;* with the names of the classes that begin with Win32_ and are not association
         ;* classes. we'll use the class names stored in the list to populate a 
         ;* DROPLISTBOX.
         ;*****************************************************************************
      
         strComputer = "."
         
         objLocator = ObjectOpen("WbemScripting.SWbemLocator")
         objService = objLocator.ConnectServer(strComputer,"root/cimv2")
         objSecurity = objService.Security_
         objSecurity.ImpersonationLevel = 3
         objClassCollection = objService.SubclassesOf()
         hEnum = ObjectCollectionOpen(objClassCollection)
         iCounter = 0
         datalist = ""
         txt = StrCat(@CRLF,@CRLF,"Retrieving Instances ",@CRLF,@CRLF)
         While 1
            objClass = ObjectCollectionNext(hEnum)
            If objClass == 0 Then Break
            
            ;notify user that its querying instances
            iCounter = iCounter + 1
            If iCounter mod 50 == 0
               txt = DialogControlGet( WBOMATIC_Handle, 006, DC_TITLE)
               txt = StrCat(txt,"|")
               DialogControlSet( WBOMATIC_Handle, 006, DC_TITLE, txt)
            EndIf

            bIsQualifier = @FALSE 
            objPath = objClass.Path_
            ClassName = objPath.Class
            If StrUpper(StrSub(ClassName,1,5)) == "WIN32"
              objQualifiers = objClass.Qualifiers_ 
              hQualifiersEnum = ObjectCollectionOpen(objQualifiers)
              While 1
                 objQualifier = ObjectCollectionNext(hQualifiersEnum)
                 If objQualifier == 0 Then Break
                 If StrUpper(StrTrim(objQualifier.Name)) == "ASSOCIATION"
                    bIsQualifier = @TRUE
                 EndIf
                 ObjectClose(objQualifier)
              EndWhile
              ObjectCollectionClose(hQualifiersEnum)
              
              ;* the class name starts with win32_ and is not an association
              ;* class - so append it to the list
               If bIsQualifier == @FALSE 
                   datalist = StrCat(datalist, @TAB, objPath.Class)
               EndIf
               ObjectClose(objQualifiers)
            EndIf
         
           ObjectClose(objPath)   
           ObjectClose(objClass)
         EndWhile
         ObjectCollectionClose(hEnum)
         ObjectClose(objSecurity)
         ObjectClose(objService)
         ObjectClose(objLocator)
         datalist = StrTrim(datalist)
         datalist = ItemSort(datalist,@TAB)

         ;* populate the droplistbox
         DialogControlState(WBOMATIC_Handle,003,DCSTATE_REMOVESTYLE,DCSTYLE_INVISIBLE)  ;  Set the visible bit on dropdown 
         DialogControlSet(WBOMATIC_Handle, 003, DC_ITEMBOXCONTENTS, datalist )
         DialogControlSet(WBOMATIC_Handle, 003, DC_ITEMBOXSELECT, "*** Select a WMI class from this dropdown list ***")
       
         ;* enable the run and save buttons
         DialogControlState(WBOMATIC_Handle,001,DCSTATE_REMOVESTYLE,DCSTYLE_INVISIBLE)  ;  Set the visible bit on RUN button 
         DialogControlState(WBOMATIC_Handle,005,DCSTATE_REMOVESTYLE,DCSTYLE_INVISIBLE)  ;  Set the visible bit on SAVE button 

         ;Update Varytext with progress 
         txt = "Please choose a WMI Win32 class from the drop down list box."
         DialogControlSet(WBOMATIC_Handle, 006, DC_TITLE, txt)
         ;Update MultiLineBox to blank
         DialogControlSet(WBOMATIC_Handle, 004, DC_EDITBOX, "")
         Return(-1)      ;  Do default processing


     Case MSG_BUTTONPUSHED
        Switch WBOMATIC_ID
           Case 001  ;RUN BUTTON
               ;****************************************************************************
               ;* when the user presses the Run button, we use the Run
               ;* to run the code 
               ;****************************************************************************
               
               ;Grab text from MultilineEditbox
               scripttext = DialogControlGet(WBOMATIC_Handle, 004, DC_EDITBOX)

               filehandle = FileOpen(strTmpName,"Write")
               FileWrite(filehandle,scripttext)
               FileClose(filehandle)

               Run(strProg,StrCat('"',strTmpName,'"'))
              Return(-2)

           Case 002 ;QUIT BUTTON
              Return(0)

           Case 005 ;SAVE BUTTON
               ;****************************************************************************
               ;* when the user presses the Save button, we present them with a prompt
               ;* and force them to give us the full path to where they'd like to the save
               ;* the script that is currently in the multilinebox.
               ;****************************************************************************            
               types="All Files|*.*|WIL Files|*.wbt;*.mnu|Text Files|*.txt|"
               defsavedir=FilePath(IntControl(1004,0,0,0,0))
               ;get current class from drop list box for file name
               saveclass= DialogControlGet(WBOMATIC_Handle,  003, DC_ITEMBOXSELECT)
               savename= StrCat(saveclass,".wbt")
               strSaveFileName=AskFilename("Please select where you want to save your script.", defsavedir, types, savename, 0)
               If strSaveFileName == ""
                  Return(0)
               EndIf
               
               handle = FileOpen(strSaveFileName,"WRITE")
               scripttext = DialogControlGet(WBOMATIC_Handle, 004, DC_EDITBOX)

               FileWrite(handle, scripttext)
               FileClose(handle)
               ;Message(strcat(saveclass," script saved as"),strSaveFileName)
               ;return(-2)
               ;return(-1)

        EndSwitch    ;WBOMATIC_ID
        Return(-1)      ;  Do default processing

     Case MSG_EDITBOX  ;ID 004
        Return(-1)      ;  Do default processing

     Case MSG_COMBOCHANGE  ;ID 003
           ;****************************************************************************
         ;* when the user selects a class from the pulldown it queries WMI 
         ;* to determine the properties of the class the user selected and 
         ;* uses the information to construct sample code which it puts
         ;* in the main window's multiline box.
         ;****************************************************************************
         selected = DialogControlGet(WBOMATIC_Handle,  003, DC_ITEMBOXSELECT)  ;get selected droplistbox item 
         If StrSub(selected,1,3) == "***" Then Return (-1)
         DialogControlState(WBOMATIC_Handle,003,DCSTATE_REMOVESTYLE,DCSTYLE_INVISIBLE)  ;  Set the visible bit on dropdown 
         classlist = DialogControlGet(WBOMATIC_Handle,  003, DC_ITEMBOXCONTENTS)  ;get all items in the droplistbox  
         
         ;Force dropdown to come back up
         ;DialogControlSet(WBOMATIC_Handle, 003, 5, classlist)
         ;DialogControlSet(WBOMATIC_Handle, 003, 6, selected)
         ;* Update VaryText box
         DialogControlSet(WBOMATIC_Handle, 006, DC_TITLE, "Retrieving data  ")
         ;* Update Multiline box
         DialogControlSet(WBOMATIC_Handle, 004, DC_EDITBOX, "")

         strComputer = "."
         objLocator = ObjectOpen("WbemScripting.SWbemLocator")
         objService = objLocator.ConnectServer(strComputer,"root/cimv2")
         objSecurity = objService.Security_
         objSecurity.ImpersonationLevel = 3
               
         wbemFlagReturnImmediately = 16
         wbemFlagForwardOnly = 32 
         objObjectSet  = objService.ExecQuery(StrCat("SELECT * FROM ", selected));," WQL, ", wbemFlagReturnImmediately + wbemFlagForwardOnly))
         ;objSWbemObjectSet = objService.InstancesOf(selected)

         ;Get a list of instances to prompt user with if more than once instance
         instancelist = ""

         If objObjectSet.Count >1
            iCounter = 0
            hEnum = ObjectCollectionOpen(objObjectSet)
            While @TRUE
              objObject = ObjectCollectionNext(hEnum)
              If objObject == 0 Then Break

              iCounter = iCounter + 1
            
              If iCounter mod 100 == 0
                  txt = DialogControlGet( WBOMATIC_Handle, 006, DC_TITLE)
                  txt = StrCat(txt,"|")
                  DialogControlSet( WBOMATIC_Handle, 006, DC_TITLE, txt)
              EndIf
               
              objPath = objObject.Path_
              class = objPath.Class
              objKeys = objPath.Keys
              instancelist = StrCat(instancelist,@TAB,class)
              ;Grab key name
              hEnumKeys = ObjectCollectionOpen(objKeys)
              While @TRUE
                 objKey = ObjectCollectionNext(hEnumKeys)
                 If objKey == 0 Then Break
                 keyname = objKey.Name
                 keyvalue = objKey.Value 
                 instancelist = StrCat(instancelist,"          ",keyname," = '",keyvalue,"'"); 10 spaces
              EndWhile
              ObjectCollectionClose(hEnumKeys)
              ObjectClose(objKeys)
              ObjectClose(objPath)
              ObjectClose(objObject)
            EndWhile
            ;Trim Leading pipe
            instancelist = StrTrim(instancelist)
            ObjectCollectionClose(hEnum)
   
            ;* Update multiline box
            DialogControlSet(WBOMATIC_Handle, 004, DC_EDITBOX, "")
         EndIf

         ;Set Varytext process control
         txt = "Please choose a WMI Win32 class from the drop down list box."
         DialogControlSet(WBOMATIC_Handle, 006, DC_TITLE, txt)

         ;Create copies of list, one for display and one original
         listdisplay = instancelist

         ;Prompt user to select an instance
         If instancelist != ""
            InstanceFormat=`WWWDLGED,6.1`

            InstanceCaption=`Browse for Instance`
            InstanceX=9999
            InstanceY=9999
            InstanceWidth=353
            InstanceHeight=256
            InstanceNumControls=004
            InstanceProcedure=`DEFAULT`
            InstanceFont=`DEFAULT`
            InstanceTextColor=`DEFAULT`
            InstanceBackground=`DEFAULT,DEFAULT`
            InstanceConfig=0
            
            Instance001=`249,236,033,011,PUSHBUTTON,DEFAULT,"OK",1,1,32,DEFAULT,DEFAULT,DEFAULT`
            Instance002=`294,236,033,011,PUSHBUTTON,DEFAULT,"Cancel",0,2,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
            Instance003=`010,028,331,201,ITEMBOX,listdisplay,DEFAULT,DEFAULT,3,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
            Instance004=`010,018,317,008,STATICTEXT,DEFAULT,"Select one object, then click OK.",DEFAULT,4,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
            
            ButtonPushed=Dialog("Instance")

            instance = listdisplay
            If instance==""
               Message("NOTICE","You must choose an instance")
               Return(-1)
            EndIf

            ;Remove first item in list because its the classname
            instance = StrReplace(instance,"          ",@TAB)
            instance = ItemRemove(1,instance,@TAB)
            instance = StrReplace(instance,@TAB," AND ")
            query = StrCat("SELECT * FROM ", selected," WHERE ",instance) ;," WQL ", wbemFlagReturnImmediately + wbemFlagForwardOnly)   
         Else
            query = StrCat("SELECT * FROM ", selected);;," WQL ", wbemFlagReturnImmediately + wbemFlagForwardOnly))
         EndIf

         objInstances = objService.ExecQuery(query)
         strCode = StrCat('; connect to WMI', @CRLF) 
         strCode = StrCat('objLocator = ObjectOpen("WbemScripting.SWbemLocator")', @CRLF)  
         strCode = StrCat(strCode , 'objService = objLocator.ConnectServer()' , @CRLF)  
         strCode = StrCat(strCode , 'objSecurity = objService.Security_' , @CRLF)  
         strCode = StrCat(strCode , 'objSecurity.ImpersonationLevel = 3' , @CRLF)  
         strCode = StrCat(strCode , 'class =  "', selected  , '"' , @CRLF)
         strCode = StrCat(strCode , '; query instances', @CRLF) 
         If instancelist != ""
             strCode = StrCat(strCode , `query = "SELECT * FROM `,selected,` WHERE `,instance,`"` , @CRLF)
         Else
            strCode = StrCat(strCode , `query = "SELECT * FROM `, selected,`"`, @CRLF)
         EndIf
          strCode = StrCat(strCode , 'objInstances = objService.ExecQuery(query)',@CRLF) 
         strCode = StrCat(strCode , '' , @CRLF)  
      
         proplist=""
          strCode = StrCat(strCode , '; loop once for each instance', @CRLF) 
         strCode = StrCat(strCode , 'hEnum = ObjectCollectionOpen(objInstances)' , @CRLF) 
         strCode = StrCat(strCode , 'While @true ', @CRLF) 
         strCode = StrCat(strCode , '   obj = ObjectCollectionNext(hEnum)' , @CRLF) 
         strCode = StrCat(strCode , '   If obj == 0 Then Break' , @CRLF) 

         strCode = StrCat(strCode,'   ; obtain properties', @CRLF) 
         displaylist =""
         hEnumInst = ObjectCollectionOpen(objInstances)
         While @TRUE
            objInst = ObjectCollectionNext(hEnumInst)
            If objInst == 0 Then Break
            objProps = objInst.Properties_
            hEnumProps = ObjectCollectionOpen(objProps)
            While @TRUE
               objProperty = ObjectCollectionNext(hEnumProps)
               If objProperty == 0 Then Break
               propname = objProperty.name               
               strCode = StrCat(strCode , '   ',udfMakeVar(propname),' = ','obj.',propname, @CRLF)
               proplist = StrCat(proplist,",",propname)
               ObjectClose(objProperty)
            EndWhile
            ObjectCollectionClose(hEnumProps)
            ObjectClose(objProps)
            ObjectClose(objInst)
         EndWhile
         ObjectCollectionClose(hEnumInst)
         ;remove leading comma
         proplist = StrSub(proplist,2,-1)
         
         strCode = StrCat(strCode , '' , @CRLF)
         strCode = StrCat(strCode , 'EndWhile' , @CRLF) 
         strCode = StrCat(strCode , 'ObjectCollectionClose(hEnum)' , @CRLF)
          strCode = StrCat(strCode , '' , @CRLF) 
         strCode = StrCat(strCode , '; close object handles' , @CRLF) 
         strCode = StrCat(strCode , 'ObjectClose(objInstances)' , @CRLF) 
         strCode = StrCat(strCode , 'ObjectClose(objSecurity)' , @CRLF) 
         strCode = StrCat(strCode , 'ObjectClose(objService)' , @CRLF) 
         strCode = StrCat(strCode , 'ObjectClose(objLocator)' , @CRLF) 
         strCode = StrCat(strCode , '' , @CRLF) 
         strCode = StrCat(strCode , '' , @CRLF) 
         strCode = StrCat(strCode , ';*************************************' , @CRLF) 
         strCode = StrCat(strCode , ';*     Display results' , @CRLF) 
         strCode = StrCat(strCode , ';*************************************' , @CRLF)

         strCode = StrCat(strCode , '#DefineSubroutine udfFormat4Display(vname)', @CRLF)
         strCode = StrCat(strCode , '   value = %%vname%%' , @CRLF)
         strCode = StrCat(strCode , '   if VarType(value)==256 ; Value is an array' , @CRLF)
         strCode = StrCat(strCode , '      ;if array then create pipe delimited list' , @CRLF)
         strCode = StrCat(strCode , '      arraylist=""' , @CRLF)
         strCode = StrCat(strCode , '      for item = 0 to ArrInfo(value,1)-1' , @CRLF)
         strCode = StrCat(strCode , '         arraylist = Strcat(arraylist,"|",value[item])' , @CRLF)
         strCode = StrCat(strCode , '      next' , @CRLF)
         strCode = StrCat(strCode , '      ;remove leading pipe' , @CRLF)
         strCode = StrCat(strCode , '      value=strsub(arraylist,2,-1)' , @CRLF)
         strCode = StrCat(strCode , '   endif' , @CRLF)
         strCode = StrCat(strCode , '    return(value)', @CRLF)
         strCode = StrCat(strCode , '#EndSubroutine', @CRLF)
         strCode = StrCat(strCode , @CRLF,@CRLF,@CRLF)

         strCode = StrCat(strCode , '; build display list',@CRLF)
         strCode = StrCat(strCode , 'displaylist = ""',@CRLF)
         propcount=ItemCount(proplist,",")

         ;get longest propr name size
         propsizemax=3
         For propitem=1 To propcount
             propname=ItemExtract(propitem,proplist,",")
             If StrLen(propname)>propsizemax Then propsizemax=StrLen(propname)
         Next


         For propitem=1 To propcount
            propname=ItemExtract(propitem,proplist,",")
            varname=UDFMakeVar(propname)
            propfill=StrFill(" ",propsizemax-StrLen(propname))
              strCode = StrCat(strCode , 'displaylist=strcat(displaylist,@LF, "',propname,propfill,' = ", UDFFormat4Display("',varname,'"))',@CRLF)
         Next

         strCode = StrCat(strCode , 'displaylist = StrSub(displaylist,2,-1)' ,@CRLF)
         strCode = StrCat(strCode , '; use fixed pitch font' ,@CRLF)
         strCode = StrCat(strCode , 'IntControl(28,1,0,0,0)' , @CRLF)
         strCode = StrCat(strCode , '; define coordinates for AskItemList' ,@CRLF)
         strCode = StrCat(strCode , 'IntControl(63,200,200,800,800)' , @CRLF)
         strCode = StrCat(strCode , 'AskItemList(class,displaylist,@LF,@unsorted,@single)' , @CRLF)

         strCode = StrCat(strCode , 'Exit' , @CRLF) 
   
         ObjectClose(objSecurity)
         ObjectClose(objLocator)
         ObjectClose(objService)

         DialogControlState(WBOMATIC_Handle,004,DCSTATE_REMOVESTYLE,DCSTYLE_INVISIBLE)  ;  Set the invisible bit on editbox 
         DialogControlSet(WBOMATIC_Handle, 004,  DC_EDITBOX, strCode);update multiline box with WMI code
         DialogControlSet(WBOMATIC_Handle, 004,  DC_ITEMSCROLLPOS, 1);show code starting from top  ;MHW
         
         ;* once the code is successfully composed and put into the multiline box, ensure
         ;* that the run and save buttons are enabled
         ;run_button.disabled = False
         ;save_button.disabled = False
         
          Return(-1)      ;  Do default processing

   EndSwitch       ; WBOMATIC_Message
   Return(-1)      ;  Do default processing

   
   :WBERRORHANDLER
   error=LastError()
   msg = ""
   msg = StrCat(msg,"LastError Value is ",error,@CRLF)
   msg = StrCat(msg,"LastError String is ",IntControl(34,Error,0,0,0),@CRLF)
   msg = StrCat(msg,"wberrorhandlerline ",wberrorhandlerline,@CRLF)
   msg = StrCat(msg,"wberrorhandleroffset ",wberrorhandleroffset,@CRLF)
   msg = StrCat(msg,"wberrorhandlerassignment ",wberrorhandlerassignment,@CRLF)
   Message("Error",msg)


   :CANCEL
   Return(-2)


#EndFunction       ;End of Dialog Callback WBOMATICCallbackProc

;============================================================
;============================================================
;============================================================



title = "WMI_Scripter - WMI Code Generator
WinTitle("",title)

WBOMATICFormat=`WWWDLGED,6.1`

WBOMATICCaption = "%title%"
WBOMATICX=9999
WBOMATICY=9999
WBOMATICWidth=353
WBOMATICHeight=256
WBOMATICNumControls=006
WBOMATICProcedure=`WBOMATICCallbackProc`
WBOMATICFont=`DEFAULT`
WBOMATICTextColor=`DEFAULT`
WBOMATICBackground=`DEFAULT,DEFAULT`
WBOMATICConfig=0

WBOMATIC001=`095,236,032,011,PUSHBUTTON,DEFAULT,"Run",1,1,32,DEFAULT,DEFAULT,DEFAULT`
WBOMATIC002=`143,236,032,011,PUSHBUTTON,DEFAULT,"Quit",0,2,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
WBOMATIC003=`009,017,331,212,DROPLISTBOX,win32classes,DEFAULT,DEFAULT,3,DEFAULT,"Microsoft Sans Serif|6963|40|34","0|0|0",DEFAULT`
WBOMATIC004=`009,030,331,198,MULTILINEBOX,text,"Multiline edit 1",DEFAULT,8,DEFAULT,"Courier New|6963|40|49","0|0|0",DEFAULT`
WBOMATIC005=`191,236,032,011,PUSHBUTTON,DEFAULT,"Save",2,5,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
WBOMATIC006=`009,005,331,011,VARYTEXT,progress,"",DEFAULT,11,DEFAULT,"Microsoft Sans Serif|6963|40|34","255|0|0",DEFAULT`

ButtonPushed=Dialog("WBOMATIC")

Exit



Article ID:   W16280
File Created: 2014:07:18:09:12:16
Last Updated: 2014:07:18:09:12:16