Anyways, processes are directly related to the app we are currently running on our Windows computer, they have a user interface to interact with, and are usually manually started.
So, when I launch Skitch, a process runs. More examples include Skype, MS Office apps, image editors, and so on. Services, on the other hand, are computer program that work in the background whether or not you have an app open in the foreground. That means they are not exactly made, or running, for the end users, but helps the programs perform their tasks. Services do not have a user interface. A service is usually started by the operating system itself. However, a user can start or restart it manually.
Services can also start when a condition is satisfied, like by an event. An example of an event would be starting the operating system. For example, event logging, error reporting, printing, device optimization, and sensor related services. Antivirus has a UI, but it can run in the foreground too. That is because a service is a process, but a process may or may not be a service. A process is an instance of an executable file.
A service, on the other hand, runs as an instance of the svchost. That is the Windows service host process. Notice how svchost is also an executable file and the service host is itself a process?
Again, a service can be a process, but a process may or may not be a service. The clock is always running on your computer, whether you have it open or not. It is also running when your computer is in sleep or hibernate mode. NET Framework do not support interaction with interactive stations, that is, the logged-on user. NET Framework also does not include classes that represent stations and desktops. If your Windows service must interact with other stations, you will need to access the unmanaged Windows API.
For more information, see the Windows SDK documentation. The interaction of the Windows service with the user or other stations must be carefully designed to include scenarios such as there being no logged on user, or the user having an unexpected set of desktop objects. In some cases, it may be more appropriate to write a Windows application that runs under the control of the user.
Windows service applications run in their own security context and are started before the user logs into the Windows computer on which they are installed.
You should plan carefully what user account to run the service within; a service running under the system account has more permissions and privileges than a user account. A service goes through several internal states in its lifetime. First, the service is installed onto the system on which it will run.
This process executes the installers for the service project and loads the service into the Services Control Manager for that computer. The Services Control Manager is the central utility provided by Windows to administer services. After the service has been loaded, it must be started.
Starting the service allows it to begin functioning. You can start a service from the Services Control Manager , from Server Explorer , or from code by calling the Start method.
The Start method passes processing to the application's OnStart method and processes any code you have defined there. A running service can exist in this state indefinitely until it is either stopped or paused or until the computer shuts down. A service can exist in one of three basic states: Running , Paused , or Stopped. These statuses indicate that a command has been issued, such as a command to pause a running service, but has not been carried out yet.
You can query the Status to determine what state a service is in, or use the WaitForStatus to carry out an action when any of these states occurs. You can pause, stop, or resume a service from the Services Control Manager , from Server Explorer , or by calling methods in code. Each of these actions can call an associated procedure in the service OnStop , OnPause , or OnContinue , in which you can define additional processing to be performed when the service changes state.
There are two types of services you can create in Visual Studio using the. NET Framework. Services that are the only service in a process are assigned the type Win32OwnProcess. Services that share a process with another service are assigned the type Win32ShareProcess.
Greg Hewgill Greg Hewgill k gold badges silver badges bronze badges. Technically correct but I don't think it answers the question very well. See Eric J's answer.
I definitely think this is a much more correct answer than the one chosen. The other one responds better to the question "What is a Windows service". It needs all the privileges of the logged-in user no more, no less Choose a service if: It may need to run when no one is logged in It doesn't generally need per-user data or privilege It solely communicates with the network It needs to expose new "securable" objects.
It needs special permissions that may not be available to the logged-in user. David Gladfelter David Gladfelter 4, 2 2 gold badges 23 23 silver badges 25 25 bronze badges. I intended the list to describe scenarios where services make sense, not circumscribing every use case for Windows services.
John Knoeller John Knoeller A service must meet some additional requirements beyond being a standard exe with no UI. Thats a service if I am not mistaken? One more thing worth mentioning is that a service does run as a specific user, much like an portable executable exe does. By default most services run as the local SYSTEM user, but applications may choose to create their own user in an effort to control resource access. Sign up or log in Sign up using Google. Sign up using Facebook.
Sign up using Email and Password. Post as a guest Name. Email Required, but never shown. The Overflow Blog. Does ES6 make JavaScript frameworks obsolete?
0コメント