如何在Python中启动Windows Service,而无需管理Admin权利提示?
我已经尝试了以下链接中给出的各种解决方案以启动,在没有任何管理员权限提示的情况下停止Windows Service(RabbitMQ)(RabbitMQ)(因此可以在构建服务器中连续运行):
- os.System 方法 - > pytest终端要求管理员密码
- subprocess.run methot->我得到
访问被拒绝
错误消息
是否有可能在pytest中启动Windows Service绕过管理员权利? 如果是,我该怎么做?
I have tried various solutions given in the links below to start, stop Windows Service (rabbitmq) in a PyTest without any admin rights prompt (so it can run continuously in a build server):
- os.system method --> The PyTest terminal asks for administrator password
- subprocess.run method --> I got
Access Denied
error message
Is it possible to start stop Windows service in the Pytest bypassing the admin rights?
If yes, how can I do it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是不可能的。
当前没有绕过我知道的管理员许可的方法。
对您最初的问题的评论谈论了服务控制器工具并修改相应服务的SDDL。
从我阅读的内容这里您需要的命令是:
用您想要的服务替换“您的服务”。
做不是粘贴此命令,因为它将覆盖整个SDDL,请确保将其添加到您已经存在的SDDL中以防止系统故障。
但是,如前所述,您还需要管理员特权来设置此问题。如果设置一次并且没有逆转,则PC上的每个用户都有启动和停止服务的权利。
请记住,这使得该服务容易受到任何程序。
(对不起,如果我在解释时做错了什么,这是我在Stackoverflow上的第一个答案)
This is not possible.
There is no current way to bypass those administrator permission known to me.
Comments on your original question talked about the Service controller tool and modifying the SDDL of the corresponding service.
From what I've read here the command you need would be:
Replace "YourService" with your wanted service.
Do NOT paste this command as it would overwrite the whole SDDL, be sure to add it accordingly into your already existing SDDL to prevent system failure.
But, as mentioned before, you also do need Administrator priviliges to once set this. If it's set once and not reversed, every user on the PC has the right to start and stop the service.
Please remember that this makes the service vulnerable to any program.
(Sorry if I did anything wrong in explaining, this is my first ever answer on stackoverflow)