Pages

Monday, January 20, 2014

create service in windows

create service in windows

sc.exe is used to create services in windows.
I tried to configure batch files as service, but it did not work.
So I converted .bat to . exe and tried with exe files.
At last, I was able to configure the exe files as windows services.

(1) First convert your .bat file to .exe file.

Refer this post for .bat to .exe conversion.

http://blogforopensource.blogspot.com/2014/01/bat-to-exe-windows.html

(2) Create Service using sc.exe command

Regarding sc.exe 

Refer: 

http://technet.microsoft.com/en-us/library/cc990289.aspx


A sample snippet is shown below.


sc create <ServiceName> binpath=<SPACE> <Full Path to Binary>  start=<SPACE> auto

start= auto -> means service will start automatically on starting the System.

sc create helloworld.exe binpath= c:/helloworld.exe start= auto

NOTE:

1. Make sure you are in the command prompt as Administrator.

    Refer this post to run command prompt as Administrator.

2. Space should be there after the = symbol.
3. This worked for me under Windows Server 2008 R2.

No comments:

Post a Comment