简体   繁体   中英

How do you automatically attach to a specific IIS pool on remote server?

Currently three developers share one IIS box for testing. Because of third party utils and other restrictions we can't run the project locally so remote debugging is the only option. Our current process is to remote to the webserver, run iisapp.vps to get the PID of our individual sites and then run remote debugging in VS2008, to connect to that pid.

I have found scripts for automatically connecting to w3wp automatically, if it's the only one running however I haven't found a way to be able to remotely find the w3wp PID in script and use that to attach.

Most of the scripts that work with IIS assume that you are running on the local machine. If you look in the script code it's most likely using WMI to work with IIS and the first thing it has to do is connect to WMI provider which always requires a machine name and a WMI provider path. The machine name for the local machine is often represented as "." where required.

For Example:

strComputer = "." 
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" _
    & strComputer & "\root\cimv2")

Set colProcesses = objWMIService.ExecQuery( _
    "select * from win32_process Where Name = 'w3wp.exe'" )
For Each objProcess in colProcesses
    WScript.Echo objProcess.ProcessId

If you change strComputer to point to the IIS server, you will get the PIDs for all of the w3wp processes running at the time of the query.

Note: the above code is a fragment of a script not a complete program.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM