Debugging W3WP Startup
On a few occasions, I have needed to debug the startup of the IIS worker process (w3wp). I finally decided to create a script so that I no longer need to search for the answer. The script starts w3wp by requesting a non-existent ASPX page. After windbg is closed, the script will kill the debug session and clean up the registry.
Script requirements:
- Debugging Tools for Windows
- TinyGet, from the IIS Resource Kit Tools
- PsKill from PsTools
Debug Script:
reg add "HKLM\Software\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\w3wp.exe" /v Debugger /t REG_SZ /d "cdb.exe -c \".server tcp:port=9999\"" /f
iisreset /restart
start /b tinyget5 -srv:localhost -uri:/notfound.aspx -status:404
sleep 3
windbg -remote tcp:port=9999,server=localhost
pskill cdb
pskill w3wp
reg delete "HKLM\Software\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\w3wp.exe" /f