Solved

Tie .exe file into a service

Posted on 2008-09-29
26
1,132 Views
Last Modified: 2012-06-21
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.
0
Comment
Question by:samiam41
  • 18
  • 7
26 Comments
 
LVL 31

Accepted Solution

by:
Paranormastic earned 500 total points
ID: 22595807
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
 
LVL 1

Expert Comment

by:scuzzie
ID: 22595824
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
 
LVL 9

Author Comment

by:samiam41
ID: 22595995
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
 
LVL 31

Expert Comment

by:Paranormastic
ID: 22598582
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
 
LVL 9

Author Comment

by:samiam41
ID: 22598787
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
 
LVL 9

Author Comment

by:samiam41
ID: 22599057
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
 
LVL 31

Expert Comment

by:Paranormastic
ID: 22599609
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
 
LVL 31

Expert Comment

by:Paranormastic
ID: 22599851
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
 
LVL 9

Author Comment

by:samiam41
ID: 22599853
I can run the exe without any problem.  Why can't I run it as a service??
0
 
LVL 9

Author Comment

by:samiam41
ID: 22599911
Didn't refresh before posting.  Going through the registry now.
0
 
LVL 9

Author Comment

by:samiam41
ID: 22605281
Nothing looks out of the norm from some of the others.  What could be missing?
0
 
LVL 31

Assisted Solution

by:Paranormastic
Paranormastic earned 500 total points
ID: 22613509
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
 
LVL 9

Author Comment

by:samiam41
ID: 22613622
Alright.  I will delete the existing service and start-over.  Thanks!
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 9

Author Comment

by:samiam41
ID: 22613768
After reading a couple of posts, should I have rebooted the server after creating the service?  I never did.
0
 
LVL 31

Expert Comment

by:Paranormastic
ID: 22614823
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
 
LVL 9

Author Comment

by:samiam41
ID: 22614954
That was my understanding but I thought I better ask.
0
 
LVL 9

Author Comment

by:samiam41
ID: 22668309
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
 
LVL 9

Author Comment

by:samiam41
ID: 22710806
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
 
LVL 9

Author Comment

by:samiam41
ID: 22710824
I am adding the binpath now.
0
 
LVL 9

Author Comment

by:samiam41
ID: 22710897
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
 
LVL 9

Author Comment

by:samiam41
ID: 22710974
Do I need to specify type?  I see there are several options.

type= <own|share|interact|kernel|filesys|rec|adapt|error>
0
 
LVL 9

Author Comment

by:samiam41
ID: 22712481
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
 
LVL 9

Author Comment

by:samiam41
ID: 22712523
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
 
LVL 9

Author Closing Comment

by:samiam41
ID: 31501151
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
 
LVL 31

Expert Comment

by:Paranormastic
ID: 22716103
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
 
LVL 9

Author Comment

by:samiam41
ID: 22813533
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

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Join & Write a Comment

This is an explanation of a simple data model to help parse a JSON feed
A quick step-by-step overview of installing and configuring Carbonite Server Backup.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now