6

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?

7

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
  • 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. – Peter Vandivier Jul 6 '18 at 7:29
5

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
2

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

  • Worth noting that Get-Service still reports this as “Automatic” though. Thanks for the tip! Finally convinced me to stop sleeping on PSCore – Peter Vandivier Apr 3 at 16:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.