Debugging a Windows NT Service

Last reviewed: July 16, 1997
Article ID: Q170738
The information in this article applies to:
  • Microsoft Windows NT Workstation version 4.0
  • Microsoft Windows NT Server version 4.0

SUMMARY

Debugging a Windows NT service can be done in several ways. You can debug a service while it is running by attaching to the process ID of the Service through a debugger such as NTSD or WINDBG. You can also set Windows NT so that it will start the process in a debugger when you start the service.

These techniques are useful for different debug scenarios. This article discusses the steps that you need to take when you want to debug a service during the initialization.

MORE INFORMATION

In order to set up Windows NT so that it will start the Service in a debugger, the following registry key needs to be set during the Service initialization:

WARNING: Using Registry Editor incorrectly can cause serious, system-wide problems that may require you to reinstall Windows NT to correct them. Microsoft cannot guarantee that any problems resulting from the use of Registry Editor can be solved. Use this tool at your own risk.

  1. Start Registry Editor and locate the following Registry subkey in the HKEY_LOCAL_MACHINE subtree:

          SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution
          Options
    

  2. Create a subkey with the name of your Service executable (for example, Myservice.exe)

  3. To this subkey, add the REG_SZ value called Debugger and the full path to the debugger you want to use. You can add any command line option for the debugger as well.

  4. Close Registry Editor.

  5. Start the Service

The debugger will start when the image for the Service executable is loaded into memory.

For additional information on Windows NT debuggers, please see the following article in the Microsoft Knowledge Base:

   ARTICLE-ID: Q121652
   TITLE     : List of Debuggers Supported with Windows NT

   ARTICLE-ID: Q121434
   TITLE     : Specifying the Debugger for Unhandled User Mode Exceptions
 

	
	


Keywords : NTSrvWkst
Version : 4.0
Platform : WinNT
Hardware : x86
Issue type : kbhowto


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: July 16, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.