[windows] How to create a service running a .exe file on Windows 2012 Server?

I have created .exe in .net and want to use as a service, run all time on my local machine. I am using windows server 2012. how to setup a service on my local computer.

**You can use windows shell script for create service with commands **

The sc create command performs the operations of the CreateService API function.

Here's what to do ...

  1. copy the "yourapplication.exe " to a suitable location on your Win2012 server (e.g. C:\Windows\System32\ ).

  2. Use "sc " to create a new service that launches "srvany " (e.g. sc create "Servicename" binPath= "C:'Windows'System32'srvany.exe" DisplayName= "My Custom Service" )

  3. Using RegEdit : create a "Parameters " key for your service (e.g. HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Servicename\Paramaters)

  4. Using RegEdit : within the newly created "Parameters " key , create a string value called "Application " and enter the full path to the application you are wanting to run as a service. (No quotes required.)

Syntax:-

sc [] create [] [type= {own | share | kernel | filesys | rec | interact type= {own | share}}] [start= {boot | system | auto | demand | disabled}] [error= {normal | severe | critical | ignore}] [binpath= ] [group= ] [tag= {yes | no}] [depend= ] [obj= { | }] [displayname= ] [password= ]

More...

This question is related to windows service windows-server-2012

The answer is


You can just do that too, it seems to work well too. sc create "Servicename" binPath= "Path\To\your\App.exe" DisplayName= "My Custom Service"

You can open the registry and add a string named Description in your service's registry key to add a little more descriptive information about it. It will be shown in services.msc.


You can use PowerShell.

New-Service -Name "TestService" -BinaryPathName "C:\WINDOWS\System32\svchost.exe -k netsvcs"

Refer - https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.management/new-service?view=powershell-3.0


Examples related to windows

"Permission Denied" trying to run Python on Windows 10 A fatal error occurred while creating a TLS client credential. The internal error state is 10013 How to install OpenJDK 11 on Windows? I can't install pyaudio on Windows? How to solve "error: Microsoft Visual C++ 14.0 is required."? git clone: Authentication failed for <URL> How to avoid the "Windows Defender SmartScreen prevented an unrecognized app from starting warning" XCOPY: Overwrite all without prompt in BATCH Laravel 5 show ErrorException file_put_contents failed to open stream: No such file or directory how to open Jupyter notebook in chrome on windows Tensorflow import error: No module named 'tensorflow'

Examples related to service

Starting ssh-agent on Windows 10 fails: "unable to start ssh-agent service, error :1058" startForeground fail after upgrade to Android 8.1 Context.startForegroundService() did not then call Service.startForeground() How to restart a windows service using Task Scheduler the MySQL service on local computer started and then stopped Android: keep Service running when app is killed How to create a service running a .exe file on Windows 2012 Server? Start systemd service after specific service? Spring Boot application as a Service SSRS expression to format two decimal places does not show zeros

Examples related to windows-server-2012

Remote desktop connection protocol error 0x112f How can I enable "URL Rewrite" Module in IIS 8.5 in Server 2012? How to create a service running a .exe file on Windows 2012 Server? Powershell script to see currently logged in users (domain and machine) + status (active, idle, away) IIS_IUSRS and IUSR permissions in IIS8