|
|
|
@ -1129,7 +1129,8 @@ bind_port = {bport} |
|
|
|
if os.name == 'nt': # Windows系统 |
|
|
|
return self._get_processes_windows(port) |
|
|
|
else: # Linux/Mac系统 |
|
|
|
return self._get_processes_linux(port) |
|
|
|
self.append_send_output(f"linux系统") |
|
|
|
return [] |
|
|
|
except Exception as e: |
|
|
|
self.append_send_output(f"[错误] 获取端口信息时出错: {e}\n") |
|
|
|
return [] |
|
|
|
@ -1141,7 +1142,7 @@ bind_port = {bport} |
|
|
|
# 方法1: 使用netstat命令 |
|
|
|
result = subprocess.run( |
|
|
|
['netstat', '-ano', '-p', 'tcp'], |
|
|
|
capture_output=True, text=True, encoding='gbk' |
|
|
|
capture_output=True, text=True, encoding='gbk',creationflags=subprocess.CREATE_NO_WINDOW # 不创建窗口 |
|
|
|
) |
|
|
|
|
|
|
|
lines = result.stdout.split('\n') |
|
|
|
@ -1169,7 +1170,7 @@ bind_port = {bport} |
|
|
|
ps_command = f"Get-NetTCPConnection -LocalPort {port} | Select-Object OwningProcess, @{{Name='ProcessName'; Expression={{ (Get-Process -Id $_.OwningProcess).Name }} }}" |
|
|
|
result = subprocess.run( |
|
|
|
['powershell', '-Command', ps_command], |
|
|
|
capture_output=True, text=True, timeout=10 |
|
|
|
capture_output=True, text=True, timeout=10,creationflags=subprocess.CREATE_NO_WINDOW # 不创建窗口 |
|
|
|
) |
|
|
|
|
|
|
|
if result.returncode == 0: |
|
|
|
@ -1193,7 +1194,7 @@ bind_port = {bport} |
|
|
|
try: |
|
|
|
result = subprocess.run( |
|
|
|
['tasklist', '/fi', f'pid eq {pid}', '/fo', 'csv', '/nh'], |
|
|
|
capture_output=True, text=True, encoding='gbk' |
|
|
|
capture_output=True, text=True, encoding='gbk',creationflags=subprocess.CREATE_NO_WINDOW # 不创建窗口 |
|
|
|
) |
|
|
|
|
|
|
|
if result.returncode == 0 and result.stdout.strip(): |
|
|
|
@ -1287,6 +1288,7 @@ local_port = {bport} |
|
|
|
self.append_output(f"创建配置文件失败: {e}\n") |
|
|
|
return False |
|
|
|
|
|
|
|
# 在所有的 subprocess.Popen 调用中添加 CREATE_NO_WINDOW 标志 |
|
|
|
def execute_frpc(self): |
|
|
|
"""执行frpc命令""" |
|
|
|
try: |
|
|
|
|