资源简介
windows查杀端口小工具,可以根据端口进行查杀,程序猿日常必备神器,再也不用担心端口被占用,还可以同名称的进程一并关闭
代码片段和文件信息
“““通过端口号查杀对应程序
author: yufei
date: 2019-05-09
“““
from tkinter import *
import tkinter.messagebox as messagebox
from tkinter import ttk
import os
import re
class Application(frame):
def __init__(self master=None):
frame.__init__(self master)
self.pack()
self.createWidgets()
# 设置窗口标题:
self.master.title(‘端口查杀程序‘)
width = 700
height = 450
screenwidth = self.master.winfo_screenwidth()
screenheight = self.master.winfo_screenheight()
size = ‘%dx%d+%d+%d‘ % (width height (screenwidth - width) / 2 (screenheight - height) / 2)
self.master.geometry(size)
# 创建组件
def createWidgets(self):
fr1 = frame(self pady=6)
fr2 = frame(self pady=6)
fr1.pack(side=‘top‘)
fr2.pack(side=‘bottom‘ expand=YES fill=BOTH)
self.label = Label(fr1 text=‘端口号:‘)
self.label.pack(side=LEFT padx=3)
self.port_input = Entry(fr1)
self.port_input.pack(side=LEFT padx=6)
self.alert_button = Button(fr1 text=‘查询‘ width=6 command=self.search)
self.alert_button.pack(side=LEFT padx=6)
self.kill_button = Button(fr1 text=‘关闭程序‘ width=10 command=self.kill)
self.kill_button.pack(side=LEFT padx=6)
self.search_and_kill_utton = Button(fr1 text=‘查杀程序‘ width=10 command=self.search_kill)
self.search_and_kill_utton.pack(side=LEFT padx=6)
self.with_name = BooleanVar()
self.with_name_check = Checkbutton(fr1 text=‘同名称一并关闭‘ variable=self.with_name)
self.with_name_check.pack(side=LEFT padx=6)
columns = (“id“ “name“ “pid“)
self.table = ttk.Treeview(fr2 show=“headings“ height=17 columns=columns)
self.table.column(“id“ width=60 anchor=‘center‘) # 表示列不显示
self.table.column(“name“ width=350 anchor=‘center‘) # 表示列不显示
self.table.column(“pid“ width=200 anchor=‘center‘)
self.table.heading(“id“ text=“序号“) # 显示表头
self.table.heading(“name“ text=“程序名称“) # 显示表头
self.table.heading(“pid“ text=“进程号“)
self.table.pack(side=LEFT expand=YES fill=BOTH)
## 查找端口的pid
def find_pro(self):
find_port = ‘netstat -aon | findstr %s‘ % self.port_input.get()
result = os.popen(find_port)
text = result.read()
datalist = text.strip().split(‘\n‘)
# print(datalist)
datalist = list(filter(self.is_real datalist))
datalist = map(self.getPid datalist)
datalist = self.getDetail(set(datalist))
print(datalist)
return datalist
# 查询进程明细
def getDetail(self datalist):
l = []
count = 0
for i in datalist:
find_pro = ‘tasklist|findstr %s‘ % i
result = os.popen(find_pro)
text = result.read()
datalist = text.strip().split(‘\n‘)
print(datalist)
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2019-05-10 00:38 portSpirit\
目录 0 2019-05-10 01:10 portSpirit\.git\
文件 13 2019-05-10 00:38 portSpirit\.git\COMMIT_EDITMSG
文件 23 2019-05-09 20:30 portSpirit\.git\HEAD
文件 307 2019-05-09 20:32 portSpirit\.git\config
文件 73 2019-05-09 20:30 portSpirit\.git\desc
目录 0 2019-05-09 20:30 portSpirit\.git\hooks\
文件 478 2019-05-09 20:30 portSpirit\.git\hooks\applypatch-msg.sample
文件 896 2019-05-09 20:30 portSpirit\.git\hooks\commit-msg.sample
文件 3327 2019-05-09 20:30 portSpirit\.git\hooks\fsmonitor-watchman.sample
文件 189 2019-05-09 20:30 portSpirit\.git\hooks\post-update.sample
文件 424 2019-05-09 20:30 portSpirit\.git\hooks\pre-applypatch.sample
文件 1638 2019-05-09 20:30 portSpirit\.git\hooks\pre-commit.sample
文件 1348 2019-05-09 20:30 portSpirit\.git\hooks\pre-push.sample
文件 4898 2019-05-09 20:30 portSpirit\.git\hooks\pre-reba
文件 544 2019-05-09 20:30 portSpirit\.git\hooks\pre-receive.sample
文件 1492 2019-05-09 20:30 portSpirit\.git\hooks\prepare-commit-msg.sample
文件 3610 2019-05-09 20:30 portSpirit\.git\hooks\update.sample
文件 406 2019-05-10 01:08 portSpirit\.git\index
目录 0 2019-05-09 20:30 portSpirit\.git\info\
文件 240 2019-05-09 20:30 portSpirit\.git\info\exclude
目录 0 2019-05-09 20:31 portSpirit\.git\logs\
文件 945 2019-05-10 00:38 portSpirit\.git\logs\HEAD
目录 0 2019-05-09 20:32 portSpirit\.git\logs\refs\
目录 0 2019-05-09 20:31 portSpirit\.git\logs\refs\heads\
文件 945 2019-05-10 00:38 portSpirit\.git\logs\refs\heads\master
目录 0 2019-05-09 20:32 portSpirit\.git\logs\refs\remotes\
目录 0 2019-05-09 20:32 portSpirit\.git\logs\refs\remotes\origin\
文件 700 2019-05-10 00:39 portSpirit\.git\logs\refs\remotes\origin\master
目录 0 2019-05-10 00:39 portSpirit\.git\ob
目录 0 2019-05-10 00:37 portSpirit\.git\ob
............此处省略1060个文件信息
- 上一篇:IEEE-802.3-2008
- 下一篇:Proxmark3 冰人原版固件及客户端
相关资源
- lp_x64_zh-cn_Windows 10 Enterprise 2016 LTSB 中
- SDRplay_RSP_API-Windows-2.13.1.exe
- WindowsFormsApp1.rar
- 伏特加串口、网络调试助手 调试工具
- 银行卡号识别Demowindows程序
- 软件打包小工具2.0版本
- 数据结构课设二:用树形结构模拟W
- minio RELEASE.2020-06-22T03-12-50Z Windows版含
- 精通WindowsPowerShell脚本编程+WindowsPow
- xray_windows_amd64.exe.zip
- emqttd-windows7-v2.3.0.zip
- Windows Power Shell应用手册[高清版
-
MQTT单片机编程小工具(阿里云li
n - mp4v2 windows 已编译版本
- 基于LabWindows/CVI的虚拟仪器设计.pd
- 最新版windows node-v12.18.3-x64.msi
- Windows Server 2003 IIS 服务器组件完全安
-
Windows .NET fr
amework API 帮助文档5 - opencv-3.4.1-windows版本
- jdk-8u241-windows-x64 .zip
- cef_binary_85.0.0-4183_g44bd7ac+chromium-85.0.
- 深入浅出Windows10通用应用开发
- Appium-windows-desktop1.15.1
- Protege-5.5.0-windows.zip
- jdk-7u60-windows-x64.exe
- 深入解析Windows操作系统 第6版 上册(
- jdk-13_windows-x64_bin.exe
- 最新版windows gradle-6.5-bin.zip
- instantclient-basic-windows.x64-11.2.0.4.0
- Clash.for.Windows.Setup.0.7.11(1).zip
评论
共有 条评论