title: How can I make a Visual Studio Macro to attach the debugger to all instances of w3wp.exe?
body: <p>I'm normally developing web apps, and a surprisingly large amount of my work time is spent doing "Ctrl + Alt + P", sorting by Process Name, and picking w3wp.exe to attach my debugger.</p>
  
  <p>To make matters worse, I'm working on an app that spans several application pools, so I normally have 2 or 3 instances of w3wp.exe, and it's impossible to know which one to attach to, so I normally end up attaching to all of them, which is overkill but works.</p>
  
  <p>All in all, this is pretty annoying...</p>
  
  <p>My colleague figured out a way to have a VS Macro to automatically attach to w3wp.exe (he basically recorded this):</p>
  
  <pre><code>Sub AttachMacro()    
    Try    
      Dim dbg2 As EnvDTE80.Debugger2 = DTE.Debugger    
      Dim trans As EnvDTE80.Transport = dbg2.Transports.Item("Default")    
      Dim dbgeng(3) As EnvDTE80.Engine    
      dbgeng(0) = trans.Engines.Item("T-SQL")    
      dbgeng(1) = trans.Engines.Item("T-SQL")    
      dbgeng(2) = trans.Engines.Item("Managed")    
      Dim proc2 As EnvDTE80.Process2 = dbg2.GetProcesses(trans, "ENIAC").Item("w3wp.exe")    
      proc2.Attach2(dbgeng)    
    Catch ex As System.Exception    
      MsgBox(ex.Message)    
    End Try    
  End Sub
  </code></pre>
  
  <p>I'm not really sure whether all that is necessary, or anything, I have never made a macro for VS, I don't really know where to start.</p>
  
  <p>Would there be a way to modify this macro so that instead of attaching itself to <strong>an</strong> instance of w3wp.exe, it will attach itself to <strong>all</strong> instances of w3wp.exe?</p>