Pages

Saturday, April 4, 2009

MSVC run and attach script

Option Strict Off
Option Explicit Off
Imports System
Imports EnvDTE
Imports EnvDTE80
Imports System.Diagnostics

Public Module Module1
Sub macro1()
'DTE.Windows.Item(Constants.vsWindowKindCommandWindow).Activate()
DTE.ExecuteCommand("Tools.Shell", "...exe")
Try

Threading.Thread.Sleep(5000)

Dim dbg2 As EnvDTE80.Debugger2 = DTE.Debugger

Dim trans As EnvDTE80.Transport = dbg2.Transports.Item("Default")

Dim dbgeng(2) As EnvDTE80.Engine

dbgeng(0) = trans.Engines.Item("Managed")

dbgeng(1) = trans.Engines.Item("Native")

Dim proc2 As EnvDTE80.Process2 = dbg2.GetProcesses(trans, "computer_name").Item("...exe")

proc2.Attach2(dbgeng)

Catch ex As System.Exception

MsgBox(ex.Message)

End Try


End Sub

End Module