Getting the process list on win98

R

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.
 
T

Thomas Heller

Ron said:
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-us/wmisdk/wmi/system_requirements.asp

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

Thomas
 
R

Roger Upole

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 said:
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.
 
R

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.Swbemlocator') 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.
 

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. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top