CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Apr 1999
    Posts
    21

    Starting VB App as a Service on NT

    I need help finding information on Starting a Program as a Service on NT. I am trying to do this in VB (432/5/6), but if this is not possible, then ANY alternates would certianly be welcome.

    1) How do I Install the program as a Service, so that it appears in the 'Control-Panel-Services' list?

    2) How do I react to the configuration changes made from the 'Control-Panel-Services' list?

    3) How do I Remove the program from the 'Control-Panel-Services' list ?

    A working example would be great, but ANY information or links would be greatly appreciated.

    Thanks
    Kevin Fegan





  2. #2
    Join Date
    Apr 1999
    Posts
    21

    Starting VB App as a Service on NT

    I need help finding information on Starting a Program as a Service on NT. I am trying to do this in VB (432/5/6), but if this is not possible, then ANY alternates would certianly be welcome.

    1) How do I Install the program as a Service, so that it appears in the 'Control-Panel-Services' list?

    2) How do I react to the configuration changes made from the 'Control-Panel-Services' list?

    3) How do I Remove the program from the 'Control-Panel-Services' list ?

    A working example would be great, but ANY information or links would be greatly appreciated.

    Thanks
    Kevin Fegan





  3. #3
    Join Date
    May 1999
    Posts
    3,332

    Re: Starting VB App as a Service on NT

    just a hint: a few weeks ago I posted an MSDN article that said, that MS does not recommend using VB to write services.

    Anyway, if you are not intimidated :-), you can use several approaches:
    - use the SRVANY tool from the NT resouce kit to turn your app into a service.

    - use the APIs: RegisterServiceProcess and RegisterServiceCtrlhandler to respond to changes.


  4. #4
    Join Date
    Apr 1999
    Posts
    21

    Re: Starting VB App as a Service on NT

    Lothar Haensler-

    Could you please let me know the URL/reference to the MSDN article you mentioned ?

    If it is not doable in VB4/5/6, then I would like to write a 'Small' C++ (or J++) App
    that would be started as a Service, and then this 'Small' App would start/stop/manage
    a VB4/5/6 App (much the same way SRVANY works).

    Do you have any ref's/links to sample code (C++ or J++) that uses RegisterServiceProcess and RegisterServiceCtrlhandler ?

    Thanks,

    Kevin



  5. #5
    Join Date
    Apr 1999
    Posts
    21

    Re: Starting VB App as a Service on NT

    Lothar Haensler-

    Could you please let me know the URL/reference to the MSDN article you mentioned ?

    If it is not doable in VB4/5/6, then I would like to write a 'Small' C++ (or J++) App
    that would be started as a Service, and then this 'Small' App would start/stop/manage
    a VB4/5/6 App (much the same way SRVANY works).

    Do you have any ref's/links to sample code (C++ or J++) that uses RegisterServiceProcess and RegisterServiceCtrlhandler ?

    Thanks,

    Kevin



  6. #6
    Join Date
    Mar 2000
    Posts
    2

    Re: Starting VB App as a Service on NT

    I've just done this, and I have a VB6 APP running as a service, sweetly

    Here is an extract from the Microsoft KnowledgeBase:

    HOWTO: Create a User-Defined Service

    The information in this article applies to:
     Microsoft Windows NT Workstation versions 3.51, 4.0
     Microsoft Windows NT Server versions 3.51, 4.0

    IMPORTANT: This article contains information about editing the registry. Before you edit the registry, make sure you understand how to restore it if a problem occurs. For information on how to do this, view the "Restoring the Registry" or the "Restoring a Registry Key" online Help topics in Registry Editor.
    SUMMARY
    The Windows NT Resource Kit provides two utilities that allow you to create a Windows NT user-defined service for Windows NT applications and some 16-bit applications (but not for batch files).

    Instrsrv.exe installs and removes system services from Windows NT and Srvany.exe allows any Windows NT application to run as a service.

    MORE INFORMATION

    To create a Windows NT user-defined service, perform the following steps:
    1. At a MS-DOS command prompt, type the following command:

    <path>\INSTSRV.EXE <My Service> <path>\SRVANY.EXE

    where <path> is the drive and directory of the Windows NT Resource Kit (i.e., C:\RESKIT) and <My Service> is the name of the service you are creating.

    WARNING: Using Registry Editor incorrectly can cause serious problems that may require you to reinstall your operating system. Microsoft cannot guarantee that problems resulting from the incorrect use of Registry Editor can be solved. Use Registry Editor at your own risk.

    For information about how to edit the registry, view the "Changing Keys And Values" online Help topic or the "Add and Delete Information in the Registry" and "Edit Registry Data" online Help topics in Registry Editor.

    NOTE: You should back up the registry before you edit it.

    2. Run Registry Editor (Regedt32.exe)and locate the following subkey:

    HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\<My Service>

    3. From the Edit menu, click Add Key. Type the following and click OK:

    Key Name: Parameters
    Class : <leave blank>

    4. Select the Parameters key.

    5. From the Edit menu, click Add Value. Type the following and click OK:

    Value Name: Application
    Data Type : REG_SZ
    String : <path>\<application.ext>

    where <path>\<application.ext> is the drive and full path to the application executable including the extension (i.e., C:\WinNT\Notepad.exe)

    6. Close Registry Editor.

    By default, a newly created service it configured to run Automatically when the system is restarted. To change this setting to Manual, run the Services applet from Control Panel and change the Startup value to Manual. A service set to Manual can be started in one of several ways:
    - From the Services applet in Control Panel

    - From a MS-DOS command prompt, type the following:

    NET START <My Service>

    - Use the Sc.exe utility from the Resource Kit. Type the following from a MS-DOS command prompt:

    <path>\Sc.exe start <My Service>

    where <path> is the drive and directory of the Windows NT Resource Kit (i.e., C:\Reskit).


    For more information on installing and removing a user-defined service, please see the Srvany.wri document provided with the Windows NT Resource Kit utilities (i.e., C:\Reskit\Srvany.wri). This document can also be found on the Windows NT Resource Kit CD in the Common\Config directory.
    Additional query words: prodnt
    Keywords : nthowto nt16ap nt32ap ntreskit NTSrvWkst
    Version : WinNT:3.51,4.0
    Platform : winnt
    Issue type : kbhowto



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured