7zip unzipping fails when destination path is given by parameter [Powershell]

放肆的年华 提交于 2019-12-02 15:36:14

问题


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.

For example, this code works:

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

This, however does not:

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

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?

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.


回答1:


Try it this way:

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


来源:https://stackoverflow.com/questions/23699690/7zip-unzipping-fails-when-destination-path-is-given-by-parameter-powershell

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!