Running 7-Zip from within a Powershell script

谁都会走 提交于 2019-11-29 01:09:20

Found this script and adapted it to your needs. Can you please try:

if (-not (test-path "$env:ProgramFiles\7-Zip\7z.exe")) {throw "$env:ProgramFiles\7-Zip\7z.exe needed"} 
set-alias sz "$env:ProgramFiles\7-Zip\7z.exe"  

$Source = "c:\BackupFrom\backMeUp.txt" 
$Target = "c:\BackupFolder\backup.zip"

sz a -mx=9 $Target $Source

put "&" special character before 7z command. Example: &7z ...

Maybe a simpler solution is to run 7-zip on your Powershell via cmd:

cmd /c 7za ...
scarba05

Simply prefix the command with an ampersand

& "C:\Program Files\7-Zip\7z.exe" -mx=9 a "c:\BackupFolder\backup.zip" "c:\BackupFrom\backMeUp.txt"

try to use parameter -file to specify the location of program or script:

-file "C:\Program Files\someting.exe"

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