使用设置服务配置服务 [英] Configure service with Set-Service
本文介绍了使用设置服务配置服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我可以设置服务通过Powershell在其自己的容器中运行吗?即.
Can I set a service to run in its own container thru Powershell? ie.
sc config<服务名>的Powershell等效项是什么?type = own
推荐答案
您可以在相应的WMI对象上更改服务类型属性.
You can change service type property on the corresponding WMI object.
# get service
$s = (Get-WmiObject win32_service -filter "Name='Fax'")
# change service type
$s.Change($null, $null, 16) # 16 = "Own Process"
您可以在此处找到其他值( http://msdn.microsoft.com/zh-CN/library/aa384901(v=vs.85).aspx )
Other values you can find here (http://msdn.microsoft.com/en-us/library/aa384901(v=vs.85).aspx)
确保更改方法中的ReturnValue等于0.您可以在上面的链接中找到错误代码的含义.
Make sure that ReturnValue from change method is equal to 0. Meaning of error codes you can find in the link above.
这篇关于使用设置服务配置服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文