We can modify the service startup type by using WMI or with PowerShell v2 we can use set-service. This has a number of other useful functions. Its just a matter of testing the type we want to change the startup to and applying it to the service. This becomes another function in my services module.
001
002 003 004 005 |
function Set-StartupType {
param ([string]$name, [string]$type) if ("Automatic", "Manual", "Disabled" -contains $type) {Set-Service -Name $name -StartupType $type} else {Write-Host "Type must be Automatic, Manual or Disabled"} } |
You do need elevated privileges to change the startup type.
under: Uncategorized