The Core Technologies Blog

Professional Software for Windows Services / 24×7 Operation

Q&A: Why did my Windows Service Start Unexpectedly?

Why did my Windows Service Start Unexpectedly?
  I’ve got a Windows Service that keeps starting by itself. Why is that happening? I’m pulling my hair out trying to figure out why…

— Colin P.

Hi Colin.

There may be several culprits here. Let’s go through a few.

1. Your service is required by another service

Does your Windows Service support any other services? Is another service “dependent” on yours?

If so, then starting that other service may start yours too.

This can be a bit confusing so let’s illustrate with an example.

Here we have a service called “Dropbox (managed by AlwaysUpService)” — created with our AlwaysUp product:

Dropbox AlwaysUp Windows Service

We made the Dropbox service dependent on the “Fax” service. Indeed, you can see the relationship on the Dependencies tab:

Dropbox service dependencies

It’s important to note that the dependency stipulates the following situation:

The Fax service must be running before the Dropbox service can start

To test the implications of that relationship, we:

  1. Stopped both the Dropbox and Fax services, and

  2. Started the Dropbox service.

Afterwards, we saw that the Fax service was running:

Fax service: Running

Apparently when we started the Dropbox service, Windows realized that the Fax service was needed and quietly started Fax as well.

So that’s one way for a service to start inadvertently.

With that example in mind, please check if another service depends on your service. If so, Windows may be starting your service because of that dependency relationship.

2. Your service is “trigger started” by Windows

Legacy versions of Windows presented a couple of options for when a service was started:

  1. Automatically — by Windows — when your computer booted;

  2. Manually — by a person or application — when needed.

Windows Vista (2007) introduced a third option: Trigger start. Now, services can be started in response to key operating system events.

And the set of triggering events is varied. For example, a trigger start service can be launched whenever:

  • Someone plugs in a USB drive;

  • Your computer joins a domain;

  • A network port is opened;

  • A custom event (or system state change) occurs.

Trigger start services reveal themselves in the Startup type column of the Services application. As you can see in this screenshot, there are quite a few on our Server 2022 machine:

Trigger start services

This article explains the difference between “Automatic (Trigger Start)” and “Manual (Trigger Start)”.

Is your service configured to trigger start? If so, it may be starting when its associated event fires.

You can use our free Service Trigger Editor utility to investigate the service and the events that trigger it. Removing the trigger may be an effective solution but please be sure to understand the consequences of doing so!

3. Someone is starting your service manually

I don’t know what your service does, but might someone else be starting it to get their work done? You want the service to be idle but perhaps a colleague needs it running!

Is someone else with access to your machine launching the service?

Best to check around and find out.

4. An application running on your PC is starting the service

Some folks say that applications are people, too. 🙂

Well, maybe not, but a program can certainly stop and start a Windows Service — just like a person can.

For example, an application that supports Bluetooth may fire up the Bluetooth Support Service if it’s not running. Indeed, the application likely calls the Windows API (the ControlService function) instead of using the NET or SC commands, but the effect will be the same.

So do you know of a program that needs your service to operate?

If so, you should consider uninstalling the application.

Our recommendation: Investigate with Windows Service Auditor

If you can’t figure out who (or what) is starting your Windows Service, it’s time to get your detective hat on.

Start with the Windows Event Viewer. Do you see the service starting and stopping? Can you tell who’s doing it? Pay attention to the times as they could shed light on the situation.

But if you’re still in the dark, we recommend bringing out the big gun: our free Windows Service Auditor.

Windows Service Auditor

Windows Service Auditor introduces extra logging, to shine a bright light on your Windows Service. For example, here it’s telling us that “Mike Jones” updated the “Windows Update” service today at 10:59 AM:

Windows Service Auditor Event

Hopefully you’ll solve the mystery soon.

Good luck!

Posted in Windows Services | Tagged , , , , , , | Leave a comment

How to Export the List of Windows Services on Your Computer

How to Export the List of Services on Your Computer

1. Export to CSV or tabbed text with the Services application

Perhaps the easiest way to export your services is with the built-in Windows Services application — services.msc.

To export, simply:

  1. Start Services. Click the Start button, type services.msc in the search field and hit return.

  2. From the Action menu, select Export List:

    Services: Export List
  3. Choose the format (tab delimited text or CSV), enter a file name and click Save to create the file.

Your file will contain the following five columns of data, which you cannot customize:

  1. Name (Note: This is the service’s display name, not its unique name used by Windows)

  2. Description

  3. Status

  4. Startup Type

  5. Log On As

If that’s all you need then you’re good to go!

2. Export to CSV or XML with PowerShell

Even though it’s easy to do, exporting with the Services application may not provide all the information you would like to capture. For example, the service name is not included and neither is the command line used to start the service.

If you’d like more columns, then PowerShell is another option.

For example, this command lists all the services on your machine:

Get-CIMInstance -Class Win32_Service | Select-Object Name, DisplayName, Description, StartMode, DelayedAutoStart, StartName, PathName, State, ProcessId

The output looks like this:

PowerShell: List all services

Note that you can add or remove properties from the Select-Object section as you see fit. Feel free to include any property listed in the Win32_Service class documentation.

And once you’ve settled on a command that prints the necessary information, call the Export-CSV module at the end to send the results to a file.

For example, this command exports the list of services to “C:\output-file.csv”:

Get-CIMInstance -Class Win32_Service | Select-Object Name, DisplayName, Description, StartMode, DelayedAutoStart, StartName, PathName, State, ProcessId | Export-CSV -Path C:\output-file.csv

If you prefer to create an XML file, call Export-Clixml instead:

Get-CIMInstance -Class Win32_Service | Select-Object Name, DisplayName, Description, StartMode, DelayedAutoStart, StartName, PathName, State, ProcessId | Export-Clixml -Path C:\output-file.xml

But we must warn you — the XML created is a bit difficult to read (or parse):

Services exported to XML with PowerShell

3. Export to XML with Windows Service Auditor

Finally, if you’re after XML, our free Windows Service Auditor utility is worth a look.

We created Windows Service Auditor to help protect against changes to your important Windows Services but it has the ability to export the list of services to an XML file as well.

After downloading and starting Windows Service Auditor, simply select Export (XML} from the All Services menu to create the XML file:

Windows Service Auditor: Export XML

The XML will be very detailed, with all aspects of your Windows Services recorded. Here is an example:

XML created by Windows Service Auditor

Because its output is so detailed, Windows Service Auditor is your best option if your goal is to take a snapshot of your services and all their settings.

Hopefully one of these three methods works for you!

Posted in Windows Services | Tagged , , , , | Leave a comment

Q&A: Why can’t AlwaysUp run my Batch File?

Why can't AlwaysUp run my Batch File?
  Hi. I think I’ve written a batch file that your AlwaysUp software cannot run as a service.

Here are the contents of my file:

@echo off
> usermessage.vbs ECHO Set wshShell = CreateObject( “WScript.Shell” )
>>usermessage.vbs ECHO wshShell.Popup “My Text line 1” ^& vbCrLf ^& _
>>usermessage.vbs ECHO “My Text line 2” ^& vbCrLf ^& _
>>usermessage.vbs ECHO “My Text line 3” ^& vbCrLf ^& _
>>usermessage.vbs ECHO “My Text line 4” ^& vbCrLf ^& _
>>usermessage.vbs ECHO “My Text line 5” ^& vbCrLf ^& _
>>usermessage.vbs ECHO “My Text line 6” ^& vbCrLf ^& _
>>usermessage.vbs ECHO “My Text line 7” ^& vbCrLf ^& _
>>usermessage.vbs ECHO “My Text line 8” ^& vbCrLf ^& _
>>usermessage.vbs ECHO “My Text line 9”, 120, _
>>usermessage.vbs ECHO “My Window Title”, 64
WSCRIPT.EXE usermessage.vbs
DEL usermessage.vbs

I searched the internet for hours using various terms and finally found a suggestion that your software would solve my problem.

It runs perfectly if I just click on it. But I could not make it run as a service. I’m not a pro at this.

Any Ideas?

— John

Hi John. Thanks for trying AlwaysUp and for getting in touch.

What’s the batch file doing?

We’re not VBScript experts so it took us a while to understand what your batch file is doing!

However, it soon became clear that the batch file:

  1. Constructs a VBScript file named usermessage.vbs on the fly.

  2. Adds a line to usermessage.vbs to create a Windows Script shell object.

  3. Adds lines to usermessage.vbs that call the Popup function with several lines of text.

  4. Runs usermessage.vbs, which shows a popup window with the specified text. The popup will stay on screen for up to 120 seconds, or until the user clicks the OK button.

  5. Deletes the usermessage.vbs file.

In summary, the purpose of the batch file is to show this message box for up to 2 minutes:

The batch file shows a popup

It seems a bit contrived, but perhaps this code is a sample you created for testing? No doubt your “real” code is more practical and exciting. 🙂

AlwaysUp runs your batch file properly

AlwaysUp launches the batch file as a Windows Service just fine. And it has no problem running the dynamically created VBScript file either. We’re lucky to have hundreds of customers using AlwaysUp to launch their batch files, every day.

Indeed, we were able to setup your batch file in AlwaysUp and confirm that it runs as expected. Process Explorer showed AlwaysUp running the batch file, which launched the Windows Script Host executable (wscript.exe) to display the popup window. You can see this arrangement in the tree of processes on the left:

AlwaysUp running the batch file as a Windows Service

All good, right? Well, not entirely…

Session 0 Isolation prevents you from seeing the popup window

Even though your script is running, you will not be able to see the popup window on your desktop. That is because of Session 0 Isolation — an important security measure that constrains Windows Services.

You won’t see the popup because:

  1. your batch file is running in Session 0, on the special background desktop where all Windows Services operate, and

  2. Windows isolates applications running in Session 0, meaning that they cannot show up alongside the other windows on your screen.

Once upon a time, you were be able to switch to Session 0 to see the popup but no longer. Unfortunately, Microsoft removed that capability a few years ago. As a result, there is no way to see a window displayed in Session 0.

So in summary, your batch file will not pop up a window on your interactive desktop when you run it as a Windows Service. And that’s true even if you don’t use AlwaysUp because the restriction is built into Windows itself.

I hope this makes sense. Unfortunately, Session 0 Isolation can be tricky to comprehend. Please check out these FAQ entries if you want to dig into the details (caveat emptor):

And please be sure to get in touch if you have any other questions.

Best of luck with your project!

Posted in AlwaysUp | Tagged , , , , , | Leave a comment

How to Restart a Windows Service Every Day (or Week)

How to Restart a Windows Service Every Day (or Week)

The easiest way to restart your Windows Service is with our Service Scheduler tool.

It’s completely free, super simple to use and you can schedule your service in less than a minute.

For example, here’s how to restart the Windows Time service every day at midnight:

  1. Download Service Scheduler. Save the executable file on your desktop, or to a well-known folder on your computer.

  2. Double-click the ServiceScheduler.exe file to launch the program. If necessary, confirm the standard User Account Control (UAC) security prompt.

  3. Choose Service Task > New from the menu (or click the button):

    Service Scheduler: New Service Task
  4. In the Add Service Task window:

    1. Choose Restart

    2. From the list of services, select Windows Time (W32Time)

    3. Choose Every and Day

    4. And finally, set 12:00 AM in the time control:

    Restart W32Time daily at midnight
  5. Click the Save button. A new entry to restart the Windows Time service will appear in the list:

    Service task created
  6. And that’s it! Going forward, the Windows Time service will restart every day at midnight.

    Note that it’s just as easy to set up a weekly or monthly restart. Simply choose the appropriate day when configuring your service:

    Service Scheduler: Restart weekly or monthly


Posted in Windows Services | Tagged , , | Leave a comment