Thread: Using wmi.cfc

    #1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2004
    Posts
    14
    Rep Power
    0

    Using wmi.cfc


    I am trying to use the wmi.cfc component to query the win32_process on a specific machine. The problem I am getting is that the array outputs the first computer in a list of several computers. Here is the code I am using:
    Code:
    <cfif #hostname# eq "machine16">
        <cfset obj_wmi = CreateObject( "component", "wmi" ).init() />
        <td nowrap="nowrap" align="left" class="tdCell">#hostname#	
    <cfset NutPro = obj_wmi.execQuery("Win32_Process")/>
        <cfdump var="#NutPro#">
    <cfelse>
    <td nowrap="nowrap" align="left" class="tdCell">#hostname#
    </cfif>
    The proplem is the array NutPro outputs machine1. I want it to just output machine16.

    What am I doing wrong?

    Mike V.
  2. #2
  3. No Profile Picture
    Moderator

    Join Date
    Jun 2002
    Location
    Raleigh, NC
    Posts
    5,264
    Rep Power
    968
    Sorry, I have no idea what the "wmi.cfc" component is. It's definitely not something built into CF.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2011
    Posts
    1
    Rep Power
    0

    wrong class?


    It looks like you are simply instantiating a reference to the WMI component. Then asking for a list of CPU PROCESSES.
    So you should, by default, get an ARRAY of class instances for procs.
    (When you dump your NutPro variable.)

    As to WHICH machine you are fetching the list of Processes from, you haven't really shown that in your code. I see you switching on #HOSTNAME# but you don't show what sets that or where you are getting it from.

    I presume that "Machine16" simply isn't matching #hostname# and therefore going into the OUTPUT Hostname ELSE piece of the code.

    So i must be missing some info nor provided (or the point entirely). 8)

IMN logo majestic logo threadwatch logo seochat tools logo