How to detect in 7-Zip fatal error #2 "Wrong password" in windows batch?
Code: Select all
ERROR: a.7z : Cannot open encrypted archive. Wrong password?
Code: Select all
ERROR: a.7z : Cannot open encrypted archive. Wrong password?
Code: Select all
C:\Program Files\7-Zip>7z x %userprofile%\downloads\file.7z
7-Zip 23.01 (x64) : Copyright (c) 1999-2023 Igor Pavlov : 2023-06-20
Scanning the drive for archives:
1 file, 32818 bytes (33 KiB)
Extracting archive: C:\Users\user\downloads\file.7z
--
Path = C:\Users\user\downloads\file.7z
Type = 7z
Physical Size = 32818
Headers Size = 162
Method = LZMA2:19 7zAES
Solid = -
Blocks = 1
Enter password (will not be echoed):
ERROR: Data Error in encrypted file. Wrong password? : file
Sub items Errors: 1
Archives with Errors: 1
Sub items Errors: 1
C:\Program Files\7-Zip>echo %errorlevel%
2
Code: Select all
7z L %userprofile%\downloads\file.7z | find /i "wrong password"