如何使用命令行回收远程计算机上的应用程序池

发布于 2024-10-25 00:23:43 字数 475 浏览 8 评论 0原文

我在 vbs 文件中有以下内容,我尝试从命令行运行该文件:

strServerName = "ServerName"
strAppPoolName = "DefaultAppPool"
set objAppPools = GetObject("IIS://" & strServerName 
                                  & "/w3svc/AppPools/" & strAppPoolName & "")
objAppPools.Recycle()

但是当我从 cmd 行运行 vbs 时,出现以下错误:

Microsoft VBScript 运行时错误:ActiveX 组件无法创建对象:“获取对象”_

我在本地计算机上运行 XP,而远程计算机具有 IIS 7。

我怎样才能使其工作?

I have the following in a vbs file that i am trying to run from the command line:

strServerName = "ServerName"
strAppPoolName = "DefaultAppPool"
set objAppPools = GetObject("IIS://" & strServerName 
                                  & "/w3svc/AppPools/" & strAppPoolName & "")
objAppPools.Recycle()

And yet when I run the vbs from cmd line i get the following error:

Microsoft VBScript runtime error: ActiveX component can't create object: 'Get Object'_

I am running XP on my local machine, and the remote machine has IIS 7.

How can I get this to work?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(8

写下不归期 2024-11-01 00:23:44

在尝试了一切之后,以下命令对我有用!

cd %windir%\system32\inetsrv

appcmd.exe stop site /site.name:"test1.com"

appcmd.exe start site /site.name:"test1.com"

显然在这些之前,您将运行一些 ssh 远程命令,如下所示出色地

Following commands worked for me after trying everything !

cd %windir%\system32\inetsrv

appcmd.exe stop site /site.name:"test1.com"

appcmd.exe start site /site.name:"test1.com"

Obviously before these, you will run some ssh remote command as well

秋风の叶未落 2024-11-01 00:23:43

我不确定特定的 vb 脚本,但我建议使用“appcmd”(http://learn.iis。 net/page.aspx/114/getting-started-with-appcmdexe)

  1. %windir%\system32\inetsrv 添加到您的路径(如果尚未
  2. 在命令提示符中输入): <代码>appcmd回收应用程序池“apppool_name”

I am not sure regarding the particular vb script but I would recommend using "appcmd" (http://learn.iis.net/page.aspx/114/getting-started-with-appcmdexe)

  1. Add %windir%\system32\inetsrv to your path if it is not already
  2. in a command prompt type: appcmd recycle apppool "apppool_name"
回眸一遍 2024-11-01 00:23:43

虽然不是 vbs 文件命令,但您可以让 vbs 执行此命令行;

appcmd recycle apppool /apppool.name:string

变量字符串是要回收的应用程序池的名称。例如,要回收名为 Marketing 的应用程序池,请在命令提示符处键入以下内容,然后按 Enter:

appcmd recycle apppool /apppool.name:Marketing

取自 technet

如果它离你想要的太远,那么我很抱歉。

While not a vbs file command you could get vbs to execute this command line;

appcmd recycle apppool /apppool.name:string

The variable string is the name of the application pool that you want to recycle. For example, to recycle an application pool named Marketing, type the following at the command prompt, and then press ENTER:

appcmd recycle apppool /apppool.name:Marketing

Taken from technet

If it's too far away from what you want then my apologies.

青衫儰鉨ミ守葔 2024-11-01 00:23:43

使用powershell命令来运行它。示例:

Invoke-WMIMethod Recycle -Path "IIsApplicationPool.Name='W3SVC/APPPOOLS/apppoolname'" -Computer "WIN-Computername" -Namespace root\MicrosoftIISv2 -Authentication PacketPrivacy

其中 apppoolname 是您的应用程序池名称。

其中 WIN-Computername 是您的远程/本地服务器名称

Use powershell command to run it. Example:

Invoke-WMIMethod Recycle -Path "IIsApplicationPool.Name='W3SVC/APPPOOLS/apppoolname'" -Computer "WIN-Computername" -Namespace root\MicrosoftIISv2 -Authentication PacketPrivacy

Where apppoolname is your application pool name.

Where WIN-Computername is your remote/local server name

野鹿林 2024-11-01 00:23:43

使用powershell在服务器上远程执行命令:

Invoke-Command -ComputerName <YOUR_IIS_SERVER_NAME> -ScriptBlock { Restart-WebAppPool -Name <YOUR_APP_POOL_NAME> }

Use powershell to execute command remotely on the server:

Invoke-Command -ComputerName <YOUR_IIS_SERVER_NAME> -ScriptBlock { Restart-WebAppPool -Name <YOUR_APP_POOL_NAME> }
偏爱自由 2024-11-01 00:23:43

我刚刚从Windows XP机器尝试到Windows 2008R2机器。它起作用了。所以你绝对走在正确的道路上。

如果您正在寻找替代方法,请从命令提示符尝试此操作。当它不起作用时,至少错误消息会更具体一些。

wmic /namespace:"\\root\MicrosoftIISv2" /node:"**serverName**" path IISApplicationPool where (name like '%**DefaultAppPool**%') call recycle

I just tried it from a Windows XP machine to Windows 2008R2 machine. It worked. So you are definitely on the right track.

If you are looking for an alternative way, try this from a command prompt. At least the error message will be a little more specific, when it doesn't work.

wmic /namespace:"\\root\MicrosoftIISv2" /node:"**serverName**" path IISApplicationPool where (name like '%**DefaultAppPool**%') call recycle
罪歌 2024-11-01 00:23:43

您是否已在远程计算机上安装并启用了 IIS7 WMI 提供程序?

我认为这个文档 涵盖了您需要的大部分内容。

这涵盖了先决条件以及如何浏览可用的管理选项...确保您能够通过一些调整来重置应用程序池...

Have you got the IIS7 WMI Provider installed and enabled on the remote machine?

I think this doc covers most of what you need.

this covers pre req and how to browse the available management options...sure you'll be able to reset the app pool with a few tweaks...

你是暖光i 2024-11-01 00:23:43

我刚刚偶然发现了这个问题,解决方法如下:
有一个名为 PsExec 的小型 Windows 工具,它基本上为您提供命令行远程访问,并且从那里您可以使用 apppool。您只需从 C# 运行此命令即可

psexec \\192.168.xx.xx %windir%\system32\inetsrv\appcmd recycle apppool /apppool.name:yourapppool

,这是工具: http://technet.microsoft .com/en-us/sysinternals/bb897553.aspx

I just stumbled upon this problem, and here's the fix:
There is a small windows tool called PsExec, which basically gives you command line remote access, and from there you can use apppool. You can just run this command from C#

psexec \\192.168.xx.xx %windir%\system32\inetsrv\appcmd recycle apppool /apppool.name:yourapppool

here's the tool: http://technet.microsoft.com/en-us/sysinternals/bb897553.aspx

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文