杀进程

总觉得电脑上的进程太多,影响速度用 python写了个小程序:

 

import os
import sys

def getpname(p):
    pnm, poth = p.split(' ', 1)
    pnm = pnm.lower()
    pid = poth.strip(' ').split(' ',1)[0]
    return pnm, pid


def main():
    fname = os.path.join(sys.path[0],'proclist.txt')
    f = open(fname,'r')
    flist = list()
    for l in f:
        if l != '':
            flist.append(l.strip('\n'))
    
    pfile = os.popen('tasklist')
    pfile.readline()
    pfile.readline()
    pfile.readline()
    for l in pfile:
        if l is not None:
            pnm, pid = getpname(l)
        if pnm in flist:
            cmd = "taskkill /F /PID " + pid
            os.system(cmd)

if __name__ == '__main__':
    main()
 

进程文件列表:

uclauncherservice.exe
jqs.exe
jusched.exe
pcsuite.exe
servicelayer.exe
nclusbsrv.exe
nclbcbtsrv.exe
nclrssrv.exe
isuspm.exe
trcboot.exe
dlactrlw.exe
tsvncache.exe
lpmgr.exe
tphdexlg.exe
wdfmgr.exe
 

 

 

 

 

你可能感兴趣的:(python,OS,F#)