Return to site

Windows Services Manual Trigger Start

broken image


Summary: Guest blogger, Karl Mitschke, discusses a Windows PowerShell script to start non-running services that are set to start automatically. Microsoft Scripting Guy, Ed Wilson, is here. Our guest blogger today is Karl Mitschke, one of the authors of the Windows PowerShell 2.0 Bible. Here is a little bit about Karl. Numerical value to indicate if the service startup type has: 0 - no startup triggers 1 - has startup triggers This macro is supported since Zabbix 3.4.4. It is useful to discover such service startup types as Automatic (trigger start), Automatic delayed (trigger start) and Manual (trigger start). Manual services do not. Triggers can be added to services to make them start on some event, such as an ETW event, or a USB device being plugged in, etc. Triggers can be added to either Manual or Automatic services. An example of the trigger (s) on an Automatic (Trigger Start) service.

  1. Start the Registry Editor by pressing the Start-button and Run.. this command:

    Regedit

  2. Browse through the left tree to where Services are found:

    [HKEY_LOCAL_MACHINE System CurrentControlSet Services]


  3. Within the Services-key find go to the short-name of the wanted service (Here RpcSS aka. Remote Procedure Call (RPC)):

    [HKEY_LOCAL_MACHINE System CurrentControlSet Services RpcSS]


  4. Double-Click the Start-value in the list to the right.
  5. Change Value data: to the wanted state:
    • 0 = Boot
    • 1 = System
    • 2 = Automatic
    • 3 = Manual
    • 4 = Disabled
  6. Press Ok and exit the Registry Editor.
  7. If setting a service to Disabled or Manual, then execute this command to stop the service:

    Net Stop RpcSS

  8. If setting the service to Automatic, then execute this command to start the service:

    Net Start RpcSS

Note in this guide the short-name of a service is shown just in parenthesis next to the 'Process Name'.
Note the 'Automatic' startup mode was extended with 'Automatic (Delayed Start)' with Windows Vista/2008. It specifies that the service startup can be delayed until after having performed user logon. It can be activated with the following DWORD registry setting:

Microsoft User Guides

[HKEY_LOCAL_MACHINE System CurrentControlSet Services BITS]
DelayedAutoStart = 1
Start = 2

Note the 'Manual' startup mode was extended with 'Manual (Trigger Start)' with Windows 7/2008 R2. It specifies that the service startup can be delayed until a certain event occurs (or be stopped). See what service trigger events that are configured for a service with this command:

sc qtriggerinfo w32time


More Info MS KB103000
More Info MS KB271362
More Info MS KB838428 (About hardware profiles)

Working with Services in PowerShell is probably one of the first tasks you'll undertake as a PowerShell newbie. Recently I needed to disable a few Windows services on a server and I'm a big believer in being able to get back to where you started so the first thing I set out to accomplish was to find out what the start mode was of the services I needed to change.

My demo machine doesn't have those particular services I referenced so the BITS service will be used for the demonstration in this scenario: Absolutely free cad cam downloads free music.

PowerShellSelect-Object</em> cmdlet, specify the <em>-Properties</em> parameter and use the wildcard character (asterisk) to return all properties and their values for the BITS service:</p>PowerShell<textarea wrap=' soft'='' readonly='>Get-Service -Name BITS | Select-Object -Property *1Get-Service-NameBITS|Select-Object-Property*
Startup

Windows 10 Services Manual Trigger Start

As you can see in the previous results, there's still isn't a StartMode parameter. You can certainly change the StartMode of a service from within PowerShell with the Set-Service cmdlet, so why can't you check to see what the StartMode is from within PowerShell?

It can be done in WMI and PowerShell has cmdlets for accessing WMI. It's not really PowerShell's fault that it doesn't natively display the StartMode property though. You see, PowerShell runs on the .Net Framework and the Get-Service cmdlet returns the same properties as the underlying .Net Framework class which that cmdlet uses:

PowerShell1

Window 10 Startup Repair

234Add-Type-AssemblyName'System.ServiceProcess'[System.ServiceProcess.ServiceController
Services
1Get-Service-NameBITS|Select-Object-Property*

Windows 10 Services Manual Trigger Start

As you can see in the previous results, there's still isn't a StartMode parameter. You can certainly change the StartMode of a service from within PowerShell with the Set-Service cmdlet, so why can't you check to see what the StartMode is from within PowerShell?

It can be done in WMI and PowerShell has cmdlets for accessing WMI. It's not really PowerShell's fault that it doesn't natively display the StartMode property though. You see, PowerShell runs on the .Net Framework and the Get-Service cmdlet returns the same properties as the underlying .Net Framework class which that cmdlet uses:

PowerShell1

Window 10 Startup Repair

234Add-Type-AssemblyName'System.ServiceProcess'[System.ServiceProcess.ServiceController]::GetServices()|Where-ObjectName-eqBITS|Select-Object-Property*

The previous results should look familiar (they're the same results as Get-Service).

We could use Get-CimInstance or Get-WMIObject to access WMI, specifically the Win32_Service class to see the StartMode property and its value for the BITS service:

PowerShell12Get-WmiObject-ClassWin32_Service-Filter'Name = 'BITS'|Select-Object-Property*

As you can see in the previous command, the StartMode for the BITS service is Manual.

I'm now going to change the StartMode for the BITS service to Automatic:

PowerShell-NameBITS-StartupTypeAutomatic

No error, but did the previous command do anything? You can make the previous command return the service that was changed by adding the -PassThru parameter:

PowerShellWindows 10 Service Manager-NameBITS-StartupTypeAutomatic-PassThru<p>I'll now double check to make sure the StartMode was indeed changed and this time I'll use the <em>Get-CimInstance</em> cmdlet which was introduced in PowerShell version 3 and can also be used to access WMI:</p>PowerShell<textarea wrap='soft' readonly='>Get-CimInstance -ClassName Win32_Service -Filter ' name='BITS' |select-object='' -property='' name,=''>12Get-CimInstance-ClassNameWin32_Service-Filter'Name = 'BITS'|Select-Object-PropertyName,StartMode

µ

Share this:

Like this:

LikeLoading..




broken image