The Core Technologies Blog

Professional Software for Windows Services / 24×7 Operation


Q&A: Why doesn’t “Allow service to interact with desktop” work?

  Our legacy Windows Service shows an alert box when it fails to print a document on our server 2012 R2 controller.

I went into the service, clicked on the properties and set it to be able to interact with the desktop. How come I still can’t see the alert windows? Do I need to change something else?

Allow service to interact with desktop

— Justin F.

Hi Justin.

Unfortunately that setting is from a bygone time. It no longer does what you expect. Let me explain.

Old versions of Windows supported interactive services

Old versions of Windows support interactive services

In Windows NT, 2000, XP and Server 2003 it was reasonable (and occasionally encouraged) for a service to create windows and other graphical elements. It was possible for someone logging in to the PC to see a service’s windows, happily intermingling with conventional applications on his desktop (like Word and Excel).

On those old operating systems, the “Allow service to interact with desktop” setting controlled the visibility of the service’s interface. If checked, the first person logging into the PC would see the service’s windows. If unchecked, the windows would not be visible. In short, the checkbox made sense.

However, in the mid-2000s, the concept of interactive services was exposed as a security risk. Hackers developed rogue Windows Services that would invade the desktop, requesting passwords, installing dangerous software and ultimately compromising a healthy computer. Those so called shatter attacks (because they visibly shatter the user’s secure environment) emerged as a serious threat.

Fortunately the folks in Redmond were quick to respond.

Interactive services are crippled (or eliminated) in current editions of Windows

Interactive services are crippled in current editions of Windows

Microsoft plugged the shatter attack security hole in Windows Vista. The remedy — known as Session 0 Isolation — is an architectural change that prevents a service’s windows from showing up on a regular desktop. Going forward, windows created by a service would be effectively hidden.

The change profoundly diminished the utility of the “Allow service to interact with desktop” option. Checking the box still enables a service to show its windows, but only on the hidden Session 0 desktop.

The reality is that on or off, the checkbox cannot empower a Windows Service to show itself on your own desktop.

But all is not lost for your situation…

However you can still see alerts from your service since you’re on Windows Server 2012

In versions of Windows where Session 0 is accessible — specifically Windows 8.1/8 and Server 2016/2012 — you can see the alerts from your service. You have to switch to Session 0 to see them though.

To make that possible:

  1. Enable interactive services.

    Start Regedit, navigate to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Windows and change the value of NoInteractiveServices from 1 to 0:

    Enable interactive services registry value
  2. Enable the Interactive Services Detection service.

    Launch Services, open the Interactive Services Detection service and change the Startup type to Automatic or Automatic (Delayed Start):

    Enable the Interactive Services Detection service

With that in place, Windows will pop up a window whenever your service is showing an alert in Session 0:

Interactive Services Detection prompt

Click View the message to switch to the austere Session 0 desktop where you should see your alert window.

And when you’re done, click Return now to go back to the safety of your regular desktop.

Note: There is no way to see your service’s alerts on Windows Server 2019

Unfortunately the solution for Server 2012 will not work on Server 2019 because Microsoft has completely removed access to Session 0 in their newest operating systems. There is simply no way to see an application running on the hidden desktop.

Please keep that in mind before upgrading your server!

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

Q&A: How do I Restart my Windows Service at a Specific Time every Week?

Restart Windows Service at a Specific Time
  I want to restart some specific service for a specific time every week. Can I use the NET command?

— Shanmuga

Hi Shanmuga.

Yes. With the help of the Windows Task Scheduler, you can use the NET command to restart a specific service at a specific time.

To do so:

1. Find the name of your service

Each Windows Service has two names — a short service name and a friendly display name. We need the service name for the NET command.

If you don’t already know the service name, or want to validate it:

  1. Launch the Windows Services application. You can find it by searching for “services” in the Control Panel, or by running services.msc at a command prompt.

  2. Scroll to locate your service in the list:

    Windows Services application
  3. Double-click the entry to open the service’s properties. The service name is displayed at the top.

Here we see that the name of the Print Spooler service is actually “Spooler”:

Print Spooler service name

2. Create a batch file to restart your service

With the service name in hand, we can now use the NET command to restart the service.

Create a new batch file and enter the following two commands:

NET STOP "Your Service Name"
NET START "Your Service Name"

Please replace Your Service Name with the service name identified in step 1. The quotes are required if the service name contains a space.

For example, if your service name is “Spooler”, the batch file should look like this:

NET STOP "Spooler"
NET START "Spooler"

Save the batch file to a well-known location. We’ll use it in the next step.

Test the batch file

At this point, we recommend performing a quick test to ensure that the batch file works as expected. Run it from an administrative command prompt and confirm that it restarts your service.

3. Create a scheduled task to run the batch file at the time you wish to restart the service

Now that you are able to restart the service with the batch file, let’s schedule it to run whenever you like.

For example, here is how we would restart the Print Spooler service every Sunday at 1 AM:

  1. Open the Windows Task Scheduler. You start it from the Control Panel or by running taskschd.msc from a command prompt.

  2. Click Create Basic Task on the right:

    Task Scheduler: Create Basic Task

    The Create Basic Task Wizard window will come up.

  3. Give the task a descriptive name:

    Enter the task name

    Click Next to continue.

  4. Select Weekly and click Next:

    Set the task to run weekly
  5. Set the day and time to restart the service:

    Set the day and time to restart the service

    Click Next to continue.

  6. Ensure that the action is Start a program and move to the next step:

    Set the action - Start a program
  7. Enter the full path to the batch file you created to restart the service:

    Specify the batch file to restart the service

    Click Next to continue.

  8. Review the summary and make sure that everything looks good.

    Check the Open the Properties dialog… box at the bottom because we’ll need to adjust one of the tasks properties:

    Review the summary of the task

    Click Finish.

  9. And finally, in the Properties window, check the Run with highest privileges box. The batch file must run with administrative rights so that it can restart the service.

    Run the task with highest privileges

    Click OK to save your settings.

Going forward, the new task will come alive at the scheduled time to promptly restart the service. You should be good to go.

Improvement: Use ServicePilot instead of NET for better reliability

Use ServicePilot instead of NET.EXE

While NET.EXE will work for most situations, there are a few scenarios where it may fall short.

Does your service:

  • take longer than 30 seconds to shut down?
  • occasionally hang and refuse to stop?

If so, the NET STOP command may fail. And when that happens, the subsequent call to NET START will fail too (because the service will not be idle). The end result is that your service will be left in an unusable/unresponsive state!

Our free ServicePilot utility was built to work around NET’s shortcomings. It will wait for longer than 30 seconds if necessary and will do its best to forcibly terminate an unresponsive service.

To use ServicePilot instead of NET:

  1. Download ServicePilot from our website. Save the executable in a well-known location (e.g. C:\Apps\ServicePilot\ServicePilot.exe).

  2. Edit the batch file you created to restart the service.

  3. Delete the two NET lines.

  4. Add the following line (adjusting the full path to ServicePilot and your service name as necessary):

    C:\Apps\ServicePilot\ServicePilot.exe -restart -wait 300 "Your Service Name"

    Note: The -wait 300 parameter instructs ServicePilot to wait up to 300 seconds (5 minutes) for the service to stop and restart. Feel free to increase (or decrease) the timeout based your specific use case.

  5. Save the batch file.

As you did with the NET version, please perform a quick test to ensure that the updated batch file works as expected. Launch it from an administrative command prompt and confirm that it restarts your service.

Best of luck with your service!


New! UPDATE: Use our free Service Scheduler utility instead of the Task Scheduler

We got tired of manually creating batch files and scheduled tasks to control our services so we created a free application to do it all. 🙂

With Service Scheduler, you can easily start, stop or restart any Windows Service — daily, weekly or monthly at a time of your choosing:

Service Scheduler

Service Scheduler is completely free and super easy to use. You can schedule your service in seconds:

Service Scheduler: Add Daily Service Task

Download Service Scheduler and check it out today!


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

Why you should Disable Smart Sync when Running Dropbox as a Windows Service

Dropbox Smart Sync

What is Dropbox Smart Sync?

The team at Dropbox says it best:

 Smart Sync is a Dropbox feature that helps you save space on your hard drive. Access every file and folder in your Dropbox account from your computer, using virtually no hard drive space. Smart Sync is available for Dropbox Plus and Professional customers, and members of Dropbox Business teams.

And this short video discusses the considerable benefits of Smart Sync:

Indeed, Smart Sync has been a very popular feature since its debut in 2017.

How Smart Sync works: Supporting technologies

Smart Sync leverages a trio of Windows capabilities:

1. NTFS Sparse Files technology

NTFS Sparse File functionality allows Dropbox to create an “empty shell” for any file — with all the usual information (name, size, etc.) but with none of the actual content.

So when you create a file on Dropbox.com, the file’s information (its “metadata”) is immediately downloaded to your computer but none of the file’s contents are transferred in that operation. As a result, you can see the file on your system but it consumes almost no space on your hard drive. Very efficient!

But what happens when you try to access the zero-content file? That’s where the next technology comes in…

2. Windows file system Minifilter driver technology

When you access a file in your Dropbox folder, demanding to see its content, a Windows Minifilter driver ensures that the file’s contents are quickly fetched from Dropbox.com. The arrangement is fairly technical, but the following example illustrates the basic concept.

Suppose you have an online-only file called “notes.txt” in your Dropbox folder. Its contents have not yet been downloaded to your computer. When you double-click on the file:

  1. Windows starts Notepad (the program associated with .TXT files), passing it the full path to notes.txt.
  2. Notepad calls the Windows API ReadFile function to grab the contents of notes.txt
  3. But before invoking ReadFile, Windows intercepts the operation and notifies the Dropbox Minifilter that a program would like to read the contents of notes.txt.
  4. The Minifilter, seeing that the file’s contents have not yet been downloaded, arranges for the file’s contents to be retrieved from Dropbox.com and saved on the local PC.
  5. Windows next calls ReadFile, which returns the contents of the file.
  6. Notepad displays the contents of the file.

Most of the magic happens in step 4. The next section examines how that works.

3. Windows Interprocess Communication (IPC)

At first, we thought that the Minifilter component did all the heavy lifting, downloading content as necessary. However Dropbox says otherwise (the Minifilter is a “system extension”):

We don’t use system extensions to make network requests
We don’t use system extensions to parse any data in the filesystem
We don’t use system extensions to read or write files

Clearly the Minifilter isn’t downloading the files from Dropbox.com. So what’s doing it?

The answer: Dropbox.exe — the process run when you launch Dropbox on your desktop.

So when you request an “online-only” file not yet on your hard drive:

  1. The Minifilter receives the request.
  2. The Minifilter contacts the Dropbox.exe process and asks it to get the file.
  3. Dropbox.exe goes out to the Internet and downloads the file from Dropbox.com.
  4. Windows makes the file available to the user.

The Minifilter and Dropbox.exe interact using Windows Interprocess Communication — a collection of technologies supporting communication between different programs.

Now that we understand how Smart Sync works, let’s highlight three implications of the technical architecture.

Implication #1: Files cannot be downloaded without an Internet connection

This shouldn’t be a surprise.

Since files are fetched from the cloud as needed, you must be connected to the Internet to download files from Dropbox.com.

Dropbox confirms this limitation in their FAQ as well:

Can I access online-only content when I’m not connected to the internet?
No, online-only content isn’t stored locally on your computer. Connect to the internet to access online-only content.

Implication #2: Files cannot be downloaded if Dropbox isn’t running

As mentioned before, the Dropbox process (Dropbox.exe) plays a key role in downloading “incomplete” Smart Sync files. No file can be downloaded if Dropbox is not running.

To be clear, the Minifilter is always notified when you try to access an “online-only” file in the Dropbox folder. But if Dropbox isn’t running, there is no way for the Minifilter to download the file. The operation fails and you get a wonderful “Unspecified error” message (pictured here from the Dropbox forums):

Unspecified Error when opening a file

Note that this behavior only occurs when Smart Sync is on. Without Smart Sync — where Dropbox synchronizes all files to your hard drive — each document you see on your computer is readily available whether Dropbox is running or not.

Implication #3: Files cannot be downloaded if Dropbox is running as a Windows Service

Perhaps the most subtle consequence of the Smart Sync architecture has to do with background operation. Specifically, the Minifilter and Dropbox must operate in the same Windows Session for the two to communicate.

This is not a problem when you use Dropbox interactively on the desktop. All components run in the single logon session and Dropbox downloads files on demand, as expected.

However, customers running Dropbox as a background Windows Service face a problem. Dropbox will be running in Session 0 (the home for all Windows Services), while the Minifilter will be operating in the user’s interactive session (for example Session 1). The components will not be able to communicate and the files cannot be downloaded or opened. The “Unspecified Error” will abound.

So if you’re running Dropbox as a Windows Service (perhaps with our AlwaysUp utility), you should definitely turn Smart Sync off. Read on to find out how to do that.

How to Disable Smart Sync

You have a couple of options. You can either disable Smart Sync for specific folders, or turn off the feature entirely.

Disable Smart Sync for a single folder

This video illustrates how to adjust your Smart Sync folder settings:

And here are the step-by-step instructions to disable Smart Sync for a specific folder only:

  1. Click the Dropbox tray icon (Dropbox tray icon) to open the Dropbox menu
  2. Click the folder icon in the upper right:
    Open Dropbox Folder
  3. Find the folder that you would like to change. Right-click that folder and select Smart Sync > Local from the menu:
    Set Smart Sync folder to Local

That’s it. In a minute or two, the Dropbox process will notice the change and will download the entire folder to your hard drive.

Turn off Smart Sync for your Dropbox Plus, Professional, or Business account

To turn off the Smart Sync feature entirely, please follow these instructions to opt out of the system extension on Dropbox.com.

Dropbox Business team administrators can deactivate Smart Sync by opting out here (sign in required).

Questions about Smart Sync? Need Help?

Please get in touch and we’ll be happy to help — with this or any Dropbox feature.

Posted in Dropbox | Tagged , , , , | 5 Comments

Moving your AlwaysUp Applications/Services? Easily Import Them All at Once

Easily import applications/services into AlwaysUp

Do you manage multiple applications in AlwaysUp?

Across multiple machines?

If so, AlwaysUp’s new “bulk import” feature might make your life a bit easier. 🙂

Instead of adding applications one-by-one (as described in the “How to move your applications” article), you’re now able to import up to 50 applications/services together. This has the potential to save you a ton of time when you have lots of services to move.

Let’s run through the new import process, to give you a feel for how it works.

How to import applications & create new Windows Services

  1. First, choose “Import” from the “Application” menu:

    AlwaysUp Import Menu
  2. In the file selector that comes up, choose the XML files you wish to import. You can select up to 50.

  3. AlwaysUp reviews your request for a few seconds:

    Windows Service Applications Import: Preparing
  4. Next, AlwaysUp examines each file, checking for common errors. Here you can see the Dropbox service being validated:

    Windows Service Applications Import: Validating Dropbox
  5. Depending on the results of validation, you may encounter one or more of the following “problem” screens.

    For example, if an XML file is unreadable, corrupt or does not contain valid XML, you may see this error:

    Import Applications: Bad XML Error

    Your only option will be to skip the file.

    If the Windows account that should run the application is not available, you will receive the following notice:

    Import Applications: Unknown Windows Account

    To fix the problem, click the Edit & Fix button to open the application’s properties, switch to the Logon tab and specify a valid account.

    Similarly, if no password appears in the XML file — a common occurrence since AlwaysUp strips away passwords when exporting — a password will be requested:

    Import Applications: Enter Windows Password

    Other errors and warnings may come up as well. For example, the password for your mail server may be missing or the path to your executable may be different on the new server:

    Import Applications: Plex Errors/Warnings

    Once again, you will have to invoke Edit & Fix to continue.

  6. Once validation is complete, you will be presented with a summary of the results:

    Import Applications: Ready to Create Services

    So far no applications have been added to AlwaysUp and no new services have been created. If you cancel now, importing would have done nothing to your computer.

  7. When you are ready to proceed, click Continue to start the addition/creation phase. Here we see the Plex Windows Service being created:

    Import Applications: Adding Plex Windows Service

    Note: Even though the files & applications were already validated, you may still run into trouble while services are being created. As before, you will have the opportunity to fix the problem (or skip the application).

  8. And finally, the process concludes with a summary of the number of applications created:

    Import Applications: Done

All done. Wasn’t that easy?

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

AlwaysUp 12: Bulk Import & Improvements for Dropbox

New Version of AlwaysUp

AlwaysUp version 12 is out!

Here are the most notable advancements in our popular “run anything as a Windows Service” software:

Easily import application XML files “in bulk” — instead of one at a time

The best way to copy (or move) an AlwaysUp application to a different computer is to:

  1. Export the application to an XML file (from the existing installation), and then

  2. Import the XML file to create a new application (with the new installation)

This works beautifully if you have one or two services, but importing files one by one creates significant overhead if you have 20 applications to restore!

The new “bulk import” capability aims to reduce that overhead. With the new feature, you simply select the files you wish to import and walk through the step-by step wizard to create your new applications.

Take a look at some of the screens:

Easily import your Windows Service applications into AlwaysUp

In the coming weeks, we’ll write an article that digs into this new process in greater detail. But in the meantime, please don’t hesitate to try it!

Smoother shutdowns for your Dropbox Windows Service

Customers running the popular Dropbox file synchronization software may notice that the latest version launches multiple copies of Dropbox.exe. One instance is responsible for file synchronization, while another two are there for crash protection and stability. The whole curious arrangement is described in our “Why are there 3 copies of Dropbox Running on my PC?” post from December 2019.

Dropbox processes in Task Manager

AlwaysUp version 12 understands how Dropbox works and will shut down the three processes in the optimal order. Doing so avoids orphaned/leftover processes whenever the Dropbox service stops.

Other fixes & improvements

  • Our team spent considerable time bulletproofing of the code for Windows Server 2019. The changes are the result of thousands of hours of testing in our rigorous quality assurance simulator.

  • The program’s Help menu now links directly to the most common FAQ entries, to provide expert guidance when customers need it most:

    AlwaysUp Help/FAQ Menu

  • Licensing problems — though rare — are handled much more gracefully now. (We aim to eliminate the problems entirely in a future release.)

  • Our development team managed to sneak in a couple of under-the-hood tweaks for Windows 10 Insider Preview Build 19577, released last week. (Thankfully there don’t seem to be any significant changes to Windows Services in Microsoft’s latest revision of the forever OS.)

As usual, please review the release notes for the full list of features, fixes and improvements included in AlwaysUp 12.

Upgrading to AlwaysUp 12

If you purchased AlwaysUp version 11 (after June 2018), you can upgrade to version 12 for free. Simply download and install “over the top” to preserve your existing applications and all settings. Your registration code will continue to work as well.

If you bought AlwaysUp version 10 or earlier (before June 2018), you will need to upgrade to use version 12. Please purchase upgrades here — at a 50% discount.

See the full upgrade policy for additional details.

Enjoy!

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