我最近开始在系统自动化上尝试使用python。下面是我试图运行来停止服务的代码,但是我得到了错误pywintypes.error:(5,'OpenSCManager','Access is denied.')。我浏览了一些在线博客和建议,但我似乎没有领会其中的要旨。我们是否需要使用提升的访问权限来运行它?如果是这样的话,我们该如何继续?
import os
import win32serviceutil
service = "Windows Update"
win32serviceutil.StopService(service)提前感谢所有人。
发布于 2020-07-10 00:20:55
导入操作系统
导入win32serviceutil
service = "Windows Update“
Win32serviceutil.StopService(服务)
您似乎想要通过python停止Windows Update。
Windows更新使用系统权限或管理权限(取决于您的操作系统和版本)在windows 10 1803中,您需要以管理权限(提升访问权限)运行它(.py文件或cmd,如果您通过CMD使用Python )。
如果它不工作,您需要通过组策略或注册表禁用它。
因为在Windows 10中,如果使用windows defender、Windows Update和Windows防火墙等系统权限,则会自动打开
Note: System Permission is Higher than the Administrator's permission.
It can deny and bypass the Administrator's actions and restrictions.
But System Permission relies on *Group Policy* or *Registry
In which the Administrator has access in it by defaulthttps://stackoverflow.com/questions/62817167
复制相似问题