简体   繁体   中英

7z cli - how to pass a password with whitespaces?

How to pass a password with whitespaces to the 7z cli argument -p ?

I want to use the cli to extract a archive with a password. The p-argument is a bit ugly, because you have to write the password directly after the argument.

https://sevenzip.osdn.jp/chm/cmdline/switches/password.htm

Following does not work:

7z t test.zip -pmy password
7z t test.zip -p="my password"

Following works, but with limitation:

7z t test.zip -p"my password"

The limitation is your password should not include quotes. Example the following will fail. The password is: "evil quotes"

7z t test.zip -p""evil quotes""

Because the password is now empty.

Is there a way to pass a safe string for the password?

The cli command is generated by JavaScript (NodeJS, exec) not manually executed in cli (windows).

Places double-quotes around the flag AND password. For example:

7z l "-pThis is password" filename.7z

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM