?
Solved

How to set a program to run as a Windows service?

Posted on 2003-03-27
5
Medium Priority
?
1,344 Views
Last Modified: 2012-05-04
Hi VB Experts,

I did a little applcation that I want to set as a service with the installation.

I have absolutly no idea on how to do it and can't find any good reference on the topic on the web.

I'm using VB6 and I did a little install with the VS package wizard. To set the program to run at boot time I edited the registry with a .reg file as follow:

REGEDIT4

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run]
"supportServer"="C:\\Program Files\\Program Files\\AIGSupportServer\\supportServer.exe"

Is there a more elegant way to set it with the instalation of the application? Wath's the most common solution experts use to set a VB application to run as a service?

Any comments or references will be very appreciate.

Thanks in advance.
0
Comment
Question by:JeromeQc
[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 Comments
 
LVL 3

Expert Comment

by:emadat
ID: 8222800
Under Windows 2000; from The Start Menu:

- Settings
- Control Panel
- Scheduled Tasks
- Add a Scheduled Task. This will launch the "Scheduled Task Wizard"
- Click Next
- Browse for your Exe
- Select "When my computer starts"

That's it.!

Regards,

0
 

Author Comment

by:JeromeQc
ID: 8224774
No, if this i wath I wanted to do I instead asked this question under the Windows section.

The way I do it now is much more simpler by a double click on a .reg file. But this is not very elegant to ask the user who make the install to set up the registry with the .reg file.

I want my program to be automaticaly register to run as a service, without any extra user interaction...
 
0
 
LVL 1

Accepted Solution

by:
GERTJAN earned 400 total points
ID: 8228828
Do you use the NTService Control NTSVC.OCX?

If you do you can try something like this. Change the setup.vbp from the package and deployment wizard. You can find this project in the C:\Program Files\Microsoft Visual Studio\VB98\Wizards\PDWizard\Setup1 directory. Add the ntservice control to the project and put the control on the frmSetup1 form. Make the properties the same as you have them in your service

Put the following code in the form load section of the frmSetup1 form just before the line: ExitSetup:


    'Install the service
        ' Only if you want to enable interaction with the desktop
        NTService.Interactive = True
        NTService.StartMode = svcStartAutomatic
        'Install the program as an NT service
        If NTService.Install Then
            'Save the TimerInterval Parameter in the Registry
            NTService.SaveSetting "Parameters", "TimerInterval", "10000"
            MsgBox NTService.DisplayName & ": Succesful installed"
        Else
            MsgBox NTService.DisplayName & ": Not installed"
        End If

Compile the setup1.vbp project and place the setup1.exe in the following directory: C:\Program Files\Microsoft Visual Studio\VB98\Wizards\PDWizard. Start the wizard and make your setup program.

Goodluck,

gertjan
0
 

Expert Comment

by:CleanupPing
ID: 8531451
Hi JeromeQc,
This old question (QID 20565977) needs to be finalized -- accept an answer, split points, or get a refund.  Please see http://www.cityofangels.com/Experts/Closing.htm for information and options.
0
 
LVL 6

Expert Comment

by:GPrentice00
ID: 9440854
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

 -->Accept GERTJAN's comment as Answer

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER

GPrentice00
Cleanup Volunteer
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
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 process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses
Course of the Month10 days, 7 hours left to enroll

765 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