Pick the right w3wp.exe to attach among Multiple Worker processes while debugging

When multiple web applications running with multiple application pools, they will create multiple worker processes (W3WP.exe). While debugging code from Visual Studio, we got to pick the one that belongs to the target web application, otherwise, the debugger will not stop on break-points!

Don’t forget to select “Show processes from all users”, otherwise w3wp won’t be showing up in attach process window!

attach w3wp process visual studio 2010

How to select the correct W3WP.exe to attach?

If you use different user accounts for different application pools, you can just pick the right one easily by checking “User Name” column. Follow these instructions to find the right worker process to attach:

  • From the running processes, we’ll have to get the process id value. Lets go to Windows Task Manager >> View >> Select Columns (You’ll see multiple w3wp.exe in task manager)
multiple w3wp.exe task manager
  • Select the “PID (Process Identifier)” column from the list.multiple w3wp.exe instances Task Manager Find ID
  • Now go to the command prompt, go to the directory “C:\windows\System32\Inetsrv”
  • Enter “Appcmd list wp”

This will list all running worker processes and their associated web applications. Now open the Task Manager to match the PID with the desired web application’s worker process ID.

attach w3wp.exe process visual studio

Now you have the right w3wp process to attach!

Here I have my custom code deployed in the web application “SharePoint80” and wanted to debug the same. So the W3WP process I’ve to attach is 2372.

Happy debugging!

For Windows 2003 – IIS 6:
If you are running IIS 6 in Windows 2003, You can get the list of worker processes with their associated web applications by running the vb script: iisapp.vbs located at: c:\windows\system32 folder.

You can type cscript iisapp.vbs in the command line. If it says “Error – No Results” – Either your IIS sites are in a Stopped state or no worker processes running.!

Alternatively, You can use Process Explorer from Microsoft to get the right worker process. Make sure you are selecting the “Command Line” column in view to get the process with its associated web application.

Salaudeen Rajack

Salaudeen Rajack - Information Technology Expert with Two-decades of hands-on experience, specializing in SharePoint, PowerShell, Microsoft 365, and related products. He has held various positions including SharePoint Architect, Administrator, Developer and consultant, has helped many organizations to implement and optimize SharePoint solutions. Known for his deep technical expertise, He's passionate about sharing the knowledge and insights to help others, through the real-world articles!

Leave a Reply

Your email address will not be published. Required fields are marked *