Application hang on exit?

Discussion in 'Scripting' started by Linn Kubler, Dec 22, 2008.

  1. Linn Kubler

    Linn Kubler Guest


    I have written a Visual FoxPro application to track my computer inventory.
    I adopted WMI scripting calls to remotely get information about the CPU,
    memory, NIC and hard drives from the computer in question. Works pretty
    slick. However, I've found one quirk that I'd like to correct if I can.

    Basically, if I query a computer then shut it down and exit my application
    it hangs. It's like one of the connections to the computer needs to be
    dropped by VFP before I shutdown the computer. Any idea how to rectify this

    Here is how I connect to the computer:
    strNamespace = "root\cimv2"

    objWbemLocator = CreateObject("WbemScripting.SWbemLocator")
    THISFORM.objWMIService = ;
    objwbemLocator.ConnectServer(strComputer, strNamespace, strUser,

    I've tried setting THISFORM.objWMIService = NULL but that doesn't work.

    Beyond that I'm just doing a series of Select calls to the computer like
    THISFORM.colCompSystem = THISFORM.objWMIService.ExecQuery ("SELECT * FROM
    Win32_ComputerSystem")THISFORM.colPhysicalMemory =
    THISFORM.objWMIService.ExecQuery ("SELECT * FROM Win32_PhysicalMemory WHERE
    capacity > 16777216")

    Any suggestions?

    Thanks in advance,
    Linn Kubler, Dec 22, 2008
    1. Advertisements

  2. Linn Kubler

    Linn Kubler Guest

    Do you open Visual Fox Pro with your script? Do you shut Visual Fox
    Pro down at the end?

    No, at this point I'm still running my scripts in VFP in the development
    mode. So I start VFP, do my development work and whatever including running
    this script multiple times. Then by the end of the day I will close down

    The work-around I've found is to make sure I exit the form that runs these
    scripts right after performing the inventory. That way I'm assured that the
    computer will still be on.

    I eventually want this to be part of a larger maintenance and monitoring
    program so I would like to figure out what I need to do to release this
    without having to close my application.

    Linn Kubler, Jan 22, 2009
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.