所有在powershell下运行,需要使用管理员权限
0.参考链接
https://learn.microsoft.com/zh-cn/powershell/scripting/samples/managing-services?view=powershell-7.5
1.列出所有服务
get-service
#列出所有服务
get-service -name **
#筛选某个服务
#或者
get-service 服务名
2.删除某个服务
Remove-Service -name "test00"
#这个好像废弃了,用下面的这个
#2.1 remove-service 可能不好用,需要使用sc.exe
sc.exe delete 服务名称
#这里.exe 不能删除
#删除成功会显示 [SC] DeleteService SUCCESS
3.添加某个服务
New-Service -Name "MyService" `
-BinaryPathName "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Bypass -File C:\Path\To\YourScript.ps1" `
-DisplayName "My PowerShell Service" `
-Description "This is a custom PowerShell service."
4.注册表删除服务
#直接暴力删除注册表,此处是文件夹的形式存在
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services
#需要重启
2236

被折叠的 条评论
为什么被折叠?



