简体   繁体   English

将 a.zip 文件提取到 %AppData%\

[英]extracting a .zip file into %AppData%\

I am looking to use the same Expand-Archive Powershell cmd to unzip the files but instead of using a local location for eg C:\Program Files\Folder\Folder\Folder\Folder" I am trying to extract the zip file into the logged on users profile so that the zip file will unpack it's payload into the users %APPDATA%\Folder\Folder\Folder\Folder\Folder I am looking to use the same Expand-Archive Powershell cmd to unzip the files but instead of using a local location for eg C:\Program Files\Folder\Folder\Folder\Folder" I am trying to extract the zip file into the logged在用户配置文件上,以便 zip 文件将其有效负载解压缩到用户 %APPDATA%\Folder\Folder\Folder\Folder\Folder

I have amended the -DestinationPath but it fails to unzip the contents into the users profile.but seems to just create a file named %APPDATA%我已经修改了 -DestinationPath 但它无法将内容解压缩到用户配置文件中。但似乎只是创建了一个名为 %APPDATA% 的文件

can anybody help?有人可以帮忙吗?

$SourcePath = "nameoffile.zip" $Destination = "C:\Program Files\Folder\Folder\Folder\Folder" Expand-Archive -Path $SourcePath -DestinationPath $Destination –Force write-host "nameofzipfile unzipped successfully" $SourcePath = "nameofile.zip" $Destination = "C:\Program Files\Folder\Folder\Folder\Folder" Expand-Archive -Path $SourcePath -DestinationPath $Destination –强制写入主机 "nameofzipfile 解压成功"

%appdata% is a environment variable used by batch (cmd). %appdata%是批处理 (cmd) 使用的环境变量。 if you want to use the same reference in powershell you use $env:appdata如果你想在 powershell 中使用相同的引用,你可以使用 $env:appdata

$Destination = "$env:appdata\Folder\Folder\Folder\Folder\Folder"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM