windows script host and python

Alex Martelli aleaxit at yahoo.com
Fri Mar 16 10:39:53 EST 2001


"bowman" <bowman at montana.com> wrote in message
news:8Aps6.104$pl.1515 at newsfeed.slurp.net...
>
> Syver Enstad <syver at NOSPAMcyberwatcher.com> wrote in message
> news:98oq3r$1e0$1 at troll.powertech.no...
> >
> > Just curious but what do plan to acheive by using python with wsh that
you
> > couldn't do using normal .py files?
>
> even more curious: can Python hook up and use WMI from a normal .py?

Sure, why not?  As MS say, in their "Microsoft Windows Management
Instrumentation Scripting" paper,
"""
The WMI SDK includes a scripting API that you use to create scripts
and Visual Basic-based applications to interact with the CIM Object
Manager. It supports the following languages:
    [snip]
Additionally, you can also use any scripting language implementation
that supports Microsoft's Active Scripting technologies with this API
(such as a Perl scripting engine).
"""
and Python (with win32all) DOES support ActiveScripting, of course.

Here, for example, is the "list all running processes" WMI scripting
example translated into Python:

from win32com.client import GetObject

processes = GetObject("winmgmts:{impersonationLevel=impersonate}").\
    InstancesOf("Win32_process")

for process in processes:
    print process.Name


Alex







More information about the Python-list mailing list