def taskkillbyname(killname):
preq=os.popen('tasklist /fi "imagename eq {}"'.format(killname))
pidlist=[]
for p in preq:
plist=p.split(" ")
for pl in plist:
if pl.isnumeric() and pl is not killname:
pidlist.append(pl)
break
# print(p,end="")
# os.system('chcp 65001')
for pid in pidlist:
preq=os.popen("taskkill /f /pid {}".format(pid))
taskkillbyname("chrome.exe")
【python代码块】通过进程名批量结束同名进程
最新推荐文章于 2023-04-05 12:37:36 发布