The PowerShell script described here allows you to set the startup mode of a Windows service to Automatic (Delayed Start) on a local computer or on the remote computers specified in a list. The PowerShell script works on Windows 7, Windows 8, Windows 2008 (and R2), and Windows Server 2012 computers.

Sitaram Pamarthi

Sitaram Pamarthi is working as a Windows Engineer and his special fields of interest are PowerShell, Active Directory, Exchange, and virtualization.

Automatic (Delayed Start) is a new service startup mode that is available from Windows Vista onward. This startup type allows you to configure less important services to start a bit later when Windows boots up. This reduces the boot time of a Windows computer. Though it is a very good feature, Microsoft didn’t update the Win32_Service WMI class to support this new startup type. Because of this, it is difficult to set this startup type in scripts.

I came up with this script to ease the life of Windows Administrators. The script is a wrapper on top of SC.exe (service controller) that sets a given service to Automatic (Delayed Start). This script takes the service name (NOT the display name of the service) as input through the –ServiceName parameter and sets it to the Automatic (Delayed Start) startup type. You can delay the start of a service on remote computers using the –ComputerName parameter. Both parameters accept multiple values. The –ServiceName parameter is mandatory. The –ComputerName parameter is optional; when this parameter is not specified, it runs against the local computer.

The following code is the core part of the script.

This code uses the Invoke-Expression cmdlet to trigger the SC.exe-based command. After execution, it checks the value of $LASTEXITCODE to verify if the command executed successfully. $LASTEXITCODE is a PowerShell built-in variable that contains the return code of the last win32 executable execution. See my blog article to know more about this special variable.

Apart from displaying the output on the PowerShell console, this script saves the details of failed (failedcomputers.txt), success (successcomputers.txt), and unreachable (unreachableComputers.txt) computer names to text files in C:\. The location of these files can be changed by editing the path in the end{} block within the script.

Help and usage instructions:

You can use the Get-Help cmdlet to see the help and usage instructions of this script.

You can download the PowerShell script here. Feel free to ask questions in a comment below.

Win the monthly 4sysops member prize for IT pros


Related Posts

  1. Rafal 5 years ago

    Hey ,

    Why wouldnt you use native powershell ?

    Set-Service -ComputerName -Name -StartupType Delayed

    I think it would do the job as well 😉



  2. Author 5 years ago

    Hi Rafal, Sorry for the delayed reply. There is no startup type called "Delayed" for Set-Service cmdlet. Have you tried it? I am sure it will fail. See for details.


  3. Matthew 4 years ago

    Hello All,
    I wanted to say that this script has been fantasic. I was able to change most of the services I needed. I ran into an issue though with services that had a $ in them. For example, BTSSvc$BizTalkServerApplication from BizTalk 2013. Is there a way I can make it like the name I'm using.


  4. Lars Hædersdal 3 years ago

    Matthew you can use single-quotes, like


    That worked for med 🙂


  5. Paul Csiki 2 years ago

    Great post, helped me a lot today at work.


  6. Varsha 1 year ago

    Great post. Thank you.



  7. Michael Freidgeim 10 months ago
  8. Nikhil 8 months ago

    Script failing if service name contains spaces such as "Citrix Encryption Service". What to do?




    Failed to set CITRIX ENCRYPTION SERVICE to delayed start. More details: DESCRIPTION: Modifies
    a service entry in the registry and Service Database. USAGE: sc <server> config [service name] <option1> <option
    2>... OPTIONS: NOTE: The option name includes the equal sign. A space is required between the equal sign and the
    value. type= <own|share|interact|kernel|filesys|rec|adapt> start= <boot|system|auto|demand|disabled|delayed-auto> err
    or= <normal|severe|critical|ignore> binPath= <BinaryPathName> group= <LoadOrderGroup> tag= <yes|no> depend= <Depende
    ncies(separated by / (forward slash))> obj= <AccountName|ObjectName> DisplayName= <display name> password= <password>


    • Paul 7 months ago

      For services there is a Display Name(with spaces usually) property and also just a 'Name' property, that doesn't have any spaces. If you double click on a service you will see the name.  That's what you want to use for the script not the display name..


Leave a reply

Your email address will not be published. Required fields are marked *



Please ask IT administration questions in the forum. Any other messages are welcome.

© 4sysops 2006 - 2017

Log in with your credentials


Forgot your details?

Create Account