如何自动附加到远程服务器上的特定IIS池?

时间:2020-12-05 20:55:10

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.

目前有三个开发人员共享一个IIS框进行测试。由于第三方工具和其他限制,我们无法在本地运行项目,因此远程调试是唯一的选择。我们当前的流程是远程访问Web服务器,运行iisapp.vps以获取各个站点的PID,然后在VS2008中运行远程调试,以连接到该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.

我找到了自动连接到w3wp的脚本,如果它是唯一运行的脚本但是我没有找到一种方法能够在脚本中远程查找w3wp PID并使用它来附加。

1 个解决方案

#1


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.

与IIS一起使用的大多数脚本都假定您在本地计算机上运行。如果你查看脚本代码,它最有可能使用WMI来处理IIS,它首先要做的是连接到WMI提供程序,它总是需要一个机器名和一个WMI提供程序路径。本地计算机的计算机名称通常表示为“。”。如果需要。

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.

如果将strComputer更改为指向IIS服务器,则将获取查询时运行的所有w3wp进程的PID。

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

注意:上面的代码是脚本的片段而不是完整的程序。

#1


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.

与IIS一起使用的大多数脚本都假定您在本地计算机上运行。如果你查看脚本代码,它最有可能使用WMI来处理IIS,它首先要做的是连接到WMI提供程序,它总是需要一个机器名和一个WMI提供程序路径。本地计算机的计算机名称通常表示为“。”。如果需要。

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.

如果将strComputer更改为指向IIS服务器,则将获取查询时运行的所有w3wp进程的PID。

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

注意:上面的代码是脚本的片段而不是完整的程序。