Tie .exe file into a service

Hi Experts.  We have an in-home app that allows certain messages to be sent to various users.  If this app (message.exe) isn't running, then the messages aren't sent out.  I didn't create or design this app, I just have to find a way to get the exe to run on the server if no one is logged into it.  Right now, if no one is logged into the server, then the exe won't run.  

I am open to ideas on how to get the app to run with no one logged in.  The server is Windows 2003 and is apart of an AD environment.  Thanks for your help.
LVL 9
samiam41Asked:
Who is Participating?
 
ParanormasticConnect With a Mentor Cryptographic EngineerCommented:
There are two main ways you could make this happen:
1) As your title suggests, create a service from the .exe.  Here are a couple articles that should help out with that:
http://support.microsoft.com/kb/137890
http://support.microsoft.com/kb/251192

2) Create a scheduled task and assign credentials for it to run under.

If it is something that should run at specified times (e.g. once an hour/day/week/etc.) then scheduled task might be the better choice.  If it is something that you want to have run continuously, or in response to an event, (e.g. emailing whenever a log file reaches 'x' size) then you probably want to do a service.
0
 
scuzzieCommented:
create a scheduled task to start the exe when windows starts.

if the app has a ui, then set the credentials to the user that you normally log in as, as that will be the only user that will be able to see any ui in the app.
0
 
samiam41Author Commented:
Thanks for the posts.

Here is what I understand, please correct me if I am wrong.
1.  Copy my service.exe into the %systemroot%\system32 folder
2.  Using SC, I will run:
sc create myservice binpath= c:\windows\system32\service.exe

It is a service that should run all the time, no schedules or event related.
0
Simple Misconfiguration =Network Vulnerability

In this technical webinar, AlgoSec will present several examples of common misconfigurations; including a basic device change, business application connectivity changes, and data center migrations. Learn best practices to protect your business from attack.

 
ParanormasticCryptographic EngineerCommented:
Barring the unexpected service hang which can happen with anything, yes that's about it, generically speaking.  

Depending on what it is meant to do, the .exe may need something to poll for information to notice a change, unless something is submitted directly to it.  That gets into a different realm of expertise and has to deal with how the exe itself runs, not simply making it a service so that if it is designed properly it can act that way automatically.  If it doesn't need to poll, refresh, etc. then yes, this would be it.
0
 
samiam41Author Commented:
Cool.  I just created the service.  Is there a way to change the description field after the service is created?

I am testing the service at 2pm EST which is the earliest I could get an approved outage window.
0
 
samiam41Author Commented:
Ok.  Just tried to run the service under the "local system" account and my domain admin account and got this error on both:

The HP9000.Chat service failed to start due to the following error:
The service did not respond to the start or control request in a timely fashion.

I verified that the service was set to "Manual".  Any ideas?
0
 
ParanormasticCryptographic EngineerCommented:
In the registry you can add:
String - "Description" = "Add your own description here in normal words"
String - "DisplayName" = "Add your own descriptive display name to show up in services.msc"
0
 
ParanormasticCryptographic EngineerCommented:
Also make sure things look normal (can compare to other services in same area) in the registry:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\%YourServiceName%
0
 
samiam41Author Commented:
I can run the exe without any problem.  Why can't I run it as a service??
0
 
samiam41Author Commented:
Didn't refresh before posting.  Going through the registry now.
0
 
samiam41Author Commented:
Nothing looks out of the norm from some of the others.  What could be missing?
0
 
ParanormasticConnect With a Mentor Cryptographic EngineerCommented:
Not really sure... instead of using the sc method, you could try removing it and trying the other way from the first link.  Here is another article that has some screenshots of that method.
http://www.tacktech.com/display.cfm?ttid=197
0
 
samiam41Author Commented:
Alright.  I will delete the existing service and start-over.  Thanks!
0
 
samiam41Author Commented:
After reading a couple of posts, should I have rebooted the server after creating the service?  I never did.
0
 
ParanormasticCryptographic EngineerCommented:
You shouldn't have to, but it wouldn't hurt to give it a try if it is still giving you grief.  The registry and services are usually pretty dynamic and instantaneous.
0
 
samiam41Author Commented:
That was my understanding but I thought I better ask.
0
 
samiam41Author Commented:
I haven't forgotten about this post.  I am working on a big project and will come back to this once the project is finished.  Thank you for your patience.
0
 
samiam41Author Commented:
I deleted the previous service and ran the sc create command but I must have missed something else in the command.  Here is what I used.

sc create HP9000.Chat

Not sure what else I need to add.
0
 
samiam41Author Commented:
I am adding the binpath now.
0
 
samiam41Author Commented:
I created the service.  It looks like it's going to run and then it dies.  Error message "Could not start the HP9000.Chat service on local computer"  Error 1053

Any ideas?

I've tried different user accounts including the one that I am logged in with and able to run the exe.  It seems like the service can't start the exe.  
0
 
samiam41Author Commented:
Do I need to specify type?  I see there are several options.

type= <own|share|interact|kernel|filesys|rec|adapt|error>
0
 
samiam41Author Commented:
Alright.  I just figured it out and after testing it, I confirmed it works.

I want to thank everyone who posted on this question for their time and suggestions.

The solution I found is:
Steps to create custom service
1.	Open command prompt
2.	From the command prompt, browse to the root of C
a.	C:\<path_containing_instsrv.exe>\instsrv.exe <service_name> <path_containing_srvany.exe>\srvany.exe
b.	By default, the path for both files should be:
i.	C:\Program Files\Windows Resource Kits\Tools
3.	You should see The service was successfully added! message
a.	If not, start over.
4.	Run regedit (*Backup the registry before proceeding*)
5.	Browse to HKLM\system\CurrentControlSet\Services\<service_name>
6.	Under <service_name>, add key 
a.	Name: Parameters
b.	Class:  <blank>
7.	Under the Parameters, create new String Value
a.	Name:  Application
b.	Data Type:  REG_SZ
c.	String:  <path>\<application.exe>
8.	Close regedit

Open in new window

0
 
samiam41Author Commented:
This may be a little cleaner
Steps to create custom service
 
1.  Open command prompt
2.  From the command prompt, browse to the root of C
    a. C:\<path_containing_instsrv.exe>\instsrv.exe <service_name>   <path_containing_srvany.exe>\srvany.exe
    b. By default, the path for both files should be:
       i. C:\Program Files\Windows Resource Kits\Tools
3.  You should see The service was successfully added! message
    a. If not, start over.
4.  Run regedit (*Backup the registry before proceeding*)
5.  Browse to HKLM\system\CurrentControlSet\Services\<service_name>
6.  Under <service_name>, add key 
    a.  Name: Parameters
    b.  Class:  <blank>
7.  Under the Parameters, create new String Value
    a.  Name:  Application
    b.  Data Type:  REG_SZ
    c.  String:  <path>\<application.exe>
8.  Close regedit

Open in new window

0
 
samiam41Author Commented:
The link you provided put me on the right path.  Thanks for all your help!  I sure learned a lot from this.  Take care!

-Aaron
0
 
ParanormasticCryptographic EngineerCommented:
Sorry, I hadn't gotten to checking up on this one yet today - looks like you got it worked out.  Nice summary documentation at the end - I wish I could give you points back just for that!  I'm happy to see that everything is working for you!
0
 
samiam41Author Commented:
I didn't get a notice you had posted back!  Thanks again for your help on this.  I would have labeled it "impossible" and not worked on it again had you not offered your time and help.  I appreciate the kind words regarding the documentation.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.