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?
Moderator: DosItHelp
Code: Select all
ERROR: a.7z : Cannot open encrypted archive. Wrong password?
Code: Select all
@echo off
set "path=C:\Program Files\7-Zip;%path%"
7z a a.7z -pBatcher "C:\Program Files\7-Zip\7-zip.chm" >nul
7z x a.7z -pBatman 2>&1 | findstr /c:"Wrong password"
if not errorlevel 1 (
echo Wrong password detected
)
pause
Code: Select all
7za.exe t -pWRONGPASS test.7z >nul 2>nul
echo %errorlevel%