WMI in Python

Discussion in 'Python' started by KING LABS, Sep 13, 2010.

  1. KING LABS

    KING LABS Guest

    Hi All,

    I am new to programming and python, Being a system administrator I
    have chose Inventory (Software & Hardware ) as my first project.

    I would like to know experts advice on the best way to build the same
    using python. I would like to this tool to evolve into full fledge
    application.

    I would like to collect the complete information of system hardware &
    and also software installed from registry and add/remove program and
    feed this data into database.

    Regards,
    KINGLABS
    KING LABS, Sep 13, 2010
    #1
    1. Advertising

  2. The easiest way to do this is to use the native OS tools readily available to do the collection and log to a central location or if possible shared location accessible by all systems, once you have all the data you want to feed into your RDBMS you could easily parse these logs using python and the native db access module.

    I hope this give you a pointer.

    Sent from my iPhone 4.

    On Sep 13, 2010, at 8:45 AM, KING LABS <> wrote:

    > Hi All,
    >
    > I am new to programming and python, Being a system administrator I
    > have chose Inventory (Software & Hardware ) as my first project.
    >
    > I would like to know experts advice on the best way to build the same
    > using python. I would like to this tool to evolve into full fledge
    > application.
    >
    > I would like to collect the complete information of system hardware &
    > and also software installed from registry and add/remove program and
    > feed this data into database.
    >
    > Regards,
    > KINGLABS
    > --
    > http://mail.python.org/mailman/listinfo/python-list
    Rodrick Brown, Sep 13, 2010
    #2
    1. Advertising

  3. KING LABS

    KING LABS Guest

    On Sep 13, 6:42 pm, Rodrick Brown <> wrote:
    > The easiest way to do this is to use the native OS tools readily available to do the collection and log to a central location or if possible shared location accessible by all systems, once you have all the data you want to feed into your RDBMS you could easily parse these logs using python and the native db access module.
    >
    > I hope this give you a pointer.
    >
    > Sent from my iPhone 4.
    >
    > On Sep 13, 2010, at 8:45 AM, KING LABS <> wrote:
    >
    >
    >
    > > Hi All,

    >
    > > I am new to programming and python, Being a system administrator I
    > > have chose Inventory (Software & Hardware ) as my first project.

    >
    > > I would like to know experts advice on the best way to build the same
    > > using python. I would like to this tool to evolve into full fledge
    > > application.

    >
    > > I would like to collect the complete information of system hardware &
    > > and also software  installed from registry and add/remove program and
    > > feed this data into database.

    >
    > > Regards,
    > > KINGLABS
    > > --
    > >http://mail.python.org/mailman/listinfo/python-list


    I am trying to learn Python programming. Since I need a custom
    inventory management tool for my work place. I am considering it as a
    project in the process of learning Python.

    I am not looking for easiest way of doing things.
    I am considering using Python . Also I would need to build a setup of
    the tool for easy installation.

    Hope I am clear this time

    Regards,
    KINGLABS
    KING LABS, Sep 13, 2010
    #3
  4. KING LABS

    Ed Leafe Guest

    On Sep 13, 2010, at 9:51 AM, KING LABS wrote:

    > I am trying to learn Python programming. Since I need a custom
    > inventory management tool for my work place. I am considering it as a
    > project in the process of learning Python.
    >
    > I am not looking for easiest way of doing things.
    > I am considering using Python . Also I would need to build a setup of
    > the tool for easy installation.
    >
    > Hope I am clear this time



    If you're looking for a rich client (i.e., desktop) application, and not a web app, you should check out Dabo: http://dabodev.com. We have hundreds of developers around the world using Dabo to build many different kinds of business applications.


    -- Ed Leafe
    Ed Leafe, Sep 13, 2010
    #4
  5. KING LABS

    Aahz Guest

    In article <>,
    KING LABS <> wrote:
    >
    >I would like to collect the complete information of system hardware &
    >and also software installed from registry and add/remove program and
    >feed this data into database.


    You should subscribe to the win32 mailing list:

    http://mail.python.org/mailman/listinfo/python-win32

    Before you ask questions there, do a bit of searching first -- there are
    lots of examples.
    --
    Aahz () <*> http://www.pythoncraft.com/

    [on old computer technologies and programmers] "Fancy tail fins on a
    brand new '59 Cadillac didn't mean throwing out a whole generation of
    mechanics who started with model As." --Andrew Dalke
    Aahz, Sep 13, 2010
    #5
  6. KING LABS

    Jerry Hill Guest

    On Mon, Sep 13, 2010 at 8:45 AM, KING LABS <> wrote:
    > Hi All,
    >
    > I am new to programming and python, Being a system administrator I
    > have chose Inventory (Software & Hardware ) as my first project.


    You'll probably want to look at the python WMI module:
    http://timgolden.me.uk/python/wmi/index.html

    as well as the pywin32 module: http://sourceforge.net/projects/pywin32/

    IIRC, there's been quite a bit of discussion about inventorying
    installed software on the pywin32 mailing list:
    http://mail.python.org/mailman/listinfo/python-win32

    --
    Jerry
    Jerry Hill, Sep 13, 2010
    #6
  7. KING LABS

    KING LABS Guest

    On Sep 14, 10:39 am, KING LABS <> wrote:
    > On Sep 13, 8:31 pm, Jerry Hill <> wrote:
    >
    > > On Mon, Sep 13, 2010 at 8:45 AM, KING LABS <> wrote:
    > > > Hi All,

    >
    > > > I am new to programming and python, Being a system administrator I
    > > > have chose Inventory (Software & Hardware ) as my first project.

    >
    > > You'll probably want to look at the python WMI module:http://timgolden.me.uk/python/wmi/index.html

    >
    > > as well as the pywin32 module:http://sourceforge.net/projects/pywin32/

    >
    > > IIRC, there's been quite a bit of discussion about inventorying
    > > installed software on the pywin32 mailing list:http://mail.python.org/mailman/listinfo/python-win32

    >
    > > --
    > > Jerry

    >
    > Thank you all, I will go through the links provided and suggestions.
    > Shall get back to you on this soon.


    The following information is exactly what I am trying to collect for
    the inventory. I can find vb scripts with googling. I want to do the
    same with Python & Win32. Use Server/Client architecture .
    Client(agent) updates the information to server.

    ----------------------------------------------------------------------------------------

    BIOS:

    System serial number, manufacturer, and model
    Bios manufacturer, version, and date

    Processors:

    Type, count (how many of them), manufacturer, speed, and cache

    Memory:

    Physical memory type, manufacturer, capacity, and slot number
    Total physical memory
    Total swap/paging memory

    Video:

    Video adapter: Chipset/model, manufacturer, memory size, speed, and
    screen resolution

    Display monitor: Manufacturer, description, refresh rate, type, serial
    number, and caption

    Storage/removable devices:

    Manufacturer, model, size, type, speed( all when applicable)

    Drive letter, filesystem type, partition/volume size, free space

    Network adapters/telephony:

    Manufacturer, model, type, speed, and description
    MAC and IP address, mask and IP gateway, DHCP server used

    Miscellaneous hardware:

    Input devices: Keyboard, mouse, and pointing device
    Sound devices: Manufacturer name, type, and description
    System slots: Name, type, and designation
    System ports: Type, name, caption, and description

    Software Information: ( from registry & add/remove program )

    Operating system: Name, version, comments, and registration info
    Installed software: Name, publisher, version (from Add / Remove
    software or Programs and Features menu)
    Custom-specified registry queries (applicable to Windows OS)

    ------------------------------------------------------------------------------------------------------------------
    KING LABS, Sep 14, 2010
    #7
  8. KING LABS

    bli Guest

    On Sep 14, 7:46 am, KING LABS <> wrote:
    > On Sep 14, 10:39 am, KING LABS <> wrote:
    >
    >
    >
    >
    >
    >
    >
    >
    >
    > > On Sep 13, 8:31 pm, Jerry Hill <> wrote:

    >
    > > > On Mon, Sep 13, 2010 at 8:45 AM, KING LABS <> wrote:
    > > > > Hi All,

    >
    > > > > I am new to programming and python, Being a system administrator I
    > > > > have chose Inventory (Software & Hardware ) as my first project.

    >
    > > > You'll probably want to look at the python WMI module:http://timgolden.me.uk/python/wmi/index.html

    >
    > > > as well as the pywin32 module:http://sourceforge.net/projects/pywin32/

    >
    > > > IIRC, there's been quite a bit of discussion about inventorying
    > > > installed software on the pywin32 mailing list:http://mail.python.org/mailman/listinfo/python-win32

    >
    > > > --
    > > > Jerry

    >
    > > Thank you all, I will go through the links provided and suggestions.
    > > Shall get back to you on this soon.

    >
    > The following information is exactly what I am trying to collect for
    > the inventory. I can find vb scripts with googling. I want to do the
    > same with Python & Win32. Use Server/Client architecture .
    > Client(agent) updates the information to server.
    >
    > ----------------------------------------------------------------------------------------
    >
    > BIOS:
    >
    > System serial number, manufacturer, and model
    > Bios manufacturer, version, and date
    >
    > Processors:
    >
    > Type, count (how many of them), manufacturer, speed, and cache
    >
    > Memory:
    >
    > Physical memory type, manufacturer, capacity, and slot number
    > Total physical memory
    > Total swap/paging memory
    >
    > Video:
    >
    > Video adapter: Chipset/model, manufacturer, memory size, speed, and
    > screen resolution
    >
    > Display monitor: Manufacturer, description, refresh rate, type, serial
    > number, and caption
    >
    > Storage/removable devices:
    >
    > Manufacturer, model, size, type, speed( all when applicable)
    >
    > Drive letter, filesystem type, partition/volume size, free space
    >
    > Network adapters/telephony:
    >
    > Manufacturer, model, type, speed, and description
    > MAC and IP address, mask and IP gateway, DHCP server used
    >
    > Miscellaneous hardware:
    >
    > Input devices: Keyboard, mouse, and pointing device
    > Sound devices: Manufacturer name, type, and description
    > System slots: Name, type, and designation
    > System ports: Type, name, caption, and description
    >
    > Software Information: ( from registry & add/remove program )
    >
    > Operating system: Name, version, comments, and registration info
    > Installed software: Name, publisher, version (from Add / Remove
    > software or Programs and Features menu)
    > Custom-specified registry queries (applicable to Windows OS)
    >
    > ------------------------------------------------------------------------------------------------------------------


    when I found Python :) I downloaded from a Ms site many (+- 120) py
    programs for hardware and os stuff and collated them into one script.
    Astonishing amount of data in the innards of a computer, do not print
    some of these!@#!
    I meant to wrap it in a neat menu (any time now), but it is easy to
    use as is.
    A few of the options :
    102 --- -List Terminal Services Terminals-
    103 --- -List Terminal Services Permissions-
    104 --- -List Terminal Services Session Settings-
    105 --- - List Terminal Services Session Directory Settings-
    106 --- - List Terminal Services Network Adapter-
    107 --- -List Terminal Services Environment Settings-
    108 --- -List Terminal Services Logon Settings-
    109 --- -List Terminal Services General Settings-
    110 --- -List Terminal Services Client Settings-
    111 --- -List Terminal Services Terminal Settings-
    112 --- -List Terminal Service Service Properties-
    113 --- -List Info about Binary Files used on Computer-
    114 --- -List Info about CODECS on this computer-
    115 --- -List Installed Software-
    116 --- -List Installed Software Features-

    Happy to send to you, will post it somewhere soon.
    bli, Sep 14, 2010
    #8
  9. KING LABS

    alex23 Guest

    KING LABS <> wrote:
    > The following information is exactly what I am trying to collect for
    > the inventory. I can find vb scripts with googling. I want to do the
    > same with Python & Win32. Use Server/Client architecture .
    > Client(agent) updates the information to server.


    I highly agree with the recommendations for Tim Golden's WMI library.
    I once used it during an MS VBScript course for sys admins to produce
    python equivalents of the VBS code; it was far, _far_ easier to
    componentise & reuse python code than VBS.

    However, for a quick & ready solution, have you looked at Microsoft's
    Scriptomatic?[2] It's a handy little tool that lets you specify the
    WMI query you want and produces code for you, with Python being one of
    the targets. It _should_ be able to handle most of everything you're
    after, with the exception of Software Information (from memory that's
    not something WMI covers?).

    Once Scriptomatic has generated the bulk of the WMI code, that's the
    payload of your client-side script. There are many many many ways of
    doing simple client/server set ups in python, just google and pick one
    that works at a suitable abstraction level for you. Here's a
    straightforward sockets-based approach[3] (that I've never used but
    looks okay).

    1: http://timgolden.me.uk/python/wmi/index.html
    2: http://www.microsoft.com/downloads/...42-648b-4119-b7eb-783b0f7d1178&displaylang=en
    3: http://wdvl.internet.com/Authoring/python/client/watts06152009.html
    alex23, Sep 16, 2010
    #9
  10. In message
    <>, alex23
    wrote:

    > However, for a quick & ready solution, have you looked at Microsoft's
    > Scriptomatic?[2] It's a handy little tool that lets you specify the
    > WMI query you want and produces code for you, with Python being one of
    > the targets.


    Why not just call Scriptomatic directly from within the Python script, then?
    Machine-generated code has no place in a source file to be maintained by a
    human.
    Lawrence D'Oliveiro, Sep 16, 2010
    #10
  11. KING LABS

    alex23 Guest

    Lawrence D'Oliveiro <_zealand> wrote:
    > Why not just call Scriptomatic directly from within the Python script, then?


    Because Scriptomatic _generates scripts to access WMI_, that's what it
    _does_. Are you _seriously_ advocating writing Python code to fire up
    a Windows application, programmatically manipulating a GUI to generate
    more Python code for your original script to import or exec?

    For your question to make any real sense, you'd want to ask "Why not
    access WMI directly...", which you might notice was the first
    recommendation I made.

    > Machine-generated code has no place in a source file to be maintained by a
    > human.


    As you've made your disdain for Windows _perfectly_ clear through your
    incessant sniping on this list, I think I'm pretty safe in saying you
    have no idea of the quality of Scriptomatic's output. I don't
    understand what possibly makes you believe you're qualified to make
    such a statement.
    alex23, Sep 16, 2010
    #11
  12. KING LABS

    KING LABS Guest

    On Sep 16, 12:39 pm, alex23 <> wrote:
    > Lawrence D'Oliveiro <_zealand> wrote:
    > > Why not just call Scriptomatic directly from within the Python script, then?

    >
    > Because Scriptomatic _generates scripts to access WMI_, that's what it
    > _does_. Are you _seriously_ advocating writing Python code to fire up
    > a Windows application, programmatically manipulating a GUI to generate
    > more Python code for your original script to import or exec?
    >
    > For your question to make any real sense, you'd want to ask "Why not
    > access WMI directly...", which you might notice was the first
    > recommendation I made.
    >
    > > Machine-generated code has no place in a source file to be maintained by a
    > > human.

    >
    > As you've made your disdain for Windows _perfectly_ clear through your
    > incessant sniping on this list, I think I'm pretty safe in saying you
    > have no idea of the quality of Scriptomatic's output. I don't
    > understand what possibly makes you believe you're qualified to make
    > such a statement.


    Thank you all .... looks I got lot of reading to be done now based on
    all your suggestions.
    KING LABS, Sep 16, 2010
    #12
  13. In message
    <>, alex23
    wrote:

    > Lawrence D'Oliveiro <_zealand> wrote:
    >
    >> Why not just call Scriptomatic directly from within the Python script,
    >> then?

    >
    > Because Scriptomatic _generates scripts to access WMI_, that's what it
    > _does_.


    Precisely why I suggested running it on the fly. Because machine-generated
    code has no place in a source file to be maintained by a human.

    > Are you _seriously_ advocating writing Python code to fire up
    > a Windows application, programmatically manipulating a GUI to generate
    > more Python code for your original script to import or exec?


    If that’s the only way you can use Scriptomatic, then the stupidity lies
    with the one who suggested using such a brain-dead tool in the first place.

    > As you've made your disdain for Windows _perfectly_ clear through your
    > incessant sniping on this list, I think I'm pretty safe in saying you
    > have no idea of the quality of Scriptomatic's output.


    The quality of the output is not at issue here. The point is that it is
    machine-generated from an input command, therefore it makes sense from a
    maintenance viewpoint to keep the input command, not the machine-generated
    output, in the source file, and simply generate the latter from the former
    as part of the build process.

    Unfortunately, as you have made abundantly clear above, Scriptomatic is a
    GUI-only tool, totally unsuited to this sort of use.
    Lawrence D'Oliveiro, Sep 17, 2010
    #13
  14. KING LABS

    alex23 Guest

    Lawrence D'Oliveiro <_zealand> wrote:
    > Because machine-generated
    > code has no place in a source file to be maintained by a human.


    Endlessly repeating your bigotry doesn't make it any more true.
    alex23, Sep 17, 2010
    #14
  15. In message
    <>, alex23
    wrote:

    > Lawrence D'Oliveiro <_zealand> wrote:
    >
    >> Because machine-generated
    >> code has no place in a source file to be maintained by a human.

    >
    > Endlessly repeating your bigotry doesn't make it any more true.


    The point is that it is machine-generated from an input command, therefore
    it makes sense from a maintenance viewpoint to keep the input command, not
    the machine-generated output, in the source file, and simply generate the
    latter from the former as part of the build process.
    Lawrence D'Oliveiro, Sep 18, 2010
    #15
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. MK
    Replies:
    4
    Views:
    795
  2. Dips
    Replies:
    0
    Views:
    573
  3. Harald Massa

    Googling for wmi and python....

    Harald Massa, Feb 6, 2005, in forum: Python
    Replies:
    0
    Views:
    268
    Harald Massa
    Feb 6, 2005
  4. Marc Wyburn

    python create WMI instances

    Marc Wyburn, Jun 10, 2005, in forum: Python
    Replies:
    0
    Views:
    302
    Marc Wyburn
    Jun 10, 2005
  5. Tim Golden

    RE: python create WMI instances

    Tim Golden, Jun 10, 2005, in forum: Python
    Replies:
    2
    Views:
    524
Loading...

Share This Page