By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,621 Members | 1,029 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,621 IT Pros & Developers. It's quick & easy.

Getting the process list on win98

P: n/a
Ron
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.

Jul 18 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Ron <ra****@tampabay.rr.com> writes:
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: [...] 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.


It seems WMI is not installed per default in Win 95/98 and NT:
http://msdn.microsoft.com/library/en...quirements.asp

If pywin32 also doesn't support win98, you could build shallow wrappers
with ctypes maybe ;-)

Thomas
Jul 18 '05 #2

P: n/a
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.Swbemlocat or')
to create the object.

hth
Roger

"Ron" <ra****@tampabay.rr.com> wrote in message
news:qe********************@tornado.tampabay.rr.co m...
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 =---
Jul 18 '05 #3

P: n/a
Ron
Thanks for the reply Roger,

Since will put this on my web site for general use, I don't want users
to have to install additional software.

I'll try win32com.client.Dispatch('Wbemscripting.Swbemlocat or') see what
that does.

As a last resort, I use a registry key as a run status varable. Not my
first choice, but I think it will work for all win9x systems.
Roger Upole wrote:
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.Swbemlocat or')
to create the object.

hth
Roger

Jul 18 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.