Attach macro

A visual studio macro to attach to a program to your choice:

Public Sub AttachPRogram()
        Try
            Dim dbg2 As EnvDTE80.Debugger2 = DTE.Debugger
            Dim trans As EnvDTE80.Transport = dbg2.Transports.Item("Default")
            Dim compName As String = System.Net.Dns.GetHostName()
            Dim procAll = dbg2.GetProcesses(trans,compName)
            For Each proc2 As Process2 In procAll
                If (proc2.Name.ToLower().Contains("your program name here")) Then

                    proc2.Attach()

                End If
            Next proc2

        Catch ex As System.Exception
            MsgBox(ex.Message)
        End Try
    End Sub

Posted

in

by

Tags:

Comments

One response to “Attach macro”

  1. Tudor Avatar
    Tudor

    Nice – I was getting tired of hitting Ctrl-Alt-P each time.. 🙂

Leave a Reply

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