Sign up ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

Any help or suggestions will be much appreciated.

share|improve this question
-psecret seems to work as advertised in the help file. – Ярослав Рахматуллин Sep 10 '13 at 17:48
What prompt are you talking about? The only difference between the two commands is an added space. – terdon Sep 10 '13 at 17:50
There must be no space after the -p switch, otherwise the program will prompt for a password. – Ярослав Рахматуллин Sep 10 '13 at 17:54
I 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 Sep 10 '13 at 18:01
To 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. – RazgrizNeedsHelp Sep 10 '13 at 18:05

2 Answers 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.

share|improve this answer

This is moved from the question to an answer on behalf of RazgrizNeedsHelp

I read somewhere about another user having password problems and their workaround was to use a ridiculously long password. I tried one that had 50+ characters and now the script seems to work. It just seems a bit counter-intuitive when the help page uses "secret" as an example password.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.