Is it possible to run a client application as a service? Not every console application will be able to start as a service, and programs with graphical interface In principle, they do not know how to work this way. But it is still possible to run the application as a service, and a program with an original name will help us with this Non-Sucking Service Manager.

NSSM is a free software With open source and supports everything OS Microsoft, starting with Windows 2000 and ending with . NSSM does not require installation, just download and unpack it. The distribution includes versions for 32- and 64-bit operating systems. You can get the program from the website nssm.cc, at this moment The latest stable version is 2.21.1, which is what I will use.

To demonstrate the capabilities of NSSM, let's try to run Notepad as a service on .

Creating a Service

To create a service named notepad launch the command console, go to the folder with the unpacked NSSM (for 64-bit Windows) and enter the command nssm install notepad, which opens a window graphical installer NSSM. To create a service, just specify the path to the executable file in the Path field and click the "Install service" button. Additionally, in the Options field you can specify the keys required to start the service.

You can also specify some additional parameters when creating a new service.

The "Shutdown" tab lists the shutdown methods and timeouts used when the application shuts down normally or crashes. When NSSM receives a stop command (e.g. when an application exits), it attempts to stop controlled application in a normal way. If the application does not respond, then NSSM can forcefully terminate all processes and subprocesses of this application.

There are four steps to shutting down the application, and by default they will be used in this order:

In the first stage, NSSM tries to generate and send an event Ctrl+C. This method works well for console applications or scripts, but is not applicable for graphical applications;
NSSM then detects all windows created by the application and sends them a WM_CLOSE message, causing the application to exit;
The third step is that NSSM calculates all threads created by the application and sends them a WM_QUIT message, which will be received if the application has a thread message queue;
As a last resort, NSSM can call the TerminateProcess() method, forcing the application to terminate.

It is possible to disable some or even all methods, but different methods work for different applications and it is recommended to leave everything as is to ensure the application shuts down correctly.

By default, when a service crashes, NSSM tries to restart it. On the "Exit actions" tab, you can change the automatic action when the application terminates abnormally, as well as set a delay before the application automatically restarts.

On the "Input/Output (I/O)" tab, you can set the redirection of application input/output to a specified file.

On the "Environment" tab, you can set new environment variables, or override existing ones.

You can also not use the graphical shell and immediately create a service in the console with the following command:

nssm install notepad ″C:\Windows\system32\notepad.exe″

Service management

After creating the service using NSSM, go to the Services snap-in and find the notepad service. As you can see, in appearance it is no different from other services; we can also start it, stop it, or change the launch mode. However, note that nssm.exe is listed as the executable file.

And if we go to Task Manager, we will see the following picture: NSSM is running as the main (parent) process, the notepad service is running as its child process, and the Notepad application is already running in this child process.

Removing a service

To remove a service, enter the nssm remove notepad command and confirm its removal. And by entering the command nssm remove notepad confirm, you can do without confirmation.

Start a service interactively

Main difference custom application from a service is that after launching the application may require additional actions from the user to continue working - for example, pressing a button or entering a command. To do this, you need to gain access to it, which, as it turns out, is not so easy to do.

In order to start a service in interactive mode, you need to open its properties in the Services snap-in and on the “Login” tab, check the “Allow interaction with the desktop” checkbox.

And then the miracles begin. For a service running in interactive mode, the system opens a separate isolated session (session 0). This session can only be accessed by using the Interactive Services Detection Service (ui0detect), which monitors the startup of interactive services on the computer and issues an alert. In Windows 7\Server 2008 this service is active by default, but in Windows 8\Server 2012 it is disabled and does not appear in graphics equipment Services (at least I didn’t find it there). Moreover, if you do find this mysterious service and try to start it, you will receive an error message.

But the fact is that to run it, you must allow interactive services to run on your computer. Therefore, open the registry editor, find in the HKLM\System\CurrentControlSet\Control\Windows section a DWORD type parameter named NoInteractiveServices and set its value to 0 .

Then open the PowerShell console and start the discovery service with the command:

Start-Service -Name ui0detect

After making sure that the detection service is running, we restart the notepad service, and we get this window. Select "View message"

and we find ourselves in the null session in which our application runs. Then we perform the necessary actions with it and return back.

This is it interesting solution to run applications as Windows services. Not the most beautiful, but quite consistent with its name

Last updated: 10/31/2015

One of the most important components of the Windows OS is services. In fact, these are separate applications that do not have a graphical interface and that perform various tasks in background. Services can be started when the operating system starts, or at any other time the user is working. A common example of services are various web servers that listen in the background to a specific port for connections, and if there are connections, they interact with them. These may also be various auxiliary update services for others installed programs, which contact the server to find out if there is a new version applications. In general, we can open the services panel and see for ourselves all installed and running services:

Let's look at how to create your own services in C#. As the task to be implemented, we will choose to monitor changes in a specific folder in the file system. Now let's create a service to execute it.

First, let's create a new project that will have the type Windows Service. Let's call the project FileWatcherService:

After that Visual Studio generates a project that has everything needed. While we don't necessarily need to choose this type of project, we could create a class library project and then define all the necessary classes in it.

So the new project looks like this:

There is also a file Program.cs and there is the actual service node Service1.cs.

The service represents a normal application, but it does not start on its own. All calls and access to it go through the service control manager (Service Control Manager or SCM). When a service starts automatically at system startup or manually, SCM calls the Main method in the Program class:

Static class Program ( static void Main() ( ServiceBase ServicesToRun; ServicesToRun = new ServiceBase ( new Service1() ); ServiceBase.Run(ServicesToRun); ) )

The Main method is defined by default to run multiple services at once, which are defined in the ServicesToRun array. However, by default the project contains only one service, Service1. The launch itself is carried out using the Run method: ServiceBase.Run(ServicesToRun) .

The service being started is represented by the Service1.cs node. However, this is not actually a simple code file. If we open this node, we will see the service designer file Service1.Designer.cs and the Service1 class.

The Service1 class actually represents the service. By default it has the following code:

Using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Diagnostics; using System.Linq; using System.ServiceProcess; using System.Text; using System.Threading.Tasks; namespace FileWatcherService ( public partial class Service1: ServiceBase ( public Service1() ( InitializeComponent(); ) protected override void OnStart(string args) ( ) protected override void OnStop() ( ) ) )

The service class must inherit from the ServiceBase base class. This class defines a number of methods, the most important of which are the OnStart() method, which starts the actions performed by the service, and the OnStop() method, which stops the service.

After SCM calls the Main method and registers the service, it is directly called by running the OnStart method.

When in the services console or through command line we send a command to stop the service, then SCM calls the OnStop method to stop it.

In addition to these two methods in the service class, you can override several more methods of the ServiceBase base class:

    OnPause: Called when the service is paused

    OnContinue: Called when a service resumes after it has been suspended

    OnShutdown: Called when Windows shuts down

    OnPowerEvent: Called when the power mode changes

    OnCustomCommand: Called when a service receives a custom command from the Service Control Manager (SCM)

In the constructor of the Service1 class, the InitializeComponent() method is called, which is defined in the designer file Service1.Designer.cs:

Namespace FileWatcherService ( partial class Service1 ( private System.ComponentModel.IContainer components = null; protected override void Dispose(bool disposing) ( if (disposing && (components != null)) ( components.Dispose(); ) base.Dispose(disposing ); ) private void InitializeComponent() ( components = new System.ComponentModel.Container(); this.ServiceName = "Service1"; ) ) )

The only thing that needs to be noted in it is setting the name of the service (ServiceName property):

This.ServiceName = "Service1";

This is the name that will be displayed in the services console after installing this service. We can change it, or we can leave it as it is.

Now let's change the service code as follows:

Using System; using System.ServiceProcess; using System.IO; using System.Threading; namespace FileWatcherService ( public partial class Service1: ServiceBase ( Logger logger; public Service1() ( InitializeComponent(); this.CanStop = true; this.CanPauseAndContinue = true; this.AutoLog = true; ) protected override void OnStart(string args) ( logger = new Logger(); Thread loggerThread = new Thread(new ThreadStart(logger.Start)); loggerThread.Start(); ) protected override void OnStop() ( logger.Stop(); Thread.Sleep(1000); ) ) class Logger ( FileSystemWatcher watcher; object obj = new object(); bool enabled = true; public Logger() ( watcher = new FileSystemWatcher("D:\\Temp"); watcher.Deleted += Watcher_Deleted; watcher.Created + = Watcher_Created; watcher.Changed += Watcher_Changed; watcher.Renamed += Watcher_Renamed; ) public void Start() ( watcher.EnableRaisingEvents = true; while(enabled) ( Thread.Sleep(1000); ) ) public void Stop() ( watcher.EnableRaisingEvents = false; enabled = false; ) // renaming files private void Watcher_Renamed(object sender, RenamedEventArgs e) ( string fileEvent = "renamed to " + e.FullPath; string filePath = e.OldFullPath; RecordEntry(fileEvent, filePath); ) // changing files private void Watcher_Changed(object sender, FileSystemEventArgs e) ( string fileEvent = "changed"; string filePath = e.FullPath; RecordEntry(fileEvent, filePath); ) // creating files private void Watcher_Created(object sender, FileSystemEventArgs e) ( string fileEvent = "created"; string filePath = e.FullPath; RecordEntry(fileEvent, filePath); ) // deleting files private void Watcher_Deleted(object sender, FileSystemEventArgs e) ( string fileEvent = "deleted"; string filePath = e.FullPath; RecordEntry(fileEvent, filePath); ) private void RecordEntry(string fileEvent, string filePath) ( lock (obj) ( using (StreamWriter writer = new StreamWriter("D:\\templog.txt", true)) ( writer.WriteLine(String.Format("(0) file (1) was (2)", DateTime.Now.ToString("dd/MM/yyyy hh:mm:ss"), filePath, fileEvent)); writer. Flush(); ) ) ) ) )

The key class that encapsulates all the functionality is the Logger class. Using the FileSystemWatcher object, it will monitor changes in the folder D://Temp. The Start() method specifies that we will watch for changes through the FileSystemWatcher object. And all the work will continue as long as the enabled boolean variable is true . And the Stop() method will allow the class to terminate.

FileSystemWatcher events allow you to monitor all changes to a watched folder. This will record changes to the templog.txt file. To avoid resource race for the templog.txt file, into which changes are recorded, the recording procedure is blocked by the lock(obj) stub.

As a result, after creating, changing, renaming and deleting, the log file will contain something like:

07/30/2015 12:15:40 file D:\Temp\New text document.txt was created 07/30/2015 12:15:46 file D:\Temp\New text document.txt was renamed to D:\Temp\hello. txt 07/30/2015 12:15:55 file D:\Temp\hello.txt was modified 07/30/2015 12:15:55 file D:\Temp\hello.txt was modified 07/30/2015 12:16:01 file D: \Temp\hello.txt has been deleted

In the Service1 service class itself, a number of options are set in the constructor:

This.CanStop = true; // the service can be stopped this.CanPauseAndContinue = true; // the service can be paused and then continued this.AutoLog = true; // the service can write to the log

In the OnStart() method, a new thread is called to start the Logger object:

Protected override void OnStart(string args) ( logger = new Logger(); Thread loggerThread = new Thread(new ThreadStart(logger.Start)); loggerThread.Start(); )

The new thread is needed because the current thread only processes SCM commands and must return from the OnStart method as quickly as possible.

When a command is received from the SCM to stop the service, the OnStop method is triggered, which calls the logger.Stop() method. The additional delay will allow the logger thread to stop:

Protected override void OnStop() ( logger.Stop(); Thread.Sleep(1000); )

However, the service class itself is not enough. We also need to create a service installer.

From point of view software compatibility. So it's only natural that we return to discussing services in the context of Windows 7. But this time we'll talk about some of the benefits of optimizing the services available in Windows 7. This article is about new opportunity Windows 7 - Trigger Start Services. But before we look at the API, let's take a look at the big picture of the services.

What are services?

A service is an internal mechanism built into the Windows operating system. You can think of services as special applications that run regardless of the current user context. Services differ from regular applications in that they can be configured to operate from the moment the system is turned on (booted) until shutdown, without requiring user presence. That is, services can run even if the user is not logged in.

We prefer to think of services as running tasks that run in the background and do not affect user operations. Services in Windows are responsible for all types of background activity, from Remote Procedure Call (RPC), Printer Spooler and all the way to Network Location Awareness.

Over the years, Windows has grown and so have the number of services. Let's be honest, background services in Windows are a bit of a pain - the operating system comes with a lot of services out of the box. In addition, independent software developers (ISVs) and their applications are adding even more services. For example, software update services. However, some services are critical and are required during the boot process, while others are needed later when a specific user logs in, and others do not need to start at all until they are called. Despite this, when you look at the list of currently running services, you see many objects that do not need to work 24x7.

What's wrong with services that operate 24 hours a day, 7 days a week?

There are several problems associated with 24x7 services. Firstly, why should something be running (even in the background) if it is not needed? Any running process (including services) uses up precious memory and CPU resources that could be used for other applications and services. If you count all the services running in certain moment, then they add up to a significant amount of memory, handles, threads, and CPU usage. All of these "wasted" resources reduce the overall performance of the computer, reduce its responsiveness, and make the computer appear sluggish and slow. In addition, since many services are configured to automatic start(begin to work when the system starts), they affect the boot time of the computer.

Secondly, these wasted resources have a direct impact on energy consumption. The greater the load on the CPU, the more power the computer consumes. This can be critical on laptops and can reduce battery life by several hours.

Third, running unproductive software continuously can lead to memory leaks and overall system instability. This leads to the failure of applications and, ultimately, the computer.

Finally, if the service operates 24x7, and if it is a well-known service (which every popular application may have - for example, PDF Reader), this creates a larger surface for attack. An attacker can take advantage of information that a certain popular app installs a service that runs 24x7 and tries to hack it to gain access to the computer.

With all that said, you might be wondering why so many developers set up their services to run all the time if they have another option. Even before Windows 7, there were several options available to start services:

  • Disabled completely disables a service and prevents it and dependent services from starting - meaning the user must enable the service manually from Control Panel or Command Prompt
  • Manual starts a service as needed (due to dependencies of other services) or when the service is called from the application using the appropriate APIs, as will be shown below
  • Automatic starts a service upon login
  • Automatic Delayed– more new type launch, appeared in Windows Vista, with the help of which the service starts after the boot has completed and the initial operations have been completed, which speeds up the system startup.

Unfortunately, many ISVs (including Microsoft itself) continue to set their services to Automated or Automatic Delayed because it seems like the simplest solution for everyone. The service simply runs 24x7 and is always available, eliminating any need to check dependencies or whether the service is running.

Many examples can be given existing services, which can consume much less resources and become safer without working 24x7. For example, think about an update service that checks for new updates to an application. If the computer is not connected to the network and does not have an IP address, why should it work? It can't do anything, so why leave a program running that doesn't do anything? Think about the policy management service that is used when changing group policies or when connecting a computer to or disconnecting from a domain, but now that the computer is connected to my home network, the service, again, is wasted.

The emergence of trigger-based services

The solution to the above problems is to move the service out of the "always on state" to other types of background activity, such as scheduled tasks or triggered services. This article is about Windows 7 Trigger Start Services. A lot of interesting things can be said about Windows 7 Scheduled Tasks, which will be done in subsequent articles.

Hello dear readers, today I would like to talk about:

1. ABOUT Windows services, what it is, what it is needed for and which ones are responsible for what.

2.And how can you increase the speed of your computer?

So what are these Windows services?

Services- applications that are automatically or manually launched by the system when Windows startup and various tasks performed regardless of the user’s status.

Open list of services can be done in several ways:

1. While holding windows button press R, a window will open, enter services.msc there

2. Start > Control Panel > Administrative Tools > Services

3. Start > right click mouse over my computer > Manage > Services and Applications > Services

As you can see, there are quite a lot of them in Windows and by downloading, you can familiarize yourself what services exist and what each of them is responsible for.

Since services are applications, they operate and use some of the computer's resources. you can improve its performance. Let's see what can be disabled.

What services can be disabled in Windows 7, 8

I did not make a list of those services that can be disabled, because... many services are individual. I just tried to describe each service and in what situations they can be disabled. If you need to turn something off mindlessly, then just use .

* BranchCache The service caches network content. If you don't use home network, then you can turn it off altogether.

* DHCP client - If you use the Internet, do not touch it under any circumstances. It is this service that assigns you an IP address.

* DNS client It is also a necessary service for using the Internet. Works with your DNS (serves in the right directions).

* KtmRm for distributed transaction coordinator - system transaction function. We leave it the same way.

* Microsoft .NET Framework - We leave all such services as is. They serve for the normal operation of most applications.

* Parental Controls - Service for parental controls. If you don't use it, you can turn it off.

* Plug-and-Play serves for automatic recognition changes in the system. For example, when you connect a flash drive, this service wakes up... So we leave it as it is.

* Quality Windows Audio Video Experience - transmission of audio and video over the network in real time. It is not needed only if there is no network (or Internet), in other cases we leave it.

* Remote Desktop Configuration - For remote desktop. If you don't use remote connections, turn off.

* Superfetch Useful feature, works with cache. Speeds up Windows operation, so we leave it.

* Windows Audio - Controls sound. If you don't need the sound, turn off the sound. In other cases we leave it.

* Windows CardSpace - unnecessary and unsafe service. That's why we turn it off.

* Windows Driver Foundation - User-mode Driver Framework - For normal operation of the drivers, do not touch. Let it remain as it is.

* Windows Search - Indexing files for search. If you don’t use it and have time to wait until the file is found, then disable it. Be sure to disable it on the ssd!

* WMI Performance Adapter - needed for services that require wmi, install manually. If any applications need them, they will launch them themselves)

* WWAN auto-configuration - service to use mobile internet. If you use usb modem, SIM card in the laptop, then do not disconnect it.

* Offline files - helps to work autonomously with inaccessible files, which loaded before. We set it manually.

* Network Access Protection Agent - We set it manually, because... if necessary, the service will start if some program requests the necessary information.

* AIPsec policy gent - Needed if you have a network and the Internet.

* Adaptive Brightness Control - Leave it if there is a light sensor.

* Windows Backup - If you don't use it, turn it off. But it’s better to read about archiving in Windows, you never know, you’ll use it.

* Windows Biometric Service - needed only when using biometric devices. In other cases we disable it.

* Windows Firewall - To be honest, I always turn it off, because... I have nothing to steal) And if they encrypt the data, I will restore it) But I advise you to get, for example, Kaspersky Internet Security, which has both an antivirus and a firewall. And turn this one off, because... it sometimes blocks things that are not needed) In general, it monitors the security of your computer and closes ports so that thieves cannot get into your computer)

* Computer browser There is no need for a home network. Manually.

* Web client - It's boring if you don't have internet. Used to work with files on the Internet. We leave it.

* Virtual disk - Service for working with storage devices. We set it manually.

* IP Ancillary Service - Works with protocol version 6. I always disable it itself, so the service can be disabled altogether.

* Secondary login - Set it manually, because... some games or programs will enable it if necessary.

* Grouping of network participants - Needed for home group. Install manually, you never know...

* Disk Defragmenter - In principle, it does not interfere. You can leave it or turn it off. If you turn it off, I recommend doing it once a month. And for ssd drives, turn it off altogether!

* Dispatcher automatic connections remote access - We set it manually. Needed for remote connections.

* Print Manager - Needed if you have something to print from. In other cases we disable it.

* Remote Access Connection Manager - manually. Once I disconnected it completely and could not create a connection. So it's better to do it manually.

* Desktop Window Manager Session Manager − If you don’t use transparency from Aero, you can turn it off, it will give a big boost.

* Network Member Identity Manager − It's better to set it manually.

* Credential Manager - Better by hand. Stores your data, such as logins and passwords.

* Security Account Manager - It's better to leave it as is. If you disable this service, then all changes to the local security policy will be lost.

* Access to HID devices - Access to shortcut keys. Disable it, if some combinations stop working, then put it back.

* Windows Event Log - records all events. A useful tool for the experienced user. It is impossible to disable.

* Performance Logs and Alerts - system service, leave it as is.

* Software Protection - Also a system service, leave it as is.

* Windows Defender - Protection against spyware and malware. Install a normal antivirus and disable this service.

* CNG Key Isolation - Manually.

* Tools Windows management System service, without it, some applications may not work correctly, so it’s better to leave it.

* Application Compatibility Information - A useful thing, it helps launch applications that refuse to run on your OS. We set it manually.

* Group Policy Client - We leave it. Responsible for security policy settings.

* Changed Link Tracking Client - Tracking ntfs files is not necessary. Turn it off.

* Distributed Transaction Coordinator - We set it manually.

* Cache Windows fonts Presentation Foundation - We set it manually. Applications will launch it if necessary.

* SNMP Trap - Some programs will collect information about you. So turn it off.

* Remote Procedure Call (RPC) Locator - Manually, if necessary, applications will launch it.

* Routing and remote access - Need not. Turn it off.

* IPsec Key Modules for Internet Key Exchange and Authenticated IP - Not necessary, but better to do it manually.

* DCOM server process launcher module - System service, leave it as is.

* NetBIOS support module over TCP/IP - If there are no other computers on the network, then manually.

* Immediate Windows connections— setup recorder — Manually.

* SSDP Discovery - Leave it as is. Required for new devices.

* Interactive Service Discovery − Manually.

* Internet Connection Sharing (ICS) - Not needed if you do not share your Internet over network connections.

* Shell Hardware Definition − necessary for the autorun dialog box of a disk or flash drive. Whatever suits you, most people need it. I left.

* Basic TPM services − Only needed to use TMP and/or BitLocker chips.

* Port forwarder user mode Remote Desktop Services - If you don't use remote connections, then you don't need it. It's better to install it manually.

*PIP bus enumerator PnP-X — It's better to install it manually.

* Nutrition - Doesn't turn off. We leave it.

* Task Scheduler - It is advisable to leave it as is, because... Now many programs use it.

* Media Class Scheduler − We leave it to those for whom sound is important.

* Support for the "Problem and Resolution Reports" control panel item - Manually.

* Smart Card Removal Policy - For smart card users, it is better to do it manually.

* HomeGroup Provider - To use home groups. Better by hand.

* Wired Auto-Tuning - Manually.

* Software Shadow Copy Provider (Microsoft) - Manually.

* Homegroup Listener - Manually.

* PNRP protocol - We also leave it manually. Some applications may use the service.

* Publishing Feature Discovery Resources − Needed if you want to show your files to other computers over the network. If you don't want to, then manually or disable it.

* Work station - It's better to leave it, because... Some applications use this service.

* Certificate Distribution − Better by hand.

* Extensible Authentication Protocol (EAP) - Manually.

* Windows Event Collector - Manually.

* Application Details - Manually.

* Server - If the computer is not used as a server or does not share access to files and printers, then turn it off.

* Thread Ordering Server - Disable if there is no home group.

* Network Login - Manually.

* Network connections - Leave it as is. If there is no network or Internet, you can turn it off.

* COM+ Event System - set manually. Applications that depend on this service will launch it themselves if necessary.

* System application COM+ - Also manually.

* SSTP Service - We leave it as is, the service is needed if there is Internet on the computer.

* WinHTTP Web Proxy Automatic Discovery Service - If you need internet, then leave it as is.

* WLAN AutoConfig Service - service for wireless networks. Accordingly, if they are not there, it is not needed.

* Basic Filtering Service - on the one hand, it is not needed (if security is not needed), but on the other hand, some programs may produce errors. So we leave it.

* Tablet PC Input Service - If the screen is not touch-sensitive, then it is not needed.

* Windows Time Service - needed to synchronize time with the Internet.

* Download service Windows images(WIA)— The service is only needed if there is a scanner. She is responsible for receiving images from scanners and cameras.

* Microsoft iSCSI Initiator Service - We install it manually, if programs need it, they will launch it themselves.

* Network Saving Interface Service - Needed for normal network operation.

* Windows Font Cache Service - serves to improve performance, caches fonts and does not waste time loading.

* WITHMedia Center set-top box service - If you don't use any attachments, you don't need it.

* Block Level Archiving Engine Service - We set it manually. If archiving or restoration is needed, the service will start on its own.

* Service public access to Net.Tcp ports - Off by default. Only needed if you need the Net.Tcp protocol.

* General service network resources Windows Player Media - Manually. If you need it, it will turn on.

* Portable Device Enumerator Service - Used to synchronize music, videos, etc. with removable media. I would install it manually. This is not always necessary.

* Scheduler service Windows Media Center— Needed if you only watch programs in Windows Media Player.

* Bluetooth Support - Needed if you have Bluetooth.

* Diagnostic Policy Service - Needed to diagnose problems... To be honest, it rarely helps. Therefore, you can experiment by turning it off. If necessary, turn it on.

* Program Compatibility Assistant Service - The service is needed to run programs that are incompatible with your OS. If there are none, install them manually.

* User Profile Service - Better to leave it. It works with computer user profiles.

* PNRP Computer Name Publishing Service - Needed for home groups.

* Windows Error Logging Service - Logs errors. It's better to install it manually.

* Windows Media Center Receiver Service - to watch TV and radio programs in the player.

* Connected Network Information Service - It is better to leave it as is for normal network operation.

* Network List Service - It's better to leave it that way.

* SPP Notification Service - For licensing. Leave by hand.

* System Event Notification Service - If you're not going to watch Windows messages, then you don't need it.

* Service remote control Windows (WS-Management) - Place it manually.

* BitLocker Drive Encryption Service - Encrypts disks. If you don't use it, it's better to turn it off.

* Application Layer Gateway Service − The service is needed only to work with the firewall. Manually.

* Cryptography Services - To install new programs, it is better to leave it as is.

* Remote Desktop Services - If you do not use remote desktops, then disable it.

* Smart card - If you don't use them, then you don't need it.

* RPC Endpoint Mapper - The service is needed for incoming traffic. Nothing can be done about it. That's why we leave it.

* Finite Builder Windows points Audio - If you need sound, leave it.

* Telephony - Leave by hand. It will start if needed.

* Themes - They eat up a lot of memory resources. If you don't need it, turn it off.

* Volume Shadow Copy - Creates recovery points, backing up in the background. Place it manually. It will start if necessary.

* Link layer topologist - Also by hand. It will start if needed.

* Remote Procedure Call (RPC) - System service. Leave it as is.

* Remote registry - Allows remote users, manipulate your registry. Turn it off.

* Application Identity - Manually.

* Diagnostic system unit - Diagnosis of problems. Place it manually.

* Diagnostic Service Node - Also manually.

* Generic PNP Device Node - Place it manually. Not all devices are PnP.

* Application Management - Place it manually. The service allows you to configure policies for applications.

* Manage certificates and health key - Install it manually, if you need it, it will start on its own.

* ActiveX Installer - Also manually. You will need to install such an object, it will start on its own.

* Windows Installer - Installation of programs.msi. Manually.

* Windows Modules Installer - Installs and removes components and updates. Manually.

* Fax - Needed if you have a fax.

* Background Intelligent Transfer Service (BITS) - Leave it by hand. The service is useful.

* Discovery Provider Host - Leave it by hand. It will need to start.

* Color Windows system(WCS) - Manually. The devices will need it and they will launch it.

* Security Center - Keeps an eye on Windows security. She annoys me with her notifications. So whether to turn it off or not is up to you.

* Windows Update - On the one hand, a useful function. It closes holes in the system, updates drivers, but on the other hand, it actively uses the Internet, memory resources, and if you turn off the computer during the update, the OS may crash. So you also have to choose what is more important, security or performance.

* Encrypted file system(EFS)— For file security. It's better to leave it as is manually.

I tried to present the entire list of services. By disabling some, you will improve the performance of your computer. You can also decide at your own discretion which ones are needed and which ones are not. For example, if there is no Internet, then you can safely cut half of it; if there is no printer, then you can also turn off a lot. Thus, depending on your needs, you can significantly invigorate your old computer.

How to run an application as Windows services



Is it possible to run a client application as a service? In one of the articles, ways to create a Windows service regular means OS. However, not every console application can run as a service, and programs with a graphical interface, in principle, cannot work in this way. But it is still possible to run the application as a service, and a program with an original name will help us with this Non-Sucking Service Manager.

NSSM is free and open source software and supports all Microsoft operating systems from Windows 2000 to Windows 8. NSSM does not require installation, just download and unzip it. The distribution includes versions for 32- and 64-bit operating systems. You can get the program from the website nssm.cc, at the moment the latest stable version is 2.21.1, which I will use.
To demonstrate the capabilities of NSSM, let's try running Windows Notepad as a service on Windows 8.1.

Creating a Service

To create a service named notepad launch the command console, go to the folder with the unpacked NSSM (for 64-bit Windows) and enter the command

Code:

Nssm install notepad

which opens the NSSM graphical installer window. To create a service, just specify the path to the executable file in the Path field and click the “Install service” button. Additionally, in the Options field you can specify the keys required to start the service.

You can also specify some additional parameters when creating a new service.

The Shutdown tab lists the shutdown methods and timeouts used when the application shuts down normally or crashes. When NSSM receives a stop command (for example, when an application is shut down), it attempts to stop the controlled application in a normal manner. If the application does not respond, then NSSM can forcefully terminate all processes and subprocesses of this application.

There are four steps to shutting down the application, and by default they will be used in this order:

In the first step, NSSM tries to generate and send a Ctrl+C event. This method works well for console applications or scripts, but is not applicable for graphical applications;
NSSM then detects all windows created by the application and sends them a WM_CLOSE message, causing the application to exit;
The third step is that NSSM calculates all threads created by the application and sends them a WM_QUIT message, which will be received if the application has a thread message queue;
As a last resort, NSSM can call the TerminateProcess() method, forcing the application to terminate.

It is possible to disable some or even all methods, but different methods work for different applications and it is recommended to leave everything as is to ensure the application shuts down correctly.

By default, when a service crashes, NSSM tries to restart it. On the “Exit actions” tab, you can change the automatic action when the application terminates abnormally, as well as set a delay before the application automatically restarts.

On the “Input/Output (I/O)” tab, you can set the redirection of application input/output to a specified file.

On the “Environment” tab, you can set new environment variables for the service, or override existing ones.

You can also not use the graphical shell and immediately create a service in the console with the following command:

Code:

Nssm install notepad "C:\Windows\system32\notepad.exe"

Service management

After creating the service using NSSM, go to the Services snap-in and find the notepad service. As you can see, in appearance it is no different from other services; we can also start it, stop it, or change the launch mode. However, note that nssm.exe is listed as the executable file.

And if we go to Task Manager, we will see the following picture: NSSM is running as the main (parent) process, the notepad service is running as its child process, and the Notepad application is already running in this child process.