Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 'Run this to get all IIS worker processes: %windir%\system32\inetsrv\appcmd.exe list wp
- 'How to attach hotkey for macros: http://blog.lavablast.com/post/2008/01/11/Attach-to-Process-with-one-shortcut.aspx
- Imports System
- Imports EnvDTE
- Imports EnvDTE80
- Imports EnvDTE90
- Imports EnvDTE90a
- Imports EnvDTE100
- Imports System.Diagnostics
- Imports System.IO
- Public Module HotKeys
- Sub AttachToIIS_WP()
- Const IISPoolName = "Your IIS app pool name"
- Dim pathToExe As String = Path.Combine(Environment.GetEnvironmentVariable("windir"), "system32\inetsrv\appcmd.exe")
- Dim arguments As String = "list wp"
- Dim workerProcesses As String = RunConsoleApp(pathToExe, arguments)
- Dim procId As Integer = 0
- For Each wp As String In workerProcesses.Split(Environment.NewLine)
- If (wp.Contains(IISPoolName)) Then
- Dim procIdString As String = wp.Split(" ")(1).Replace("""", "")
- procId = Integer.Parse(procIdString)
- Exit For
- End If
- Next
- For Each proc In DTE.Debugger.LocalProcesses
- If (proc.ProcessID = procId And proc.Name.Contains("w3wp.exe")) Then
- proc.Attach()
- Exit Sub
- End If
- Next
- End Sub
- Function RunConsoleApp(ByVal pathToExe As String, ByVal arguments As String)
- Dim returnvalue As String = ""
- Dim info As ProcessStartInfo = New ProcessStartInfo(pathToExe, arguments)
- info.UseShellExecute = False
- 'info.RedirectStandardInput = True
- info.RedirectStandardOutput = True
- info.CreateNoWindow = True
- Using process As System.Diagnostics.Process = process.Start(info)
- 'Dim sw As StreamWriter = process.StandardInput
- Dim sr As StreamReader = process.StandardOutput
- returnvalue = sr.ReadToEnd()
- End Using
- Return returnvalue
- End Function
- End Module
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement