Set service StartType to Automatic - Delayed

Solution 1:

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

Solution 2:

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

Solution 3:

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