7-Zip command line -p switch is not working according to the help page
Solution 1
To fully script-automate:
Create:
7z -mhc=on -mhe=on -pPasswordHere a %ZipDest% %WhatYouWantToZip%
Unzip:
7z x %ZipFile% -pPasswordHere
https://stackoverflow.com/a/39826601/3441182
Solution 2
I was having issues with the -p
also. I found that I had a special character in the password and it needed to be escaped.
If you have a comma (,
) or a exclamation point(!
) you would need to escape the character like this:
,
would be ^,
and !
would be ^!
Look here for more info.
Related videos on Youtube
RazgrizNeedsHelp
Updated on September 18, 2022Comments
-
RazgrizNeedsHelp over 1 year
I want to be able to automate the encryption of the file type .pcapng in a Windows batch script. My current problem is that I get an error when extracting the encrypted file saying something along the lines "error. Wrong Password?"
My script code:
7z a -t7z captures.7z -pINSERTPASSWORDHERE -mhe *.pcapng
The compression works as expected and this format for the
-p
switch was taken from 7-Zip's help page. But again the set password does not work, giving the error described above. After some playing I managed to get the code below to work... However I don't want there to be a prompt for a password; I want the password set using the value in the script.7z a -t7z captures.7z -p INSERTPASSWORDHERE -mhe *.pcapng
-
Ярослав Рахматуллин over 10 yearsThere must be no space after the -p switch, otherwise the program will prompt for a password.
-
RazgrizNeedsHelp over 10 yearsI realize that but it was the only way I could get a set password to work. I was more so wondering why -pInsertPassword wasn't letting me open any encrypted file.
-
RazgrizNeedsHelp over 10 yearsTo further clarify my actual password had a mix of letters of different case and numbers as well. After more testing it seems that it doesn't like a password unless its all characters or numbers.
-
-
fixer1234 about 8 yearsThis was moved from the question to an answer on behalf of RazgrizNeedsHelp