terminating an inactive process

fred.dixon fred.dixon at gmail.com
Sat Apr 2 10:37:24 EST 2005


i use this to open/close netscape as it also doesnt like to close all
the time. its a WMI script but easiely edited.

check out script-o-matic from ms-downloads , it outputs python code as
well as others.
######################################################################
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer &
"\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from
Win32_Process",,48)
For Each objItem in colItems
    strProcess = Ucase(objItem.Name)
    If strProcess = "NETSCP.EXE" Then
        objItem.Terminate()
    End If
Next
'---------------------
MyVar = MsgBox ("Do you want to start Netscape Mail and News " &
chr(13) & chr(13) & "Any Zombie processes have been exorcised from the
machine already." & chr(13) & chr(13) , 308, "Warning!")
Set objWMIService = Nothing
Set colItems = Nothing
If MyVar = 7 Then
    Wscript.Quit
Else
    sExecStr = "C:\Program Files\Netscape\Netscape\Netscp.exe -mail"
    Dim oShell, obj
    Set oShell = WScript.CreateObject ("WSCript.shell")
    Set obj = oShell.exec(sExecStr)
    Set oShell = Nothing
    Set obj = Nothing
End If

'--------------------------------
MyVar = MsgBox ("Click to close Netscape")
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer &
"\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from
Win32_Process",,48)
For Each objItem in colItems
    strProcess = Ucase(objItem.Name)
    If strProcess = "NETSCP.EXE" Then
        objItem.Terminate()
    End If    
Next
Set objWMIService = Nothing
Set colItems = Nothing




More information about the Python-list mailing list