拒绝访问Python脚本Pstui

2024-09-30 04:26:29 发布

您现在位置:Python中文网/ 问答频道 /正文

所以基本上我已经用python创建了这个使用Psutil的应用程序。Iam使用它以非常高的速度暂停和恢复进程。虽然它对大多数过程有效,但对某些人却不起作用。我会提供下面的错误代码,但如果你真的决定帮助,请非常友好的Iam才刚刚开始python

import psutil
import time
import subprocess



print("Auto Suspender")

condition = 10

subprocess.call("taskkill /Program example")

print("Program Example has been killed :)")

time.sleep(1)

somepid = int(input("What is Process ID ?"))
p = psutil.Process(somepid)
print("Working...")
time.sleep(0.5)

while condition == 10:
    choice = input("1__Suspend")
    if (choice == "1"):
        while condition == 10:
            p.suspend()
            print("Suspended !")
            time.sleep(0.1)
            p.resume
            print("Resumed !")
    else:
        print("Invalid response")`enter code here`

获取错误

^{pr2}$

Tags: importinputtimesleepprogramconditionprocessiam
1条回答
网友
1楼 · 发布于 2024-09-30 04:26:29

我认为您没有足够的特权来暂停进程。在Windows操作系统(以及其他操作系统)中,有些进程是在另一个用户帐户下运行的,在Windows中通常是在系统帐户下运行的,普通用户不能挂起或终止这个进程。尝试以管理员用户身份运行脚本,这样脚本可能会正常工作。在

相关问题 更多 >

    热门问题