如何在Python中停止作为管理员的Windows服务?
我已经尝试了几种方法,但是它们都没有用。
os.system('net stop service_name')
返回“系统错误5发生。访问被拒绝。
os.system('runas /user:Administrator net stop service_name')
没有错误,但什么也
subprocess.Popen(
['runas', '/user:Administrator', 'net stop service_name'],
stdin=subprocess.PIPE
)
process.stdin.write(b'admin_password_here')
发生
win32serviceutil.StopService(service_name)
没
I already tried a few ways but none of them worked.
os.system('net stop service_name')
which returns "System error 5 has occurred. Access denied.
os.system('runas /user:Administrator net stop service_name')
no errors, but nothing happened
subprocess.Popen(
['runas', '/user:Administrator', 'net stop service_name'],
stdin=subprocess.PIPE
)
process.stdin.write(b'admin_password_here')
again nothing happened
win32serviceutil.StopService(service_name)
and few more ways
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试添加
noprofile
:try add
noprofile
: