Registrations are now open. Join us today!
There is still a lot of work to do on the wiki yet! More information about editing can be found here.
Already have an account?

Difference between revisions of "Microsoft KB Archive/170738"

From BetaArchive Wiki
(importing KB archive)
 
m (Text replacement - """ to """)
 
Line 78: Line 78:
 
                     </pre></li>
 
                     </pre></li>
 
<li>Create a subkey with the name of your Service executable (for example, Myservice.exe)</li>
 
<li>Create a subkey with the name of your Service executable (for example, Myservice.exe)</li>
<li>To this subkey, add the REG_SZ value called Debugger and the full path to the debugger you want to use, but omit the &quot;.exe&quot; extension. You can add any command-line option for the debugger as well.</li>
+
<li>To this subkey, add the REG_SZ value called Debugger and the full path to the debugger you want to use, but omit the ".exe" extension. You can add any command-line option for the debugger as well.</li>
 
<li>Close Registry Editor.</li>
 
<li>Close Registry Editor.</li>
 
<li>Start the Service.<br />
 
<li>Start the Service.<br />
 
<br />
 
<br />
'''NOTE''': The service must run as Local System and have &quot;Interact with Desktop&quot; enabled in order for the debugger to show up on the default desktop. For example:
+
'''NOTE''': The service must run as Local System and have "Interact with Desktop" enabled in order for the debugger to show up on the default desktop. For example:
 
<div class="indent">
 
<div class="indent">
  
<p>HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\yourapp.exe &quot;Debugger&quot;=&quot;C:\windbg -g&quot;</p>
+
<p>HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\yourapp.exe "Debugger"="C:\windbg -g"</p>
  
 
</div></li></ol>
 
</div></li></ol>

Latest revision as of 10:04, 21 July 2020

Knowledge Base


Debugging a Windows NT Service

Article ID: 170738

Article Last Modified on 2/27/2007



APPLIES TO

  • Microsoft Windows 2000 Server
  • Microsoft Windows 2000 Advanced Server
  • Microsoft Windows 2000 Professional Edition
  • Microsoft Windows 2000 Datacenter Server
  • Microsoft Windows NT Workstation 4.0 Developer Edition
  • Microsoft Windows NT Server 4.0 Standard Edition



This article was previously published under Q170738

IMPORTANT: This article contains information about modifying the registry. Before you modify the registry, make sure to back it up and make sure that you understand how to restore the registry if a problem occurs. For information about how to back up, restore, and edit the registry, click the following article number to view the article in the Microsoft Knowledge Base:

256986 Description of the Microsoft Windows Registry


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

WARNING: If you use Registry Editor incorrectly, you may cause serious problems that may require you to reinstall your operating system. Microsoft cannot guarantee that you can solve problems that result from using Registry Editor incorrectly. Use Registry Editor at your own risk.

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:

  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, but omit the ".exe" extension. You can add any command-line option for the debugger as well.
  4. Close Registry Editor.
  5. Start the Service.

    NOTE: The service must run as Local System and have "Interact with Desktop" enabled in order for the debugger to show up on the default desktop. For example:

    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\yourapp.exe "Debugger"="C:\windbg -g"

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

For additional information about Windows NT debuggers, click the article number below to view the article in the Microsoft Knowledge Base:

121434 Specifying the Debugger for Unhandled User Mode Exceptions


Keywords: kbhowto KB170738