Invisible processes in Win2K

henrik.garbergs at telia.com henrik.garbergs at telia.com
Wed Jun 20 05:12:03 EDT 2007


Hi!

I'm running a Python program on M$ Windows 2000 as a test monitor. The program 
should close various processes, mostly "Application error"-windows, as they are 
created. This works fine until the screensaver gets active or until I press 
Ctrl-Alt-Del and choose "Lock my computer". At that point, my Python program 
cannot see any change when a "Application error" pops up. Without locked 
computer, it can identify these windows and close them, but I want it to do 
this with the computer locked as well. (My company has a policy that says you 
have to lock the computer or activate a password protected screensaver when you 
leave your desk)

The code I'm using to list processes looks like this:

# ------------------------------------        
def process_callback_function(hwnd, resultdict):
....# Callback-function for win32gui.EnumWindows    
....wtext = win32gui.GetWindowText(hwnd)
....if wtext != '' and wtext != 'Default IME':
........resultdict.update( {wtext:hwnd} )
# ------------------------------------                
def getProcessDictionary(w):
....try:
........win32gui.EnumWindows(process_callback_function, w)
....except Exception, message:
........logAndPrint('Error in getProcessDictionary: ' + str(message))
# --------------------------------
def getProcessList():
....# Flush old cache
....win32pdh.EnumObjects(None, None, 0, 1)    
....# Get a list of processes running on the system:
....try:
........junk, instances = win32pdh.EnumObjectItems(None,None,'Process', 
win32pdh.PERF_DETAIL_WIZARD)
....except win32api.error, message:
........logAndPrint('Error in getProcessList(): ' + str(message))
........return []
....else:
........return instances
# --------------------------------

# Code in main loop:
topWindows = {}      
getProcessDictionary(topWindows)
for w in topWindows.iteritems():
...if 'Application Error' in w[0]:
.......closeProcess(w[1])


I'm using two functions to receive process info: getProcessList and 
getProcessDictionary. I have tried to save the result of these, compare them at 
different times in the main loop and print newly started processes. This works 
great outside "locked computer"-mode where it prints all new processes found, 
including Application errors. But when the computer is locked and Application 
errors pops up, the Python program shows no new processes. It's not hanged or 
freezed, since it can identify the screensaver and also keep doing other work. 
So what is so special about the error windows?

Any help with this is greatly appreciated!

Best regards,
/Henrik




More information about the Python-list mailing list