在powershell中使用7z解压缩文件的命令是什么?
set-alias sz "$env:ProgramFiles\7-Zip\7z.exe"
sz x $zipfilePath $destinationUnzipPath -aoa -r;
Run Code Online (Sandbox Code Playgroud)
该命令工作正常,但它说没有要处理的文件,一切正常而不是解压缩文件?
我不想使用别名、函数或Start-Process
. 在网上浏览了一下后,我发现了这个宝石(我不记得在哪里):
& ${env:ProgramFiles}\7-Zip\7z.exe x $zipfilePath "-o$($destinationUnzipPath)" -y
Run Code Online (Sandbox Code Playgroud)
> $null
如果您不想看到7z的消息,可以在末尾添加一个!
有了 7zip PowerShell 模块,现在就没有麻烦了
# Install 7zip module
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force
Set-PSRepository -Name 'PSGallery' -SourceLocation "https://www.powershellgallery.com/api/v2" -InstallationPolicy Trusted
Install-Module -Name 7Zip4PowerShell -Force
# Extract 7zip file
$sourcefile = "c:\source\sample.7z"
Expand-7Zip -ArchiveFileName $sourcefile -TargetPath 'c:\destinaation'
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
27584 次 |
最近记录: |