23

Using Set-Service, I'm able to change the StartType of my services between the accepted values of Boot, System, Automatic, Manual, Disabled. Using services.msc, I'm able to set some services to startup with a Priority of Automatic (Delayed Start). However, Get-Service still reports these delayed-start services as StartType : Automatic, and Set-Service errors out when attempting to set these values.

Am I able to set this property via powershell? Or am I limited to the UI or GPO?

4 Answers 4

11

PowerShell 6.0 has added the option StartType to Automatic - Delayed in Set-Service cmdlet

ex: Set-Service -Name "Testservice" –StartupType "AutomaticDelayedStart"

https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.management/set-service?view=powershell-6

0
27

No direct way in PowerShell, just use sc

sc.exe config NameOfTheService start= delayed-auto 

in older versions of Windows you needed a space after the equal sign, this doesn't seem to be required anymore but it still works.

You can also change the registry keys:

HKLM\SYSTEM\CurrentControlSet\Services\NameOfTheService\Start = 2
HKLM\SYSTEM\CurrentControlSet\Services\NameOfTheService\DelayedAutostart = 1
1
  • 2
    calling sc.exe directly makes it easy to pipe the result for later handling. as well - this answer gave me the idea to just query the registry directly with Get-ItemProperty to determine if the service is DelayedAutostart. Jul 6, 2018 at 7:29
8

There is no simple way to do it using powershell cmdlets. In my opinion the easiest way is to use sc.exe. Here is one way to do that:

$myArgs = 'config "{0}" start=delayed-auto' -f 'TheServiceName'
Start-Process -FilePath sc.exe -ArgumentList $myArgs
1
  • My version require a space after the equal sign Sep 11, 2019 at 23:26
3

The catch is to use "StartupType" instead of "StartType" when you are searching for "AutomaticDelayedStart, which is introduced in PowerShell 6.

After a bit of trial and error and error, this worked for me:

Get-Service | Where-Object {$_.StartupType -eq "AutomaticDelayedStart"} | Sort-Object status

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .