问题
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