有没有办法使用通配符更改服务启动类型


1

有人可以告诉我,是否可以在命令提示符或powershell中完成此操作?我能够通过粗略显示显示名称来停止并开始服务。但不确定是否可以这样做以改变启动类型。请指教。谢谢。

Answers:


0

替代使用wmic(需要在提升的提示下运行)

wmic service where "name like 'xbox%'" call changestartmode startmode="Disabled"


2

这可以使用Set-Service PowerShell cmdlet完成:

Get-Service -DisplayName xbox* | Set-Service -StartupType Disabled

上面的行将找到显示名以“xbox”开头的所有服务,并将结果传递给Set-Service,并将启动类型设置为Disabled。添加-WhatIf到行尾以确认返回所需的服务而不更改启动类型。


此外,我可以使用此命令停止所有显示名为“X”的服务,但显示名为“Y”的服务除外。
亚伦

是的,只需将结果传递给Stop-Service而不是Set-Service。
FastEthernet
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.