在服务下运行的Powershell挂起*.zip CopyHere

Tri*_*ion 5 powershell hudson

我正在运行一个Windows服务(Hudson),它反过来生成一个PowerShell进程来运行我的自定义PowerShell命令.我的部分脚本是使用CopyHere解压缩文件.当我在本地运行此脚本时,我会看到在提取和复制文件时弹出一个进度对话框.但是,当它在服务下运行时,它会挂起,否则会出现一个对话框.

这是我脚本的解压缩部分.

# Extract the contents of a zip file to a folder
function Extract-Zip {
    param([string]$zipFilePath, [string]$destination)
    if(test-path($zipFilePath))     {   
        $shellApplication = new-object -com shell.application

        $zipFile = get-item $zipFilePath
        $zipFolder = $shellApplication.NameSpace($zipFile.fullname)

        $destinationFile = get-item $destination
        $destinationFolder = $shellApplication.NameSpace($destinationFile.fullname)

        $destinationFolder.CopyHere($zipFolder.Items())
    }
}
Run Code Online (Sandbox Code Playgroud)

我怀疑,因为它在一个无头的服务过程中运行(没有与桌面交互),所以它不知何故试图显示一个对话框.

有没有解决的办法?

Mic*_*hue 1

查看PowerShell 的文档,看起来-NonInteractive选项可能会有所帮助