Link to home
Start Free TrialLog in
Avatar of samiam41
samiam41Flag for United States of America

asked on

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.
ASKER CERTIFIED SOLUTION
Avatar of Paranormastic
Paranormastic
Flag of United States of America image

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
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.
Avatar of samiam41

ASKER

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.
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.
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.
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?
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"
Also make sure things look normal (can compare to other services in same area) in the registry:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\%YourServiceName%
I can run the exe without any problem.  Why can't I run it as a service??
Didn't refresh before posting.  Going through the registry now.
Nothing looks out of the norm from some of the others.  What could be missing?
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
Alright.  I will delete the existing service and start-over.  Thanks!
After reading a couple of posts, should I have rebooted the server after creating the service?  I never did.
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.
That was my understanding but I thought I better ask.
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.
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.
I am adding the binpath now.
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.  
Do I need to specify type?  I see there are several options.

type= <own|share|interact|kernel|filesys|rec|adapt|error>
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

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

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
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!
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.