Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1358
  • Last Modified:

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

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
JeromeQc
Asked:
JeromeQc
1 Solution
 
emadatCommented:
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
 
JeromeQcAuthor Commented:
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
 
GERTJANCommented:
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
 
CleanupPingCommented:
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
 
GPrentice00Commented:
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.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now