Solved

COM object as NT Service

Posted on 2002-03-04
15
241 Views
Last Modified: 2010-05-02
I have a COM object that reads a directory for a specific file and if it finds one, it is to copy it from one folder to another.
I want this COM object to a be an NT Service that runs every 10 minutes....how can I make this COM object an NT Service so it runs in the background...like other Services on a machine?
0
Comment
Question by:lobos
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
  • 3
  • +2
15 Comments
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 6839260
I would write a small VB app that runs as a service, and that calls this COM object.
* to run every 10 minutes: use a timer control or a API, as you like
* to run as service: use the ntsvc.ocx, or some utility to transform your application into a service.


Note:
  For simplicity, you might use the timer control and the ntsvc control on the same form, the utility to transform your application makes it more difficult in your code to handle the different events send from the services applet...

CHeers
0
 
LVL 18

Expert Comment

by:mdougan
ID: 6839269
Well, VB executables don't really have the proper interface to be installed as services by themselves.

What you need to do is download this C program that can act as a "proxy" for your VB program.  So, the C program is actually the one that runs as the NT Service, but when it starts up, you give it some start-up parameters to start-up your VB program.

This program was available on the MSDN disks.... let me see if I can find in out there.....

Here is one of the links that I used:

http://www.geocities.com/SiliconValley/Pines/3991/nthowto.htm

Here is the other one I think:

http://vbwire.com/advanced/howto/service.asp

Good Luck!
0
 
LVL 4

Expert Comment

by:srauda
ID: 6840172
I believe the NT Service Toolkit by Desaware is exactly what you are looking for.  I have used it and it works very nicely and is very reliable.

This toolkit allows you to create an ActiveX Dll that is linked to an exe created by the toolkit.  The exe runs as the service and calls your dll for running the tasks you require.  The exe hides all the complexities required for creating a service.

Check it out at www.desaware.com
0
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 
LVL 18

Accepted Solution

by:
mdougan earned 100 total points
ID: 6843104
srauda,

That is exactly what the srvany.exe does that you can download for free from the links I provided above.  The links also provide sample VB source, including some important tips on code necessary for cleanly terminating the service when the user stops the service using the Service control manager.

Why pay for something from Desaware when you can get it for free?
0
 
LVL 4

Expert Comment

by:srauda
ID: 6844334
mdougan,

the srvany.exe is not as stable.

0
 
LVL 4

Expert Comment

by:srauda
ID: 6844338
Plus, you cannot handle events passed on by the service control manager if necessary.
0
 

Author Comment

by:lobos
ID: 6844386
I would like to avoid including other vendors for anything.
0
 
LVL 4

Expert Comment

by:srauda
ID: 6844712
then mdougan has the right solution.

another solution would be to include the COM in a standard exe.  Then have the Microsoft Task Scheduler run the exe every ten minutes.
0
 
LVL 18

Expert Comment

by:mdougan
ID: 6845542
I never had any trouble with srvany.exe.  

I'm not sure what you mean by events.  srvany handles the user starting or stoping the service from the service control manager (and as far as I know, anthing else you can do in the service control manager), all you have to do is put code in your vb component for when those events are relayed to your app from srvany.
0
 
LVL 4

Expert Comment

by:srauda
ID: 6845717
In the desaware toolkit, have a scm object reference that you can use to respond to start and stop events as well as user control events.

I never saw how my vb code could respond to srvany.  As far as I saw, srvany would be responsible for launching and terminating your executable.  In fact, your program had to be an executable.

Maybe I am mistaken, but that was how I saw it.

0
 
LVL 1

Expert Comment

by:Moondancer
ID: 6851778
I'll return shortly, but since I've asked Administration to contact lobos, wanted to include this first.

Question(s) below appears to have been abandoned. Your options are:
 
1. Accept a Comment As Answer (use the button next to the Expert's name).
2. Close the question if the information was not useful to you. You must tell the participants why you wish to do this, and allow for Expert response.
3. Ask Community Support to help split points between participating experts, or just comment here with details and we'll respond with the process.
4. Delete the question. Again, please comment to advise the other participants why you wish to do this.

For special handling needs, please post a zero point question in the link below and include the question QID/link(s) that it regards.
http://www.experts-exchange.com/jsp/qList.jsp?ta=commspt
 
Please click the Help Desk link on the left for Member Guidelines, Member Agreement and the Question/Answer process.  http://www.experts-exchange.com/jsp/cmtyHelpDesk.jsp

Please click you Member Profile to view your question history and keep them all current with updates as the collaboration effort continues, to track all your open and locked questions at this site.  If you are an EE Pro user, use the Power Search option to find them.

To view your open questions, please click the following link(s) and keep them all current with updates.
http://www.experts-exchange.com/questions/Q.20258729.html
http://www.experts-exchange.com/questions/Q.20269575.html
http://www.experts-exchange.com/questions/Q.20273076.html

PLEASE DO NOT AWARD THE POINTS TO ME.  
 
------------>  EXPERTS:  Please leave any comments regarding your closing recommendations if this item remains inactive another seven (7) days.  Also, if you are interested in the cleanup effort, please click this link, entitled EXPERTS WHO ARE TIRED OF ABANDONED QUESTIONS CAN HELP"  ... http://www.experts-exchange.com/jsp/qManageQuestion.jsp?ta=commspt&qid=20274643

Thank you everyone.
Moondancer
Moderator @ Experts Exchange
0
 
LVL 1

Expert Comment

by:Moondancer
ID: 6869725
A "C" grade without even a comment as to why?  Please do make a comment to tell us why.  This not only helps the experts here understand, but also future people who visit this item in our PAQ for help.  If you've found more in this regard, please add it. If the grade was given in error, let us know, we can correct.

The points to you are the same, but the expert points which flow depend on the grade.

Thanks,
Moondancer - EE Moderator
0
 
LVL 1

Expert Comment

by:Moondancer
ID: 6869979
After re-reading this the 3rd time and still no response, feel that an A is in order and changed it accordingly.
Moondancer - EE Moderator
0
 
LVL 18

Expert Comment

by:mdougan
ID: 6872867
Thanks!  I can't understand a "C" either, he got more than enough information to answer his original question.
0
 

Author Comment

by:lobos
ID: 6876796
I applogize, it was an error and it should have been corrected, thanks for changing it for me.
Thanks again.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

717 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