Getting the process list on win98

Roger Upole rupole at hotmail.com
Tue Mar 15 07:56:14 EST 2005


   WMI didn't come installed on Win98.  You can download the
addon for win98 from Microsoft.
   If I recall correctly from when I last used it on 98, GetObject
didn't work for wmi.  You might have to use
win32com.client.Dispatch('Wbemscripting.Swbemlocator')
to create the object.

    hth
         Roger

"Ron" <radam2 at tampabay.rr.com> wrote in message 
news:qekZd.117526$pc5.16285 at tornado.tampabay.rr.com...
> I've written a screen saver which opens multiple copies on windows 98. I'm 
> trying to check the process list to determine if it is already running.
>
> So far all the example win32 routines I've found, through google, only 
> work on newer xp and nt versions of windows. This is the current attempt 
> to get the process list on windows 98:
>
> def GetProcessNameList():
>     from win32com.client import GetObject
>     WMI = GetObject('winmgmts:')
>     processes = WMI.InstancesOf('Win32_Process')
>     names = []
>     for process in processes:
>         names += [process.Properties_('Name').Value]
>     return names
>
> def IsRunning( filename ):
>     n = 0
>     for process in GetProcessNameList():
>         if process.lower() == filename.lower():
>             n += 1
>     return n
>
>
> Then in the startup section:
>
>             filename = os.path.basename(sys.argv[0])
>             # Wait for preview window to exit.
>     t = clock()
>             while IsRunning( filename) > 1 and clock() < t + 3:
>                 sleep(.01)
>     # Start screen saver if only self is running.
>             if IsRunning( filename)==1:
>                 saver = Screensaver()
>                 saver.launchScreenSaver()
>
>
> Results in this error on windows 98, works fine on windows xp:
>
> Traceback (most recent call last):
>   File "Aztec.pyw", line 255, in ?
>   File "Aztec.pyw", line 38, in IsRunning
>   File "Aztec.pyw", line 29, in GetProcessNameList
>   File "win32com\client\__init__.pyc", line 73, in GetObject
>   File "win32com\client\__init__.pyc", line 88, in Moniker
> pywintypes.com_error: (-2147221014, 'Moniker cannot open file', None, 
> None)
>
> The program is in python v2.3 and packaged using pyexe, and inno setup.
> 




----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= East/West-Coast Server Farms - Total Privacy via Encryption =---



More information about the Python-list mailing list