Running 7-Zip from within a Powershell script

后端 未结 6 682
栀梦
栀梦 2020-12-09 08:10

I\'m trying to use 7-Zip to backup some files inside a Powershell (v2) script.

I have:

$zipPath = \"C:\\Program Files\\7-Zip\\7z.exe\"
[Array]$zipArg         


        
6条回答
  •  -上瘾入骨i
    2020-12-09 08:13

    If you adapt it correctly: Dont forget the "" on "$Target" and avoid $7zipPath in c:\programm files with a space in the path

    Set-Alias 7zip $7zipPath
    
    $Source = "c:\BackupFrom\backMeUp.txt"
    $Target = "c:\BackupFolder\backup.zip"
    
    7zip a -mx=9 "$Target" "$Source"
    

    or

    7z a "$ArchiveName" -t7z '@listfile.txt'
    

提交回复
热议问题