【问题标题】:How correct delete folder in IIS server如何正确删除 IIS 服务器中的文件夹
【发布时间】:2014-11-30 17:59:39
【问题描述】:

我在 powershell 中编写了函数,删除 IIS 中的虚拟文件夹,删除物理路径,将存档解压缩到文件夹,并在 IIS 中使用旧名称创建虚拟路径。步骤 2 中的问题。脚本尝试删除文件和文件夹。

...
get-childitem ($pathToIIs + "*") -recurse | remove-item -Force -recurse
...

Powershell 抛出错误:

无法删除项目 C:\inetpub\test\css:目录不为空。 + CategoryInfo : WriteError: (css:DirectoryInfo) [Remove-Item], I 异常 + FullyQualifiedErrorId : RemoveFileSystemItemIOError,Microsoft.PowerShell .Commands.RemoveItemCommand + PSComputerName : test.cloudapp.net

如果理解正确,停止和启动 IIS 是个坏主意。那么如何修复这个错误呢?

【问题讨论】:

    标签: powershell iis


    【解决方案1】:

    必须停止 IIS 才能删除被 IIS 锁定的文件:

    ...
    iisreset /stop
    get-childitem ($pathToIIs + "*") -recurse | remove-item -Force -recurse
    iisreset /start
    ...
    

    停止 IIS 显然会暂时阻止您的服务器提供网页。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2023-03-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多