0

I'm modifying one of the attach to process macro's for VS 2010.

I often have multiple instances of iisexpress running. I usually run them via batch start command and specify a title - so whenever i use VS's attach to process window i can clearly see the title of the instance i'm attaching to. I'm wondering how do I get the title of the process within the macro. I can get process id which could potentially give me access to title I assume... ?

Community
  • 1
  • 1
ambidexterous
  • 832
  • 12
  • 21

2 Answers2

0

After you get EnvDTE.Process, e.g. process, you can get the tile like this:

 System.Diagnostics.Process.GetProcessById(process.ProcessID).MainWindowTitle 
aaron
  • 1,951
  • 3
  • 27
  • 41
0

You can use the Process.MainWindowTitle property:

Sub Main()

    For Each process In System.Diagnostics.Process.GetProcesses()
        If process.ProcessName = "cmd" Then
            Console.WriteLine("{0}: {1}", process.ProcessName, process.MainWindowTitle)
        End If

    Next

End Sub

If you execute this command:

start "xyzzy" cmd.exe

The test program produces this output:

cmd: C:\Windows\system32\cmd.exe
cmd: xyzzy
Rick Sladkey
  • 33,988
  • 6
  • 71
  • 95