Wie kann ich überprüfen, ob eine Entschlüsselung per 7zip geglückt ist?

1 Antwort

Aus der Dokumentation zu 7zip:

7-Zip returns the following exit codes:
     0 Normal (no errors or warnings detected)
     1 Warning (Non fatal error(s)). For example, some files cannot be read during compressing. So they were not compressed
     2 Fatal error
     7 Bad command line parameters
     8 Not enough memory for operation
     255 User stopped the process with control-C (or similar)

'Ne Beispiel-Batch dazu wäre:

C:\Programme\7-Zip\7z.exe e -p"%Passwort%" C:\Datei.txt
if errorlevel 0: goto alles_ok
:nicht_alles_ok
echo "Fehler...."
goto fertig
:alles_ok
echo "Hat geklappt! YAY!"
:fertig
echo "Ich habe fertig."

P.S.: Du kannst natürlich auch jeden "Exit-Code" einzeln behandeln, um beispielsweise 'ne Meldung auszugeben, was genau nicht geklappt hat, aber wenn's nur um "gut oder nix gut" geht, reicht's den Fall 0 und den Fall "alles andere" zu behandeln.