The Core Technologies Blog

Professional Software for Windows Services / 24×7 Operation



Q&A: How can a Non-Admin User Start my AlwaysUp Service?

How can a Non-Admin User Start my AlwaysUp Service?
  Hi — long time user of AlwaysUp here!

I followed your suggestion in the FAQ to allow my non-admin user to control the Windows Service that AlwaysUp created. Now he can run the NET command to start and stop our application in Session 0 whenever he likes, which is great. But we’re still having one problem.

Sometimes the user needs to start the application in the current session to make changes. The user manual says that running AlwaysUp.exe with the “-restart-in-current-session” parameter will do the trick.

And that command works fine for me (I’m an admin). However, the non-admin user is prompted for admin credentials because his account doesn’t have the rights to run AlwaysUp.

Is there any way to start AlwaysUp.exe without needing admin credentials?

— Steve

Hi Steve. Thanks for getting in touch — and for being a loyal customer!

Permissions is always a thorny topic but we can help you. Let’s start by reviewing why there is no direct remedy from the AlwaysUp executable (AlwaysUp.exe).

AlwaysUp needs admin rights to do its work

Unfortunately it’s not possible to launch AlwaysUp without elevated rights. That’s because AlwaysUp needs to:

  1. Read, create and update your Windows Services

  2. Interrogate the Windows Event logs for errors and warnings

  3. Carefully monitor your important applications and react quickly when they use too much memory, hog the CPU, hang or crash.

Typically only administrators — with broad access to low-level systems — can perform those actions.

So your non-admin user won’t be able to run AlwaysUp.exe. But as you know, there are other ways to start or stop the Windows Service created by AlwaysUp. Let’s explore the NET command since you’re already familiar with how it works.

Use NET to start your application in a given session

To recap, you’re already using the NET command to start your application. If your application is called “MyServer” in AlwaysUp, then this command will do the trick:

NET START "MyServer (managed by AlwaysUpService)"

Notice that you must add the "(managed by AlwaysUpService)" suffix as that is how the service is named in the Service Control Manager.

In any case, running that command instructs AlwaysUp to start your application in Session 0 — the background desktop hosting Windows Services. You won’t see the application on your normal desktop.

Fortunately slight variants of the NET command will enable you to launch your application in a specific session.

Provide a Session ID

To start in a specific session, add the session’s numeric identifier (the Session ID) to the command. The format is:

NET START "<ApplicationName> (managed by AlwaysUpService)" /<SessionID>

For example, to start “MyServer” in Session 2, run:

NET START "MyServer (managed by AlwaysUpService)" /2

That will launch your application in Session 2, regardless of who is logged in there.

Provide a Windows username

Alternately, you can pass a username to start the application in the session occupied by that Windows user. The format of that command is:

NET START "<ApplicationName> (managed by AlwaysUpService)" /"user:<UserName>"

For example, to start “MyServer” in the session where “psmith” is logged in, run:

NET START "MyServer (managed by AlwaysUpService)" /"user:psmith"

Note that if the given user is not logged in, AlwaysUp will start the application in Session 0.

How to use NET to start your application in the current session

To achieve what you’re trying to do, we recommend going with the username variant of the NET command.

This command — which features the USERNAME environment variable — will start your application on the current user’s desktop:

NET START "<ApplicationName> (managed by AlwaysUpService)" /"user:%USERNAME%"

Again, if your application is called “MyServer”, the precise syntax is:

NET START "MyServer (managed by AlwaysUpService)" /"user:%USERNAME%"

When you run the command, %USERNAME% expands to the username of the account invoking the command. In that way, the command works for whoever runs it.

We recommend saving the command to a batch file and placing the file on the user’s desktop, for easy access. With that, your application will only be a double-click away.

Enjoy!

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

Q&A: How do I Launch a Service after AlwaysUp Starts my Application?

How do I Launch a Service after AlwaysUp Starts Google Drive
   I’m interested in purchasing your AlwaysUp application but would like some further information first if you don’t mind.

My main goal is to run Google Drive for desktop as a service. But there is an existing Windows Service that I need to run after Google Drive has launched. Is it possible to use AlwaysUp to start it after Google Drive has started?

— Shaheed

Hi Shaheed, thanks for trying AlwaysUp.

The answer to your question is yes. Please follow these steps to setup Google Drive and your other service in AlwaysUp.

1. Install Google Drive as a service with AlwaysUp

As described in our step-by-step tutorial, the new AlwaysUp Application Advisor supports Google Drive for desktop:

Application Advisor supports Google Drive for desktop

Instead of leaving you to figure out and apply the best settings to support background file synchronization, simply click through the Advisor’s straightforward prompts to create your Google Drive service — in less than 2 minutes.

At the end of the process, your Google Drive for desktop will be installed as a 24/7 Windows Service. Afterwards, test and make sure that the new service syncs your files as expected.

2. Have AlwaysUp start the other service after it runs Google Drive

Now that Google Drive is set up, let’s turn our attention to starting the other service at the right time.

Please:

  1. Edit your Google Drive for desktop entry in AlwaysUp.

  2. Move to the Automate tab.

  3. Check the When the application starts… box at the top.

  4. Enter the following command (which will start your service):

    C:\Windows\System32\net.exe START "<Service-Name>"

    where <Service-Name> is the name of your service. Note that the quotes around the name are required if it contains a space.

  5. In the Every section, specify when the service should be started.

  6. Check the Only option and set the value to 1 (because we only need to start the service once).

  7. Finally, save your settings.

For example, if you want to start the Print Spooler service (named “Spooler”) 30 seconds after Google Drive starts, your Automate tab should look like this:

Use AlwaysUp to automate NET START

3. Change your service to start manually

Is Windows starting your service when the computer boots? If so, you may want to change that because with step 2 in place, AlwaysUp will start the service when it’s needed.

To prevent Windows from starting your service at boot:

  1. Start the Services application (run “services.msc” to launch it)

  2. Scroll the list to find your service.

  3. Double-click the entry to bring up the service’s properties.

  4. In the Startup type field, select Manual. It should look like this:

    Set the service's startup type to Manual
  5. Save your changes.

And that’s it!

Next time your computer boots:

  1. Windows will automatically start AlwaysUp

  2. AlwaysUp will start Google Drive

  3. And after a few seconds/minutes (whichever you specified), AlwaysUp will start your service.

All the best.

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

Q&A: Can AlwaysUp Auto-Start and Recycle my Leaky Program Once per Day?

Can AlwaysUp Restart my Leaky Program Once per Day?
  I am trying out AlwaysUp and so far I like the way it works.

I’m running this program as a service is for only two reasons: to start when the computer boots and (the most important one) to be able to schedule it to stop and restart once a day at the time of my choosing. I need to do this or the program will run out of memory over time and cause all kinds of trouble when I am away from my computer for more than 24 hours.

Is AlwaysUp capable of doing this?

— Ron

Hi Ron.

Yes, AlwaysUp can do both of the things you would like to do.

AlwaysUp will start your program at boot

The first task — starting your program when your computer boots — was the main reason for building AlwaysUp. Rest assured that AlwaysUp will do everything in its power to ensure that your program starts quickly after a power cycle or any other event that causes your PC to reboot.

Note that AlwaysUp provides a couple of options for when to launch your application:

  1. Automatically, when the computer boots: Starts your application as quickly as possible, usually seconds after boot

  2. Automatically, but shortly after the computer boots: Runs your application about 2 minutes after boot, after critical operating system services (e.g. networking, security) have started.

Make your selection on the General tab when configuring your application:

Options to start your application as a service

AlwaysUp will restart/recycle your program daily

The second task — recycling your application daily to keep it “fresh” — is easily done too.

In fact, recycling an application is one of AlwaysUp’s most popular features! It comes in handy for programs that get sicker over time, like yours does.

To illustrate, here are the steps to stop and restart your application at 3 AM every morning:

  1. Edit your application in AlwaysUp.

  2. Switch to the Monitor tab. The settings on this screen specify when AlwaysUp should intervene and stop your application.

  3. Since we want to stop at a specific time, check the Every box, choose Day from the drop-down and enter 3:00 AM in the time field:

    Stop your application daily at 3 AM
  4. Switch to the Restart tab.

  5. Ensure that the When your application stops, restart it box at the top is checked. If not, AlwaysUp won’t restart your application after it stops it at 3 AM.

    By default, AlwaysUp will restart your program immediately but you can specify another schedule if you like:

    Restart your application after it stops
  6. Save your changes.

Putting it all together…

With the recommendations above in place, when your computer boots:

  1. Windows will start AlwaysUp

  2. AlwaysUp will start your application

  3. AlwaysUp will watch your application and quickly restart it if it stops for any reason

And whenever 3 AM rolls around, AlwaysUp will:

  1. Stop your application

  2. Restart your application — so fresh, so clean.

That addresses all your concerns, right? Please let us know if not.

Best of luck with your program!

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

ChatGPT Knows Windows Services

ChatGPT Knows Windows Services

Like many folks this holiday season, we’ve been playing with OpenAI’s ChatGPT — the surprisingly conversational AI engine taking the world by storm.

We were particularly interested in what ChatGPT thinks of Windows Services, which are highly technical and often difficult to explain. Our company has been wrestling with them for years! 🙂

The rest of this article focuses on four questions we asked ChatGPT. For each question, we present the AI’s response and review the quality of the answer.

What is a Windows Service?

We figured we’d start with the basics. Here’s how ChatGPT defined a Windows Service:

  A Windows service is a program that is designed to run in the background and perform tasks without user interaction. Services are typically used to perform tasks that need to be run continuously, even when no user is logged in to the system.

Services are managed through the Windows Services Control Manager, which allows you to start, stop, and configure services on your system. You can access the Services Control Manager by going to the “Services” snap-in for the Microsoft Management Console (MMC).

Some examples of common Windows services include:

  • The Print Spooler, which manages print jobs and controls access to printers.

  • The Task Scheduler, which is used to schedule tasks to run at a specific time or when certain conditions are met.

  • The Windows Event Log, which records system events and allows you to view and manage event logs.

  • The Windows Update service, which checks for and installs updates for the operating system and installed applications.

Overall, Windows services are a useful tool for running background tasks and automating various system tasks and processes. They can help to improve the performance and reliability of your system, and can be configured to start automatically when the system starts up.

That’s a great answer. It’s accurate, provides examples and avoids the use of technical jargon. Impressive!

But many sites are great with definitions, which may be easier to source and regurgitate. Let’s increase the difficulty.

Why would I run an application as a Windows Service?

Next, we wanted to see how the AI tackles a real-world question that we are often presented with. Indeed, folks browsing our products often wonder why they should convert their application to run as a service.

ChatGPT posited:

  There are several reasons why you might run an application as a Windows Service:

  1. To perform tasks in the background: By running as a Windows Service, an application can perform tasks in the background, even when no user is logged on to the system. This can be useful for tasks that need to run continuously or on a schedule, such as data backup, virus scanning, or monitoring system performance.

  2. To provide services to other programs: By running as a Windows Service, an application can provide services to other programs, such as database access, web server functionality, or messaging capabilities.

  3. To improve system performance: By running in the background as a Windows Service, an application can help improve system performance by offloading tasks from the main user interface and allowing other programs to run more efficiently.

  4. To enhance security: By running as a Windows Service with a lower level of privileges than the main user interface, an application can help enhance security by preventing unauthorized access to system resources.

  5. To reduce maintenance: Because Windows Services run in the background and do not require user intervention, they can help reduce maintenance by running automatically and requiring less attention than other types of programs.

In summary, running an application as a Windows Service can be useful for performing tasks in the background, providing services to other programs, improving system performance, enhancing security, and reducing maintenance.

Another excellent answer!

We’ve been advising customers of the benefits of Windows Services for years and that response aligns with our thinking.

Let’s keep going. How does ChatGPT respond to a plea for help?

My Windows Service is stuck in the “Stopping” state. How do I fix it?

This is an issue faced by many of our customers (it’s covered in the Windows Services FAQ).

ChatGPT suggested a few practical remedies:

  If your Windows Service is stuck in the “Stopping” state and is not stopping or shutting down as expected, there are a few steps you can try to fix the issue:

  • Restart the service: Sometimes, simply restarting the service can resolve the issue. To restart the service, go to the Services control panel, right-click on the service, and select “Restart” from the menu.

  • End the process manually: If restarting the service does not resolve the issue, you can try ending the process manually. To do this, go to the Task Manager and find the process associated with the service. Right-click on the process and select “End task” to stop it.

  • Check the service logs: The service logs may provide information about why the service is not stopping as expected. To view the service logs, go to the Services control panel, right-click on the service, and select “Properties”. Then, go to the “Log On” tab and click the “Event Viewer” button to view the service logs.

  • Check for dependency issues: If the service has dependencies on other services, and those dependencies are not stopping as expected, this can cause the service to get stuck in the “Stopping” state. To check for dependency issues, go to the Services control panel, right-click on the service, and select “Properties”. Then, go to the “Dependencies” tab to see a list of services that the service depends on. If one of those services is not stopping as expected, this could be the cause of the issue.

  • Check for errors or issues in the service code: If none of the above steps resolve the issue, there may be an error or issue in the service code that is preventing it from stopping as expected. In this case, you may need to review the service code and try to identify and fix any errors or issues.

Another solid response. ChatGPT is 3 for 3!

But can the AI tell us something we don’t already know?

Tell me something obscure but useful about Windows Services

ChatGPT responded:

  One obscure but useful feature of Windows Services is the ability to specify a “dependency” on another service. When you specify a service as a dependency for another service, the dependent service will automatically start whenever the required service starts, and will automatically stop whenever the required service stops.

For example, suppose you have a service that performs data backups for your system. You might want this service to run every night at midnight, after all other user activity on the system has ceased. In this case, you could specify the “Workstation” service as a dependency for your backup service. The Workstation service is a built-in Windows service that manages network connections and file and printer sharing on the system. By specifying the Workstation service as a dependency, you can ensure that your backup service will only start when all network activity has stopped and all files are closed, which can help ensure that the backup process is successful.

This feature can be useful for setting up complex service dependencies and ensuring that services start and stop in the correct order. You can specify dependencies for a service using the “Dependencies” tab in the service’s properties in the Services control panel.

Interesting. This is the first time we’ve seen ChatGPT trip up.

While the ability to set a dependency is an advanced/obscure feature, there are a trio of problems with the answer:

  1. When you specify a service as a dependency for another service, it’s true that the dependent service will automatically start whenever the required service starts. However, despite what ChatGPT says, the dependent service will not stop when you stop the required service. The dependent service may keep running.

  2. Next, the example is inaccurate. Setting the backup service to depend on the Workstation service will not “ensure that your backup service will only start when all network activity has stopped and all files are closed”. That’s because the Workstation service doesn’t start or stop based on network activity.

  3. Finally, you cannot “specify dependencies for a service using the Dependencies tab in the service’s properties in the Services control panel”. In reality, that view is read-only and you can’t update dependencies there:

    Workstation service dependencies

But even more worrisome, the faulty answer has the air of authority. It will certainly seem plausible to folks unfamiliar with service dependencies — who will not be able to spot the inaccuracies!

Let’s try one more.

How do I find out who stopped my Windows Service?

This time, ChatGPT’s advice was on point:

  To find out who stopped your Windows Service, you can check the service logs in the Event Viewer. The service logs can provide information about when the service was stopped and who stopped it.

To view the service logs in the Event Viewer:

  1. Press the Windows key + R to open the Run dialog, then type “eventvwr.msc” and press Enter. This will open the Event Viewer.

  2. In the Event Viewer, expand the “Windows Logs” tree on the left and select the “System” log.

  3. In the System log, look for entries related to your service. These will typically be listed under the “Service Control Manager” source.

  4. Look for entries with the “Information” level that indicate that the service was stopped. These entries should include information about the time the service was stopped and the account that stopped it.

Keep in mind that the service logs may only contain information about the most recent service stops. If the service was stopped a long time ago, the log entries may have been purged.

You can also check the service’s properties in the Services control panel to see if the service is set to automatically start when the system starts up. If the service is set to start automatically, this could indicate that the service was stopped intentionally by an administrator or another service.

Conclusion: ChatGPT does a good job of answering questions involving Windows Services

Despite providing misleading advice in one situation, it seems that ChatGPT can be a credible source of information about Windows Services.

Indeed, in all our tests, ChatGPT’s provided answers that were relevant, free of techno-babble and full of actionable advice.

What’s your experience with ChatGPT?

Please leave a comment to let us know!

Posted in Windows Services | Tagged , , | 2 Comments