Link to home
Start Free TrialLog in
Avatar of Patrick Wrigley
Patrick WrigleyFlag for United States of America

asked on

How create a service from a single .exe file

I am trying to create a service out of a simple .exe file

using the following command:
sc.exe create messageAll  binPath= "C:\MSG_Service\messageAll.exe"

the service is successfully created:
C:\Windows\system32>sc.exe create messageAll  binPath= "C:\MSG_Service\messageAll.exe"
[SC] CreateService SUCCESS

But when I try to start the service I get the follwing error
Avatar of Patrick Wrigley
Patrick Wrigley
Flag of United States of America image

ASKER

User generated image
the only item in the folder C:\MSG_Service is the messageAll.exe

SOLUTION
Avatar of skullnobrains
skullnobrains

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Arana (G.P.)
Arana (G.P.)

The best approach to do that is to use http://nssm.cc/

 Install your sevice with nssm.exe install [serviceName]

it is really good
@Arana, I slightly disagree. You don't win anything by running it as a service, Running it as scheduled task is sufficient in almost every case. Since the dawn of NT, I never had an use-case where this would be necessary.
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
i remember the days when we could tell the difference between forced accepts, actual accepts, community based accepts... sigh
Well you do gain something, using nssm you can actually monitor if service (application) is really running and it handles restart on crash, system logs etc. While yes starting a task can be enough for the app to  start you have to handle the restarts, the logs, etc.
Imho it is the wrong approach.

It's like using a hammer and a screw to hang up a picture. It can be done, but it's simply not correct.
i love the analogy !
monitor your services instead of using a watchdog per service.
btw, who is expected to monitor the watchdog ?