当参数[Powershell]给出目标路径时,7zip解压缩失败 [英] 7zip unzipping fails when destination path is given by parameter [Powershell]

查看:119
本文介绍了当参数[Powershell]给出目标路径时,7zip解压缩失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在通过Powershell脚本自动执行安装,并且在解压缩到参数给定的路径而不是进行硬编码时遇到一些问题。
解压缩似乎像应该的那样进行,并且需要一段时间才能处理,但最终没有文件传送到目标文件夹。当我明确说明目标路径时,不会发生这种情况。

I am automating installation through a Powershell script and am having some issues with unzipping to a path given by a parameter rather than being hardcoded. The unzipping seems to go like it is supposed to and takes a while to process but in the end no files are delivered to the destination folder. This does not happen when I explicitly state the destination path.

例如,此代码有效:

& $7zipexe x $zipFile -p$zipFilePassword -oC:\Test -y

但是不是:

& $7zipexe x $zipFile -p$zipFilePassword -o$path -y

其中$ path是一个通过命令行输入或脚本中明确说明的参数。没有区别。我做错了吗?

where $path is either a parameter taken in through the commandline or explictly stated in the script. Makes no difference. Am I doing something wrong?

注意:我已经尝试过用各种引号将参数引起来,但无济于事。 $ 7zipexe,$ zipFile和$ zipPassword都作为参数使用,我也尝试过明确声明它们。错误仅限于目标路径。

Note: I have tried all manner of quotation marks around the parameters but to no avail. $7zipexe, $zipFile and $zipPassword are all taken in as parameters and I have tried to state them explicitly as well. The error is confined to the destination path.

推荐答案

以这种方式尝试:

& $7zipexe x $zipFile `-p$zipFilePassword `-o$path -y

这篇关于当参数[Powershell]给出目标路径时,7zip解压缩失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆