borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder

AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

Print This Topic
Previous Topic (Ideas needed)Next Topic (Date problem) New Topic New Poll Post Reply
AndreaVB Forum : VB General : Creating a service
Poster Message
sanjsood
Level: Guest


icon Creating a service

Background:
I am trying to write a program that checks the condition of a remote server, ie when last rebooted, diskspace, etc.
The things I will need to create this as service the starts running when the server is rebooted.
As some of the servers I need to monitor ar Win 2000 and some are NT.

Question:
How do I create a application as a service?

Thanks in advance.

05-04-2004 at 11:18 AM
| Quote Reply
yronium
Level: Moderator


Registered: 14-04-2002
Posts: 907
icon Re: Creating a service

Well, as far as I know, every app can be run as a service. In fact a service isn't nothing else than a program that's run at startup and keeping running until you shut your pc. So you can do it with every program (or file) you want, and not necessarily written in VB (even an HTML file for instance).

Now, you need:
- to have a program that's capable to work in background until the user explicitly closes it (or otherwise, until the session ends);
- to launch it at startup
- to combine this two features into your project.

The second is the one you need: you have to put your app's final path into the registry Run or Runservices key of user's pc. But at the moment, you don't know what will be the user's final path (he could choose another installation path during install phase, or manually move the app directory). So you should manage the installation process:
- have an install program. It can be even the MSI installer created packet, or a custom install launcher
- define an installation default directory, that can be changed by user, and store this path in a string variable
- configure the MSI packet, or your install launcher, to write in the Run registry key the path.

That's all. When the installation is finished, and your user reboots his pc, it will run your app. It will keep running until the user will explicitly close it, or otherwise until the pc is shut down.

There are other methods to make an app to execute at startup, but this one is the most used by developpers.
HTH


____________________________
Real Programmer can count up to 1024 on his fingers

05-04-2004 at 12:13 PM
View Profile Send Email to User Show All Posts | Quote Reply
sanjsood
Level: Guest

icon Re: Creating a service

Will I need to add any APIs in to the code to tell the system that the program is a service.

Also I know what the final path the installation is going to be installed in.

Would I have to tell MSI that it is a service.?

05-04-2004 at 01:49 PM
| Quote Reply
admin
Level: Administrator


Registered: 04-04-2002
Posts: 530
icon Re: Creating a service

you can download a special ocx from http://www.andreavb.com/vb_downloads.html

this ocx created by microsoft allows you to run your program as a service, a service is not only a program which runs in background, it also has to respond to special system messages such as start, stop or pause service and has other features such as desktop interaction...

hope this helps!
the zip file contains the ocx, the help file and a simple example on how to use it.

[Edited by admin on 07-04-2004 at 07:08 AM GMT]

____________________________
AndreaVB

05-04-2004 at 02:37 PM
View Profile Send Email to User Show All Posts Visit Homepage | Quote Reply
yronium
Level: Moderator


Registered: 14-04-2002
Posts: 907
icon Re: Creating a service

Of course you're right admin, I was thinking only to Win9x platforms. But now I remember sanj spoke about Win2k ant NT machines. Well, nevermind my speech


____________________________
Real Programmer can count up to 1024 on his fingers

06-04-2004 at 01:01 PM
View Profile Send Email to User Show All Posts | Quote Reply
AndreaVB Forum : VB General : Creating a service
Previous Topic (Ideas needed)Next Topic (Date problem) New Topic New Poll Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder