7z Archiv Packen / Entpacken

<p>Ein Sicherungsscript das z.B. per "Geplante Tasks" ausgeführt werden kann.</p>
<p>Viele Parameter von 7z sind nicht so einfach zu durchschauen.</p>
<p>Ein paar sinnvolle werden in diesem Script aufgezeigt / verwenden.</p>
<p>&nbsp;</p>
<p>Das Script kann einfach per <strong>cscript 7z.vbs</strong> gestartet werden. Dann müssen allerdings die Parameter im Script Bereich "Konfiguration" angepasst werden.</p>
<p>Genauso kann das Script mit Parameter gestartet werden <strong>cscript7z .vbs -p"geht keinen was an ;-)" c:\quelle d:\Sicherung</strong></p>
<p>Das Script durchsucht die gängigen Pfade nach der 7z.exe-Datei<strong>. </strong>Im Notfall in der Funktion <strong>getSevenZipProg()</strong> anpassen.</p>
<div>
<div>
<div><strong>Script-Link: </strong><a href="/download/wsh/7z.vbs" target="_blank" title="geziptes Script" data-cke-saved-href="download/wsh/7z.vbs"><img src="/images/stories/windows/thumbs/script.jpg" alt="script" width="16" height="19" style="vertical-align: text-bottom; border: 0px none;" data-cke-saved-src="images/stories/windows/thumbs/script.jpg" /></a></div>
<div>&nbsp;</div>
</div>
</div>
<!-- HTML generated using hilite.me -->
<div style="background: #ffffff; overflow: auto; width: auto; border: solid gray; border-width: .1em .1em .1em .8em; padding: .2em .6em;">
<pre style="margin: 0; line-height: 125%;"><span style="color: #000080; font-weight: bold;">Option</span> Explicit
<span style="color: #008800; font-style: italic;">'...........................................................................................................................................................</span>
<span style="color: #008800; font-style: italic;">' 7z.vbs 1.05 Autor: Michael Hölldobler hoelldobler[at]alant.de</span>
<span style="color: #008800; font-style: italic;">' Script benötigt eine Version des 7z-Packers</span>
<span style="color: #008800; font-style: italic;">' Packen: 7z.vbs &lt;command&gt; -&lt;Parameter1&gt; -&lt;Parameter2&gt; -&lt;..&gt;. Pfad\Unterpfad\[ArchivName.7z] Quelle1 &lt;Quelle2&gt; &lt;..&gt;</span>
<span style="color: #008800; font-style: italic;">' Entpacken: 7z.vbs x &lt;-p&gt; Entpack-Ziel-Pfad Archiv.7z</span>
<span style="color: #008800; font-style: italic;">'</span>
<span style="color: #008800; font-style: italic;">' Commands: Ohne führendes Minuszeichen. Wird kein Command angegeben wird u angenommen wenn es schon ein Archiv gibt</span>
<span style="color: #008800; font-style: italic;">' a Dateien zum Archiv hinzufügen [Optional] </span>
<span style="color: #008800; font-style: italic;">' u update Achiv differnziell (differenziell) [Optional]</span>
<span style="color: #008800; font-style: italic;">' m Mirror Quelle auf Archiv spiegeln</span>
<span style="color: #008800; font-style: italic;">' x Dateien entpacken (e) Alle in den Basisordner entpacken</span>
<span style="color: #008800; font-style: italic;">' </span>
<span style="color: #008800; font-style: italic;">' Parameter: &lt;Zusätzliche Angaben zu Parameter. !ohne eckige Klammern!&gt;</span>
<span style="color: #008800; font-style: italic;">' -p&lt;"?"&gt; Passwort</span>
<span style="color: #008800; font-style: italic;">' -h&lt;"?"&gt; Passwort mit verborgener Ordnerstrucktur (-mhe)</span>
<span style="color: #008800; font-style: italic;">' -b Nur Basisverzeichnis der Quellen (-r-)</span>
<span style="color: #008800; font-style: italic;">' -v&lt;?&gt; maximale Dateigröße danach wird gesplittet z.B -v100m -v1g (nicht kombinierbar mit "u")</span>
<span style="color: #008800; font-style: italic;">' -x Selbstentpackendes Archiv.exe erzeugen (-sfx)</span>
<span style="color: #008800; font-style: italic;">' -t&lt;?&gt; fileFormat 7z (default) -tz ZIP</span>
<span style="color: #008800; font-style: italic;">' -i&lt;?&gt; Nur diese Dateien einschließen z.B. -i*.doc (mehrfach möglich)</span>
<span style="color: #008800; font-style: italic;">' -x&lt;?&gt; Diese Datei ausschließen z.B. -x*.tmp -x*.mp3 (mehrfach möglich)</span>
<span style="color: #008800; font-style: italic;">' Eine Filter wie unter Windows mit *.* funtioniert nur bedingt. Wenn es einen Ordner mit einem Puntk im Namen gibt wird diese ebenfallst archiviert</span>
<span style="color: #008800; font-style: italic;">' Der Filter wird von * auf *.* gesetzt und der Unter-Ordner mit einem Punkt im Namen in die auszuschließenden Dateien aufgenommen.</span>
<span style="color: #008800; font-style: italic;">' -c&lt;?&gt; Kompressieronsrate 0 (keine) .. 5 (default) .. 9 (maximale)</span>
<span style="color: #008800; font-style: italic;">' -n&lt;?&gt; Archivname. Kann aber auch im Archiv-Pfad angegeben werden.</span>
<span style="color: #008800; font-style: italic;">' -v&lt;?&gt; Dateigrö0e der einzelnen Archiv-Dateien. Es kann dann aber immer nur ein Vollbackup gemacht werden!</span>
<span style="color: #008800; font-style: italic;">' -u&lt;?&gt; Anzahl der differentiellen Backups (-up0) </span>
<span style="color: #008800; font-style: italic;">' -o&lt;?&gt; Ausgabe-Ordner zum Entpacken</span>
<span style="color: #008800; font-style: italic;">'</span>
<span style="color: #008800; font-style: italic;">' Archiv-Pfad </span>
<span style="color: #008800; font-style: italic;">' Immer als erster Datei-/ Ordner-Pfad angegeben z.B. c:\backup\archiv </span>
<span style="color: #008800; font-style: italic;">' Wird die Endung mit angegeben z.B c:\backup\archiv.7z wird der Dateiname Archiv sein</span>
<span style="color: #008800; font-style: italic;">' Ohne Endung wird angenommen das es der Pfadname ist und der Dateiname wird aus der Valirablen "archivName" erstellt</span>
<span style="color: #008800; font-style: italic;">' Quelle[n] </span>
<span style="color: #008800; font-style: italic;">' Immer nach dem Archiv-Pfad angeben z.B. c:\meineDaten c:\meineDaten\* </span>
<span style="color: #008800; font-style: italic;">'</span>
<span style="color: #008800; font-style: italic;">' Generell gilt:</span>
<span style="color: #008800; font-style: italic;">' Alle Parameter mit Leerzeichen kapseln -&gt; "mit Leerzeichen"</span>
<span style="color: #008800; font-style: italic;">' Optionale Parameter werden wie unten im Konfigurations-Teil verwendet, wenn nichts angegeben</span>
<span style="color: #008800; font-style: italic;">' Das Script kann auch ohne Parameter aufgerufen werden. Damm müssen aber alle Parameter im Konfiguration-Teil eingetragen sein</span>
<span style="color: #008800; font-style: italic;">' Es werden nur die s.O. in ()Klammern angegebenen originalen Parameter mit ausgewertet</span>
<span style="color: #008800; font-style: italic;">' Bezugsquellew: http://www.7zip.org/</span>
<span style="color: #008800; font-style: italic;">'...........................................................................................................................................................</span>

<span style="color: #000080; font-weight: bold;">Dim</span> sourceFolders, excludeFilter, includeFilter, sevenZipProg
<span style="color: #000080; font-weight: bold;">dim</span> destination, cmd, password, fileFormat, filesize, noSubdir, compression, fileSuffix
<span style="color: #000080; font-weight: bold;">Dim</span> fso, wsh, sfx, noListing, updateAchiv, outputDir, destinationDiff, quiet
<span style="color: #000080; font-weight: bold;">Dim</span> oArgs, extract, f, archivName, diffName, diffCount
<span style="color: #000080; font-weight: bold;">dim</span> s, stmp2, s3, stmp, i, j, k

<span style="color: #008800; font-style: italic;">'--------------------------------------------------------------------------------------</span>
<span style="color: #008800; font-style: italic;">'----- Konfiguration ------------------------------------------------------------------</span>
<span style="color: #008800; font-style: italic;">'--------------------------------------------------------------------------------------</span>

<span style="color: #008800; font-style: italic;">' Quellverzeichnisse</span>
<span style="color: #008800; font-style: italic;">' Wichtig: Bei den Quellpfaden keinen abschließende Backslashes angeben !</span>
<span style="color: #008800; font-style: italic;">' ---------------------------------------------------------------------------</span>
sourceFolders = Array(<span style="color: #0000ff;">"d:\persoenliche Daten"</span>, <span style="color: #0000ff;">"c:\test"</span>) <span style="color: #008800; font-style: italic;">'"c:\data","c:\Users\[user]\Documents", "d:\data"</span>

<span style="color: #008800; font-style: italic;">' Ausschluss-Dateien</span>
<span style="color: #008800; font-style: italic;">' ------------------</span>
excludeFilter = Array()

<span style="color: #008800; font-style: italic;">' Nur bestimmte Dateitypen packen</span>
<span style="color: #008800; font-style: italic;">' -&gt; "" "*" alle Dateien außer excludeFilter</span>
<span style="color: #008800; font-style: italic;">' -&gt; "*.doc", "*.xls", "*.pdf"</span>
<span style="color: #008800; font-style: italic;">' -------------------------------</span>
includeFilter = Array(<span style="color: #0000ff;">"*"</span>)

<span style="color: #008800; font-style: italic;">' Das Zielverzeichnis</span>
<span style="color: #008800; font-style: italic;">' -------------------</span>
destination = <span style="color: #0000ff;">"x:\testbackup"</span>
<span style="color: #008800; font-style: italic;">'destination = ""</span>

<span style="color: #008800; font-style: italic;">' Arrchiv-Name für Vollbackup </span>
<span style="color: #008800; font-style: italic;">' ---------------------------------------------------------------------------------------------------------</span>
archivName = <span style="color: #0000ff;">"Sicherung"</span>

<span style="color: #008800; font-style: italic;">' Archiv-Namenserweiterung bei differenziellem Backup in das Archiv</span>
<span style="color: #008800; font-style: italic;">'-------------------------------------------------------------------</span>
diffName = <span style="color: #0000ff;">"_diff_?"</span>
<span style="color: #008800; font-style: italic;">'max. Anzahl der differenziellem Backup's. Leer oder 0 wird nur ein diff Backup erstellt und immer wieder dieses verwendet</span>
diffCount = <span style="color: #0000ff;">"50"</span>
<span style="color: #008800; font-style: italic;">'Platzhalter für den Zähler im diff. Backup</span>
<span style="color: #000080; font-weight: bold;">Const</span> diffWildcard = <span style="color: #0000ff;">"?"</span>

<span style="color: #008800; font-style: italic;">' Archiv-Format</span>
<span style="color: #008800; font-style: italic;">' -------------</span>
<span style="color: #008800; font-style: italic;">' -&gt; "7z" oder "zip"</span>
fileFormat = <span style="color: #0000ff;">"7z"</span>

<span style="color: #008800; font-style: italic;">' Passwort angeben</span>
<span style="color: #008800; font-style: italic;">' -&gt; "?" -&gt; öffnet ein Eingabefenster</span>
<span style="color: #008800; font-style: italic;">' -----------------------------------</span>
password = <span style="color: #0000ff;">""</span> <span style="color: #008800; font-style: italic;">'"0815 ist als Passwort nicht OK"</span>

<span style="color: #008800; font-style: italic;">' Blick ins Archiv verwehren (Dateiliste)</span>
<span style="color: #008800; font-style: italic;">' -&gt; False oder True - Explorer kann nicht hineinschauen (Sowieso nur bei *.zip)</span>
<span style="color: #008800; font-style: italic;">' ------------------------------------------------------------------------------</span>
noListing = <span style="color: #000080; font-weight: bold;">False</span>

<span style="color: #008800; font-style: italic;">' maximale Datei-Größe</span>
<span style="color: #008800; font-style: italic;">' -&gt; "" 100k (Kilobyte) 100m (Megabyte) 2g (Gigabytes)</span>
<span style="color: #008800; font-style: italic;">' ----------------------------------------------------</span>
filesize = <span style="color: #0000ff;">""</span>

<span style="color: #008800; font-style: italic;">'Kompressionsrate</span>
<span style="color: #008800; font-style: italic;">' -&gt; 5 Vorgabe 0 (keine), 1, 3 ,(5 default) ,7 ,9</span>
<span style="color: #008800; font-style: italic;">'--------------------------------------</span>
compression = <span style="color: #0000ff;">""</span>

<span style="color: #008800; font-style: italic;">' Selbstentpackendes Archiv erzeugen</span>
<span style="color: #008800; font-style: italic;">' -&gt; False oder True (exe wird erzeugt. 7zip wird nicht mehr benötigt zu eintpacken des Archivs)</span>
<span style="color: #008800; font-style: italic;">' ----------------------------------------------------------------------------------------------</span>
sfx = <span style="color: #000080; font-weight: bold;">False</span>

<span style="color: #008800; font-style: italic;">'Keine Unterverzeichnisse der Quellverzeichnisse sichern</span>
<span style="color: #008800; font-style: italic;">' -&gt; True kein Unterverzeichnisse archivieren. Wurde in der Quellenangabe nur der * angegeben muss dieser auf *.* erweitert werden</span>
<span style="color: #008800; font-style: italic;">' -&gt; False =&gt; Mit Unterverzeichnisen sichern</span>
<span style="color: #008800; font-style: italic;">'-------------------------------------------------------</span>
noSubdir = <span style="color: #000080; font-weight: bold;">false</span>

<span style="color: #008800; font-style: italic;">' entpacken (extrahieren) in folgendes Verzeichnis</span>
<span style="color: #008800; font-style: italic;">'--------------------------------------------------</span>
outputDir = <span style="color: #0000ff;">""</span>

<span style="color: #008800; font-style: italic;">'Keine Popups ausgeben</span>
<span style="color: #008800; font-style: italic;">'---------------------</span>
quiet = <span style="color: #000080; font-weight: bold;">False</span>

<span style="color: #008800; font-style: italic;">'Vorgegebener Befehl</span>
<span style="color: #008800; font-style: italic;">'---------------------</span>
cmd = <span style="color: #0000ff;">""</span>
<span style="color: #008800; font-style: italic;">'--------------------------------------------------------------------------------------</span>
<span style="color: #008800; font-style: italic;">'----- ENDE Konfiguration -------------------------------------------------------------</span>
<span style="color: #008800; font-style: italic;">'--------------------------------------------------------------------------------------</span>

<span style="color: #000080; font-weight: bold;">Const</span> cSpace = <span style="color: #0000ff;">" "</span>
<span style="color: #000080; font-weight: bold;">Const</span> cBSlash = <span style="color: #0000ff;">"\"</span>
<span style="color: #000080; font-weight: bold;">Const</span> cSlash = <span style="color: #0000ff;">"/"</span>
<span style="color: #000080; font-weight: bold;">Const</span> cDQ = <span style="color: #0000ff;">""""</span>
<span style="color: #000080; font-weight: bold;">Const</span> cC = <span style="color: #0000ff;">"%COMSPEC% /C "</span>
<span style="color: #000080; font-weight: bold;">Const</span> cHeader = <span style="color: #0000ff;">"7-Zip Backup-Script"</span>
<span style="color: #000080; font-weight: bold;">Set</span> fso = CreateObject(<span style="color: #0000ff;">"Scripting.FileSystemObject"</span>)
<span style="color: #000080; font-weight: bold;">Set</span> wsh = CreateObject(<span style="color: #0000ff;">"WScript.Shell"</span>)
<span style="color: #000080; font-weight: bold;">Set</span> oArgs = WScript.Arguments

<span style="color: #008800; font-style: italic;">' 7z-Pfad ermitteln</span>
getSevenZipProg()

<span style="color: #008800; font-style: italic;">' Startparameter verarbeiten</span>
openArgs()
setPara()
run7z()

<span style="color: #000080; font-weight: bold;">set</span> fso = <span style="color: #000080; font-weight: bold;">nothing</span>
<span style="color: #000080; font-weight: bold;">Set</span> wsh = <span style="color: #000080; font-weight: bold;">nothing</span>
<span style="color: #000080; font-weight: bold;">Set</span> oArgs = <span style="color: #000080; font-weight: bold;">nothing</span>

<span style="color: #008800; font-style: italic;">'---------------------------------------------------------------------------------------</span>
<span style="color: #008800; font-style: italic;">'--- Funktionen ------------------------------------------------------------------------</span>
<span style="color: #008800; font-style: italic;">'---------------------------------------------------------------------------------------</span>

<span style="color: #000080; font-weight: bold;">Function</span> openArgs()
<span style="color: #000080; font-weight: bold;">Dim</span> sOA, i, j, k
<span style="color: #000080; font-weight: bold;">Dim</span> fDestination
fDestination = <span style="color: #000080; font-weight: bold;">False</span>

<span style="color: #000080; font-weight: bold;">If</span> oArgs.Count = <span style="color: #0000ff;">0</span> <span style="color: #000080; font-weight: bold;">Then</span>
<span style="color: #008800; font-style: italic;">'Abfangen wenn kein Argument übergeben wurde</span>
<span style="color: #000080; font-weight: bold;">Else</span>
<span style="color: #000080; font-weight: bold;">For</span> i = <span style="color: #0000ff;">0</span> <span style="color: #000080; font-weight: bold;">To</span> oArgs.Count - <span style="color: #0000ff;">1</span>
<span style="color: #000080; font-weight: bold;">On</span> <span style="color: #000080; font-weight: bold;">Error</span> <span style="color: #000080; font-weight: bold;">Resume</span> <span style="color: #000080; font-weight: bold;">Next</span>
sOA = LCase(oArgs(i))
<span style="color: #000080; font-weight: bold;">select</span> <span style="color: #000080; font-weight: bold;">case</span> sOA
<span style="color: #000080; font-weight: bold;">case</span> <span style="color: #0000ff;">"a"</span>, <span style="color: #0000ff;">"u"</span>,<span style="color: #0000ff;">"m"</span>, <span style="color: #0000ff;">"x"</span>, <span style="color: #0000ff;">"e"</span>: cmd = sOA
<span style="color: #000080; font-weight: bold;">case</span> <span style="color: #0000ff;">"b"</span>, <span style="color: #0000ff;">"h"</span>,<span style="color: #0000ff;">"l"</span>, <span style="color: #0000ff;">"rn"</span>, <span style="color: #0000ff;">"t"</span>: cmd = sOA <span style="color: #008800; font-style: italic;">'b (Benchmark): h (Hash) command, l (List contents of archive), rn (Rename), t (Test integrity of archive)</span>
<span style="color: #000080; font-weight: bold;">case</span> <span style="color: #000080; font-weight: bold;">Else</span>
<span style="color: #000080; font-weight: bold;">if</span> Left(sOA, <span style="color: #0000ff;">1</span>) = <span style="color: #0000ff;">"/"</span> <span style="color: #000080; font-weight: bold;">Then</span> sOA = replace(sOA, <span style="color: #0000ff;">"/"</span>, <span style="color: #0000ff;">"-"</span>, <span style="color: #0000ff;">1</span>, <span style="color: #0000ff;">1</span>, vbTextCompare) <span style="color: #008800; font-style: italic;">'/ ist auch erlaubt wird hier in ein Parameter-Steuerzeichen umgewandelt</span>
<span style="color: #000080; font-weight: bold;">if</span> Left(sOA, <span style="color: #0000ff;">1</span>) = <span style="color: #0000ff;">"-"</span> <span style="color: #000080; font-weight: bold;">Then</span> <span style="color: #008800; font-style: italic;">'Parameter</span>
sTmp = Left(sOA, <span style="color: #0000ff;">2</span>)
stmp2 = Right(oArgs(i),Len(oArgs(i)) - <span style="color: #0000ff;">2</span>)
<span style="color: #000080; font-weight: bold;">Select</span> <span style="color: #000080; font-weight: bold;">Case</span> sTmp
<span style="color: #000080; font-weight: bold;">case</span> <span style="color: #0000ff;">"-b"</span>: noSubdir = <span style="color: #000080; font-weight: bold;">True</span>
<span style="color: #000080; font-weight: bold;">case</span> <span style="color: #0000ff;">"-c"</span>: compression = stmp2
<span style="color: #000080; font-weight: bold;">Case</span> <span style="color: #0000ff;">"-h"</span>: fNoListing = <span style="color: #000080; font-weight: bold;">true</span>
<span style="color: #000080; font-weight: bold;">Case</span> <span style="color: #0000ff;">"-i"</span> <span style="color: #008800; font-style: italic;">'Datei-Filter +</span>
<span style="color: #000080; font-weight: bold;">if</span> stmp2 &lt;&gt; vbnullString <span style="color: #000080; font-weight: bold;">then</span>
j = UBound(includeFilter) + <span style="color: #0000ff;">1</span>
<span style="color: #000080; font-weight: bold;">ReDim</span> Preserve includeFilter(j)
includeFilter(j) = stmp2
<span style="color: #000080; font-weight: bold;">end</span> <span style="color: #000080; font-weight: bold;">if</span>
<span style="color: #000080; font-weight: bold;">case</span> <span style="color: #0000ff;">"-n"</span>: archivName = stmp2
<span style="color: #000080; font-weight: bold;">case</span> <span style="color: #0000ff;">"-o"</span>: outputDir = stmp2
<span style="color: #000080; font-weight: bold;">Case</span> <span style="color: #0000ff;">"-p"</span> <span style="color: #008800; font-style: italic;">'Passwort</span>
<span style="color: #000080; font-weight: bold;">If</span> stmp2 = <span style="color: #0000ff;">"?"</span> <span style="color: #000080; font-weight: bold;">Then</span> stmp2 = InputBox(<span style="color: #0000ff;">"Passwort eingeben"</span> &amp; VbCrLf &amp; <span style="color: #0000ff;">"Wird nicht verschlüsselt angezeigt"</span>, <span style="color: #0000ff;">"Passwort-Abfrage"</span>)
password = stmp2
<span style="color: #000080; font-weight: bold;">case</span> <span style="color: #0000ff;">"-r"</span>: <span style="color: #000080; font-weight: bold;">if</span> stmp2 = <span style="color: #0000ff;">"-"</span> <span style="color: #000080; font-weight: bold;">then</span> noSubdir = <span style="color: #000080; font-weight: bold;">True</span>
<span style="color: #000080; font-weight: bold;">Case</span> <span style="color: #0000ff;">"-t"</span> <span style="color: #008800; font-style: italic;">'Packformat</span>
<span style="color: #000080; font-weight: bold;">If</span> stmp2 = <span style="color: #0000ff;">"z"</span> <span style="font-weight: bold;">or</span> stmp2 = <span style="color: #0000ff;">"zip"</span> <span style="color: #000080; font-weight: bold;">Then</span>
fileFormat = <span style="color: #0000ff;">"zip"</span>
<span style="color: #000080; font-weight: bold;">Else</span>
fileFormat = <span style="color: #0000ff;">"7z"</span>
<span style="color: #000080; font-weight: bold;">End</span> <span style="color: #000080; font-weight: bold;">If</span>
<span style="color: #000080; font-weight: bold;">Case</span> <span style="color: #0000ff;">"-u"</span>:
<span style="color: #000080; font-weight: bold;">if</span> IsNumeric(stmp2) <span style="color: #000080; font-weight: bold;">then</span>
diffCount = stmp2 <span style="color: #008800; font-style: italic;">'Anzahl Backups</span>
<span style="color: #000080; font-weight: bold;">elseif</span> stmp2 = <span style="color: #0000ff;">"q0"</span> <span style="color: #000080; font-weight: bold;">then</span>
updateAchiv = <span style="color: #0000ff;">" -uq0"</span> <span style="color: #008800; font-style: italic;">'Mirror</span>
<span style="color: #000080; font-weight: bold;">end</span> <span style="color: #000080; font-weight: bold;">if</span>
<span style="color: #000080; font-weight: bold;">Case</span> <span style="color: #0000ff;">"-v"</span>: filesize = stmp2 <span style="color: #008800; font-style: italic;">'Dateigröße nachdem gesplittet wird</span>
<span style="color: #000080; font-weight: bold;">Case</span> <span style="color: #0000ff;">"-x"</span> <span style="color: #008800; font-style: italic;">'Datei-Filter -</span>
<span style="color: #000080; font-weight: bold;">if</span> stmp2 &lt;&gt; vbnullString <span style="color: #000080; font-weight: bold;">then</span>
j = UBound(excludeFilter) + <span style="color: #0000ff;">1</span>
<span style="color: #000080; font-weight: bold;">ReDim</span> Preserve excludeFilter(j)
excludeFilter(j) = stmp2
<span style="color: #000080; font-weight: bold;">end</span> <span style="color: #000080; font-weight: bold;">if</span>
<span style="color: #000080; font-weight: bold;">case</span> <span style="color: #0000ff;">"-?"</span>:
s = <span style="color: #0000ff;">"Commands: Ohne führendes Minuszeichen. Wird kein Command angegeben wird in das Archiv gespeichert"</span> &amp; vbCrLf &amp; _
<span style="color: #0000ff;">" a Dateien zum Archiv hinzufügen [Optional]"</span> &amp; vbCrLf &amp; _
<span style="color: #0000ff;">" u update Achiv differnziell (differenziell) [Optional]"</span> &amp; vbCrLf &amp; _
<span style="color: #0000ff;">" m Mirror Quelle auf Archiv spiegeln"</span> &amp; vbCrLf &amp; _
<span style="color: #0000ff;">" e Dateien entpacken (e) Alle in den Basisordner entpacken"</span> &amp; vbCrLf &amp; _
<span style="color: #0000ff;">"Parameter: Zusätzliche Angaben ohne ekige Klammern!"</span> &amp; vbCrLf &amp; _
<span style="color: #0000ff;">" -p&lt;""?""&gt; Passwort (Leerzeichen müssen gekapselt werden "" "")"</span> &amp; vbCrLf &amp; _
<span style="color: #0000ff;">" -h&lt;""?""&gt; Passwort mit verborgener Ordnerstrucktur (-mhe)"</span> &amp; vbCrLf &amp; _
<span style="color: #0000ff;">" -b Nur Basisverzeichnis der Quellen (-r-)"</span> &amp; vbCrLf &amp; _
<span style="color: #0000ff;">" -v&lt;?&gt; maximale Dateigröße danach wird gesplittet z.B. -v100m -v1g"</span> &amp; vbCrLf &amp; _
<span style="color: #0000ff;">" (nicht kombinierbar mit 'u')"</span> &amp; vbCrLf &amp; _
<span style="color: #0000ff;">" -x Selbstentpackendes Archiv.exe erzeugen (-sfx)"</span> &amp; vbCrLf &amp; _
<span style="color: #0000ff;">" -t&lt;?&gt; Dateiformat 7z (default) -tz ZIP"</span> &amp; vbCrLf &amp; _
<span style="color: #0000ff;">" -i&lt;?&gt; Nur diese Dateien einschließen z.B. -i*.doc (mehrfach möglich)"</span> &amp; vbCrLf &amp; _
<span style="color: #0000ff;">" -x&lt;?&gt; Diese Datei ausschließen z.B. -x*.tmp -x*.mp3 (mehrfach möglich)"</span> &amp; vbCrLf &amp; _
<span style="color: #0000ff;">" Eine Filter wie unter Windows mit *.* funtioniert nur bedingt."</span> &amp; vbCrLf &amp; _
<span style="color: #0000ff;">" Wenn es einen Ordner mit einem Puntk im Namen gibt wird dieser"</span> &amp; vbCrLf &amp; _
<span style="color: #0000ff;">" ebenfallst archiviert. Der Filter wird von * auf *.* gesetzt und"</span> &amp; vbCrLf &amp; _
<span style="color: #0000ff;">" der Unter-Ordner mit einem Punkt im Namen in die auszuschließenden"</span> &amp; vbCrLf &amp; _
<span style="color: #0000ff;">" Dateien aufgenommen."</span> &amp; vbCrLf &amp; _
<span style="color: #0000ff;">" -c&lt;?&gt; Kompressieronsrate 1 3 (5) 7 9"</span> &amp; vbCrLf &amp; _
<span style="color: #0000ff;">" -v&lt;?&gt; Dateigrö0e der einzelnen Archiv-Dateien. Es kann dann aber immer nur"</span> &amp; vbCrLf &amp; _
<span style="color: #0000ff;">" ein Vollbackup gemacht werden!"</span> &amp; vbCrLf &amp; _
<span style="color: #0000ff;">" -u&lt;?&gt; Anzahl der differentiellen Backups"</span> &amp; vbCrLf &amp; _
<span style="color: #0000ff;">" -n&lt;?&gt; Archivname kann aber auch im Archiv-Pfad angegeben werden."</span> &amp; vbCrLf &amp; _
<span style="color: #0000ff;">" Archiv-Pfad c:\backup\archiv"</span> &amp; vbCrLf &amp; _
<span style="color: #0000ff;">" Mit angegebener Endung z.B c:\backup\archiv.7z"</span> &amp; vbCrLf &amp; _
<span style="color: #0000ff;">" wird der Dateiname Archiv sein"</span> &amp; vbCrLf &amp; _
<span style="color: #0000ff;">" Wird keien Endung angegeben wird angenommen es ist der Pfadname"</span> &amp; vbCrLf &amp; _
<span style="color: #0000ff;">" -o Ausgabe-Ordner zum entpacken"</span> &amp; vbCrLf &amp; _
<span style="color: #0000ff;">"scsript 7z.vbs a -p""gheimes Passwort"" -narchiv.7z c:\backuporder c:\quelle1 ""c:\2. quelle"""</span> &amp; vbCrLf &amp; _
<span style="color: #0000ff;">"scsript 7z.vbs -narchiv.7z c:\backuporder c:\quelle1 ""c:\2. quelle"""</span>
wscript.echo s
wscript.quit
<span style="color: #000080; font-weight: bold;">Case</span> <span style="color: #000080; font-weight: bold;">Else</span>
sTmp = Left(sOA, <span style="color: #0000ff;">3</span>)
<span style="color: #000080; font-weight: bold;">select</span> <span style="color: #000080; font-weight: bold;">case</span> sOA
<span style="color: #000080; font-weight: bold;">case</span> <span style="color: #0000ff;">"-mhe"</span>: fNoListing = <span style="color: #000080; font-weight: bold;">True</span>
<span style="color: #000080; font-weight: bold;">case</span> <span style="color: #0000ff;">"-sfx"</span>: sfx = <span style="color: #000080; font-weight: bold;">True</span> <span style="color: #008800; font-style: italic;">'Selbstentpackendes Archiv</span>
<span style="color: #000080; font-weight: bold;">case</span> <span style="color: #0000ff;">"-mhe"</span>: fNoListing = <span style="color: #000080; font-weight: bold;">True</span>
<span style="color: #000080; font-weight: bold;">End</span> <span style="color: #000080; font-weight: bold;">select</span>
<span style="color: #000080; font-weight: bold;">End</span> <span style="color: #000080; font-weight: bold;">select</span>
<span style="color: #000080; font-weight: bold;">else</span>
<span style="color: #008800; font-style: italic;">'Da die Command's nur einem Buchstaben bestehen und diese schon abgefangen wurdern</span>
<span style="color: #008800; font-style: italic;">'wird erwartet dass alle Parameter mit einem "-" bzw "/" beginnen</span>
<span style="color: #008800; font-style: italic;">'Die erste Angabe ist das Ziel-Archiv alle weiteren sind Quellen</span>
<span style="color: #000080; font-weight: bold;">If</span> <span style="color: #000080; font-weight: bold;">Not</span> fDestination <span style="color: #000080; font-weight: bold;">Then</span>
<span style="color: #000080; font-weight: bold;">if</span> right(sOA, <span style="color: #0000ff;">1</span>) = cBSlash <span style="color: #000080; font-weight: bold;">then</span>
destination = left(sOA, len(sOA) - <span style="color: #0000ff;">1</span>)
<span style="color: #000080; font-weight: bold;">elseif</span> right(sOA, <span style="color: #0000ff;">2</span>) = <span style="color: #0000ff;">"7z"</span> <span style="color: #000080; font-weight: bold;">then</span>
fileFormat = <span style="color: #0000ff;">"7z"</span>
archivName = ExtractFileName(sOA, <span style="color: #000080; font-weight: bold;">true</span>)
j = InStrRev (sOA, archivName, -<span style="color: #0000ff;">1</span>, vbTextCompare)

destination = left(sOA, j - <span style="color: #0000ff;">2</span>)
fileSuffix = <span style="color: #0000ff;">".7z"</span>
<span style="color: #000080; font-weight: bold;">elseif</span> right(sOA, <span style="color: #0000ff;">3</span>) = <span style="color: #0000ff;">"zip"</span> <span style="color: #000080; font-weight: bold;">then</span>
fileFormat = <span style="color: #0000ff;">"zip"</span>
archivName = ExtractFileName(sOA, <span style="color: #000080; font-weight: bold;">true</span>)
j = InStrRev (sOA, archivName, -<span style="color: #0000ff;">1</span>, vbTextCompare)
destination = left(sOA, j - <span style="color: #0000ff;">2</span>)
fileSuffix = <span style="color: #0000ff;">".zip"</span>
<span style="color: #000080; font-weight: bold;">else</span>
destination = sOA
<span style="color: #000080; font-weight: bold;">end</span> <span style="color: #000080; font-weight: bold;">if</span>
fDestination = <span style="color: #000080; font-weight: bold;">True</span>
<span style="color: #000080; font-weight: bold;">Else</span> <span style="color: #008800; font-style: italic;">'2 ff die Quellen</span>
j = UBound(sourceFolders) + <span style="color: #0000ff;">1</span>
<span style="color: #000080; font-weight: bold;">ReDim</span> Preserve sourceFolders(j)
sourceFolders(j) = sOA
<span style="color: #000080; font-weight: bold;">End</span> <span style="color: #000080; font-weight: bold;">If</span>
<span style="color: #000080; font-weight: bold;">end</span> <span style="color: #000080; font-weight: bold;">if</span>
<span style="color: #000080; font-weight: bold;">end</span> <span style="color: #000080; font-weight: bold;">select</span>
<span style="color: #000080; font-weight: bold;">On</span> <span style="color: #000080; font-weight: bold;">Error</span> <span style="color: #000080; font-weight: bold;">Goto</span> <span style="color: #0000ff;">0</span>
<span style="color: #000080; font-weight: bold;">Next</span>
<span style="color: #000080; font-weight: bold;">End</span> <span style="color: #000080; font-weight: bold;">If</span>
<span style="color: #000080; font-weight: bold;">End</span> <span style="color: #000080; font-weight: bold;">Function</span>

<span style="color: #000080; font-weight: bold;">Function</span> setPara()
<span style="color: #008800; font-style: italic;">'Das Script kann auch ohne Parameter gestartet werden, da alle Parameter auch innerhlab des Script's angegeben werden können </span>
<span style="color: #008800; font-style: italic;">'Destination und Archv-Name analysieren</span>

<span style="color: #000080; font-weight: bold;">if</span> destination = vbNullString <span style="color: #000080; font-weight: bold;">then</span>
sTmp = <span style="color: #0000ff;">"Kein Ziel-Pfad für das Archiv angegeben "</span>
<span style="color: #000080; font-weight: bold;">if</span> quiet <span style="color: #000080; font-weight: bold;">then</span>
wscript.echo sTmp
<span style="color: #000080; font-weight: bold;">else</span>
wsh.PopUp sTmp, <span style="color: #0000ff;">60</span>, cHeader, vbOKOnly + vbExclamation
<span style="color: #000080; font-weight: bold;">end</span> <span style="color: #000080; font-weight: bold;">if</span>
WScript.Quit
<span style="color: #000080; font-weight: bold;">elseif</span> ubound(sourceFolders) = -<span style="color: #0000ff;">1</span> <span style="color: #000080; font-weight: bold;">then</span>
sTmp = <span style="color: #0000ff;">"Kein Dateien/Ordner zum Archiveren angegeben"</span>
<span style="color: #000080; font-weight: bold;">if</span> quiet <span style="color: #000080; font-weight: bold;">then</span>
wscript.echo sTmp
<span style="color: #000080; font-weight: bold;">else</span>
wsh.PopUp sTmp, <span style="color: #0000ff;">60</span>, cHeader, vbOKOnly + vbExclamation
<span style="color: #000080; font-weight: bold;">end</span> <span style="color: #000080; font-weight: bold;">if</span>
WScript.Quit
<span style="color: #000080; font-weight: bold;">end</span> <span style="color: #000080; font-weight: bold;">if</span>

fileSuffix = ExtractFileSuffix(destination, <span style="color: #000080; font-weight: bold;">True</span>)
<span style="color: #000080; font-weight: bold;">if</span> (fileSuffix = <span style="color: #0000ff;">".zip"</span> <span style="font-weight: bold;">or</span> fileSuffix = <span style="color: #0000ff;">".7z"</span>) <span style="color: #000080; font-weight: bold;">then</span>
<span style="color: #008800; font-style: italic;">'In destination wurde schon der Archiv-Name angegeben </span>
archivName = ExtractFileName(destination, <span style="color: #000080; font-weight: bold;">true</span>)
destination = ExtractFilePath(destination)
<span style="color: #000080; font-weight: bold;">elseif</span> archivName &lt;&gt; vbNullString <span style="color: #000080; font-weight: bold;">Then</span>
fileSuffix = ExtractFileSuffix(archivName, <span style="color: #000080; font-weight: bold;">True</span>)
<span style="color: #000080; font-weight: bold;">if</span> (fileSuffix = <span style="color: #0000ff;">".zip"</span> <span style="font-weight: bold;">or</span> fileSuffix = <span style="color: #0000ff;">".7z"</span>) <span style="color: #000080; font-weight: bold;">then</span>
archivName = ExtractFileName(archivName, <span style="color: #000080; font-weight: bold;">true</span>)

<span style="color: #000080; font-weight: bold;">end</span> <span style="color: #000080; font-weight: bold;">if</span>
<span style="color: #008800; font-style: italic;">'destination = ExtractFilePath(destination) </span>
<span style="color: #000080; font-weight: bold;">elseif</span> Right(destination, <span style="color: #0000ff;">1</span>) = cBSlash <span style="color: #000080; font-weight: bold;">then</span>
destination = Right(destination, Len(destination) - <span style="color: #0000ff;">1</span>)

<span style="color: #000080; font-weight: bold;">end</span> <span style="color: #000080; font-weight: bold;">if</span>
<span style="color: #000080; font-weight: bold;">if</span> archivName = vbNullString <span style="color: #000080; font-weight: bold;">then</span> archivName = <span style="color: #0000ff;">"backup"</span>
<span style="color: #000080; font-weight: bold;">if</span> fileSuffix = vbNullString <span style="color: #000080; font-weight: bold;">then</span>
fileSuffix = <span style="color: #0000ff;">".7z"</span>
<span style="color: #000080; font-weight: bold;">elseif</span> <span style="color: #000080; font-weight: bold;">not</span> (fileSuffix = <span style="color: #0000ff;">".zip"</span> <span style="font-weight: bold;">or</span> fileSuffix = <span style="color: #0000ff;">".7z"</span>) <span style="color: #000080; font-weight: bold;">then</span>
fileSuffix = <span style="color: #0000ff;">".7z"</span>
<span style="color: #000080; font-weight: bold;">end</span> <span style="color: #000080; font-weight: bold;">if</span>
<span style="color: #008800; font-style: italic;">' Prüfen ob das Ziel-Laufwerk vorhanden ist. </span>
sTmp = UCase(Left(destination, <span style="color: #0000ff;">1</span>))
<span style="color: #000080; font-weight: bold;">If</span> <span style="color: #000080; font-weight: bold;">Not</span> fso.DriveExists(sTmp &amp; <span style="color: #0000ff;">":"</span>) <span style="color: #000080; font-weight: bold;">Then</span>
wsh.PopUp <span style="color: #0000ff;">"Laufwerk '"</span> &amp; sTmp &amp; <span style="color: #0000ff;">":' nicht vorhanden !"</span>, <span style="color: #0000ff;">60</span>, cHeader, vbOKOnly + vbExclamation
WScript.Quit
<span style="color: #000080; font-weight: bold;">ElseIf</span> <span style="color: #000080; font-weight: bold;">Not</span> fso.folderexists(destination) <span style="color: #000080; font-weight: bold;">Then</span>
sTmp = cC &amp; <span style="color: #0000ff;">"md "</span> &amp; wrap(destination)
wsh.run sTmp, <span style="color: #0000ff;">0</span>, <span style="color: #000080; font-weight: bold;">True</span>
<span style="color: #000080; font-weight: bold;">End</span> <span style="color: #000080; font-weight: bold;">If</span>
<span style="color: #000080; font-weight: bold;">If</span> fileFormat = vbNullString <span style="color: #000080; font-weight: bold;">Then</span>
fileFormat = <span style="color: #0000ff;">" -t7z"</span>
<span style="color: #000080; font-weight: bold;">else</span>
fileFormat = <span style="color: #0000ff;">" -t"</span> &amp; fileFormat
<span style="color: #000080; font-weight: bold;">end</span> <span style="color: #000080; font-weight: bold;">if</span>

<span style="color: #000080; font-weight: bold;">If</span> password &lt;&gt; vbNullString <span style="color: #000080; font-weight: bold;">Then</span>
password = wrap(password)
<span style="color: #000080; font-weight: bold;">If</span> fNoListing <span style="color: #000080; font-weight: bold;">Then</span>
password = <span style="color: #0000ff;">" -mhe=on -p"</span> &amp; password
<span style="color: #000080; font-weight: bold;">Else</span>
password = <span style="color: #0000ff;">" -p"</span> &amp; password
<span style="color: #000080; font-weight: bold;">End</span> <span style="color: #000080; font-weight: bold;">If</span>
<span style="color: #000080; font-weight: bold;">End</span> <span style="color: #000080; font-weight: bold;">If</span>

<span style="color: #000080; font-weight: bold;">If</span> filesize &lt;&gt; vbNullString <span style="font-weight: bold;">And</span> <span style="color: #000080; font-weight: bold;">CStr</span>(filesize) &lt;&gt; <span style="color: #0000ff;">"0"</span> <span style="color: #000080; font-weight: bold;">Then</span>
<span style="color: #000080; font-weight: bold;">If</span> IsNumeric(filesize) <span style="color: #000080; font-weight: bold;">Then</span> filesize = filesize &amp; <span style="color: #0000ff;">"m"</span>
filesize = <span style="color: #0000ff;">" -v"</span> &amp; filesize
<span style="color: #000080; font-weight: bold;">Else</span>
filesize = vbNullString
<span style="color: #000080; font-weight: bold;">End</span> <span style="color: #000080; font-weight: bold;">If</span>

<span style="color: #000080; font-weight: bold;">If</span> compression &lt;&gt; vbNullString <span style="color: #000080; font-weight: bold;">Then</span> compression = <span style="color: #0000ff;">" -mx"</span> &amp; compression

<span style="color: #000080; font-weight: bold;">if</span> noSubdir <span style="color: #000080; font-weight: bold;">then</span>
noSubdir = <span style="color: #0000ff;">" -r-"</span>
prepFilterNoSubdirectories
<span style="color: #000080; font-weight: bold;">else</span>
noSubdir = vbNullString
<span style="color: #000080; font-weight: bold;">If</span> UBound(includeFilter) &gt;= <span style="color: #0000ff;">0</span> <span style="color: #000080; font-weight: bold;">Then</span>
<span style="color: #000080; font-weight: bold;">if</span> includeFilter(<span style="color: #0000ff;">0</span>) = <span style="color: #0000ff;">"*"</span> <span style="color: #000080; font-weight: bold;">then</span>
includeFilter = <span style="color: #0000ff;">""</span>
<span style="color: #000080; font-weight: bold;">for</span> i = <span style="color: #0000ff;">0</span> <span style="color: #000080; font-weight: bold;">To</span> UBound(sourceFolders)
sourceFolders(i) = wrap(sourceFolders(i) &amp; <span style="color: #0000ff;">"\*"</span>)
<span style="color: #000080; font-weight: bold;">next</span>
<span style="color: #000080; font-weight: bold;">else</span>
includeFilter = wrap(includeFilter)
includeFilter = <span style="color: #0000ff;">" -ir!"</span> &amp; Join(includeFilter, <span style="color: #0000ff;">" -ir!"</span>)
<span style="color: #000080; font-weight: bold;">end</span> <span style="color: #000080; font-weight: bold;">If</span>
<span style="color: #000080; font-weight: bold;">Else</span>
includeFilter = <span style="color: #0000ff;">""</span>
<span style="color: #000080; font-weight: bold;">End</span> <span style="color: #000080; font-weight: bold;">If</span>
<span style="color: #000080; font-weight: bold;">end</span> <span style="color: #000080; font-weight: bold;">if</span>
<span style="color: #000080; font-weight: bold;">If</span> UBound(excludeFilter) &gt;= <span style="color: #0000ff;">0</span> <span style="color: #000080; font-weight: bold;">Then</span>
excludeFilter = wrap(excludeFilter)
excludeFilter = <span style="color: #0000ff;">" -xr!"</span> &amp; Join(excludeFilter, <span style="color: #0000ff;">" -xr!"</span>)
<span style="color: #000080; font-weight: bold;">Else</span>
excludeFilter = <span style="color: #0000ff;">""</span>
<span style="color: #000080; font-weight: bold;">End</span> <span style="color: #000080; font-weight: bold;">If</span>

<span style="color: #000080; font-weight: bold;">If</span> ubound(sourceFolders) &gt; -<span style="color: #0000ff;">1</span> <span style="color: #000080; font-weight: bold;">Then</span> sourceFolders = cSpace &amp; Join(sourceFolders, cSpace)
<span style="color: #000080; font-weight: bold;">If</span> outputDir &lt;&gt; vbNullString <span style="color: #000080; font-weight: bold;">Then</span> outputDir = <span style="color: #0000ff;">" -o"</span> &amp; wrap(outputDir)
<span style="color: #000080; font-weight: bold;">If</span> sfx <span style="color: #000080; font-weight: bold;">Then</span>
<span style="color: #000080; font-weight: bold;">Const</span> cD = <span style="color: #0000ff;">"7z.sfx"</span> <span style="color: #008800; font-style: italic;">'Grafische Entpackoberfläche</span>
<span style="color: #008800; font-style: italic;">'Const cW = "7zCon.sfx" 'Dos</span>
<span style="color: #008800; font-style: italic;">'Const cW = "7zS.sfx" 'Windows version for installers.</span>
<span style="color: #008800; font-style: italic;">'Const cW = "7zSD.sfx" 'Windows version for installers (uses MSVCRT.dll)</span>
stmp = ExtractFilePath(sevenZipProg) &amp; cD
<span style="color: #000080; font-weight: bold;">If</span> <span style="color: #000080; font-weight: bold;">Not</span> fso.FileExists(stmp) <span style="color: #000080; font-weight: bold;">Then</span>
i = wsh.PopUp(<span style="color: #0000ff;">"Die Datei '"</span> &amp; sTmp &amp; <span style="color: #0000ff;">"' im 7zip-Packerpfad "</span> &amp; vbcrlF &amp; stmp &amp; vbcrlF &amp; _
<span style="color: #0000ff;">"wurde nicht gefunden."</span> &amp; vbcrlF &amp; <span style="color: #0000ff;">"Normales Archiv erzeugen."</span> , <span style="color: #0000ff;">10</span> , _
<span style="color: #0000ff;">"Selbstenpakendes Archiv *.exe"</span>, vbYesNo + vbQuestion)
<span style="color: #000080; font-weight: bold;">If</span> i = vbno <span style="color: #000080; font-weight: bold;">Then</span>
Wscript.Quit
<span style="color: #000080; font-weight: bold;">End</span> <span style="color: #000080; font-weight: bold;">If</span>
sfx = vbNullString
<span style="color: #000080; font-weight: bold;">Else</span>
sfx = <span style="color: #0000ff;">" -sfx"</span> &amp; wrap(stmp)
filesize = vbNullString
<span style="color: #000080; font-weight: bold;">End</span> <span style="color: #000080; font-weight: bold;">If</span>
<span style="color: #000080; font-weight: bold;">Else</span>
sfx = vbNullString
<span style="color: #000080; font-weight: bold;">End</span> <span style="color: #000080; font-weight: bold;">If</span>

<span style="color: #000080; font-weight: bold;">if</span> diffWildcard = vbNullString <span style="color: #000080; font-weight: bold;">then</span> diffWildcard = <span style="color: #0000ff;">"?"</span>
<span style="color: #000080; font-weight: bold;">if</span> diffCount &lt;&gt; vbNullString <span style="color: #000080; font-weight: bold;">then</span>
<span style="color: #000080; font-weight: bold;">if</span> IsNumeric(diffCount) <span style="color: #000080; font-weight: bold;">then</span>
<span style="color: #000080; font-weight: bold;">if</span> <span style="color: #000080; font-weight: bold;">cInt</span>(diffCount) = <span style="color: #0000ff;">0</span> <span style="color: #000080; font-weight: bold;">then</span>
diffCount = vbNullString
<span style="color: #000080; font-weight: bold;">elseIf</span> InStr(<span style="color: #0000ff;">1</span>, diffName, diffWildcard, vbTextCompare) = <span style="color: #0000ff;">0</span> <span style="color: #000080; font-weight: bold;">Then</span>
diffName = diffName &amp; diffWildcard
<span style="color: #000080; font-weight: bold;">end</span> <span style="color: #000080; font-weight: bold;">If</span>
<span style="color: #000080; font-weight: bold;">If</span> cmd = vbNullString <span style="color: #000080; font-weight: bold;">Then</span> cmd = <span style="color: #0000ff;">"u"</span>
<span style="color: #000080; font-weight: bold;">else</span>
diffCount = vbNullString
<span style="color: #000080; font-weight: bold;">end</span> <span style="color: #000080; font-weight: bold;">if</span>
<span style="color: #000080; font-weight: bold;">end</span> <span style="color: #000080; font-weight: bold;">if</span>
<span style="color: #000080; font-weight: bold;">if</span> diffCount = vbNullString <span style="color: #000080; font-weight: bold;">then</span> diffName = replace(diffName, diffWildcard, vbNullString, <span style="color: #0000ff;">1</span>, -<span style="color: #0000ff;">1</span>, vbTextCompare)

sTmp = destination &amp; cBSlash &amp; archivName &amp; fileSuffix
f = fso.FileExists(sTmp)
extract = <span style="color: #000080; font-weight: bold;">False</span>

<span style="color: #000080; font-weight: bold;">select</span> <span style="color: #000080; font-weight: bold;">case</span> cmd
<span style="color: #000080; font-weight: bold;">case</span> <span style="color: #0000ff;">"a"</span> <span style="color: #008800; font-style: italic;">'Dateinen anhängen</span>
cmd = iif(f, <span style="color: #0000ff;">"u"</span>, <span style="color: #0000ff;">"a"</span>)
<span style="color: #000080; font-weight: bold;">case</span> <span style="color: #0000ff;">"m"</span> <span style="color: #008800; font-style: italic;">'Mirror. Dateien spiegeln</span>
<span style="color: #000080; font-weight: bold;">if</span> f <span style="color: #000080; font-weight: bold;">then</span>
cmd = <span style="color: #0000ff;">"u"</span>
updateAchiv = <span style="color: #0000ff;">" -uq0"</span> <span style="color: #008800; font-style: italic;">'Mirror-Switch Datnen werden gespiegelt </span>
<span style="color: #000080; font-weight: bold;">else</span>
cmd = <span style="color: #0000ff;">"a"</span>
<span style="color: #000080; font-weight: bold;">end</span> <span style="color: #000080; font-weight: bold;">if</span>
<span style="color: #000080; font-weight: bold;">case</span> <span style="color: #0000ff;">"u"</span> <span style="color: #008800; font-style: italic;">'update Achiv differnziell</span>
<span style="color: #000080; font-weight: bold;">if</span> f <span style="color: #000080; font-weight: bold;">then</span>
<span style="color: #000080; font-weight: bold;">if</span> diffCount &lt;&gt; vbNullString <span style="color: #000080; font-weight: bold;">then</span>
sTmp = destination &amp; cBSlash &amp; archivName &amp; replace(diffName, diffWildcard, addLeadingZero(diffCount), <span style="color: #0000ff;">1</span>, -<span style="color: #0000ff;">1</span>, vbTextCompare) &amp; fileSuffix
<span style="color: #000080; font-weight: bold;">if</span> fso.FileExists(sTmp) <span style="color: #000080; font-weight: bold;">then</span>
<span style="color: #008800; font-style: italic;">'Maximale Anzahl erreicht alle um 1 umbenennen </span>
<span style="color: #000080; font-weight: bold;">for</span> i = <span style="color: #0000ff;">1</span> <span style="color: #000080; font-weight: bold;">to</span> diffCount - <span style="color: #0000ff;">1</span>
<span style="color: #008800; font-style: italic;">'Die diff-Archive um eins nach unten verschieben</span>
sTmp = destination &amp; cBSlash &amp; archivName &amp; replace(diffName, diffWildcard, addLeadingZero(i + <span style="color: #0000ff;">1</span>), <span style="color: #0000ff;">1</span>, -<span style="color: #0000ff;">1</span>, vbTextCompare) &amp; fileSuffix
sTmp2 = archivName &amp; replace(diffName, diffWildcard, addLeadingZero(i) , <span style="color: #0000ff;">1</span>, -<span style="color: #0000ff;">1</span>, vbTextCompare) &amp; fileSuffix
s = cC &amp; <span style="color: #0000ff;">"REN "</span> &amp; wrap(sTmp) &amp; <span style="color: #0000ff;">" "</span> &amp; wrap(sTmp2)
wsh.Run s, <span style="color: #0000ff;">0</span>, <span style="color: #000080; font-weight: bold;">True</span>
<span style="color: #000080; font-weight: bold;">next</span>
destinationDiff = destination &amp; cBSlash &amp; archivName &amp; replace(diffName, diffWildcard, addLeadingZero(diffCount), <span style="color: #0000ff;">1</span>, -<span style="color: #0000ff;">1</span>, vbTextCompare) &amp; fileSuffix
s = cC &amp; <span style="color: #0000ff;">"DEL /F /Q "</span> &amp; wrap(destinationDiff)
wsh.Run s, <span style="color: #0000ff;">0</span>, <span style="color: #000080; font-weight: bold;">True</span>
<span style="color: #000080; font-weight: bold;">else</span>
destinationDiff = wrap(getDiffmaxFileName(<span style="color: #000080; font-weight: bold;">False</span>))
<span style="color: #000080; font-weight: bold;">end</span> <span style="color: #000080; font-weight: bold;">if</span>
<span style="color: #000080; font-weight: bold;">else</span>
sTmp = destination &amp; cBSlash &amp; archivName &amp; diffName &amp; fileSuffix
<span style="color: #000080; font-weight: bold;">if</span> fso.FileExists(sTmp) <span style="color: #000080; font-weight: bold;">then</span>
s = cC &amp; <span style="color: #0000ff;">"DEL /F /Q "</span> &amp; wrap(sTmp)
wsh.Run s, <span style="color: #0000ff;">0</span>, <span style="color: #000080; font-weight: bold;">True</span>
<span style="color: #000080; font-weight: bold;">end</span> <span style="color: #000080; font-weight: bold;">if</span>
destinationDiff = wrap(sTmp)
<span style="color: #000080; font-weight: bold;">end</span> <span style="color: #000080; font-weight: bold;">if</span>
<span style="color: #008800; font-style: italic;">'p - File exists in archive, but is not matched with wildcard.</span>
<span style="color: #008800; font-style: italic;">'q - File exists in archive, but doesn't exist on disk.</span>
<span style="color: #008800; font-style: italic;">'r - File doesn't exist in archive, but exists on disk.</span>
<span style="color: #008800; font-style: italic;">'x - File in archive is newer than the file on disk.</span>
<span style="color: #008800; font-style: italic;">'y - File in archive is older than the file on disk.</span>
<span style="color: #008800; font-style: italic;">'z - File in archive is same as the file on disk</span>
<span style="color: #008800; font-style: italic;">'w - Can not be detected what file is newer (times are the same, sizes are different)</span>
<span style="color: #008800; font-style: italic;">'0 Ignore file (don't create item in new archive for this file)</span>
<span style="color: #008800; font-style: italic;">'1 Copy file (copy from old archive to new)</span>
<span style="color: #008800; font-style: italic;">'2 Compress (compress file from disk to new archive)</span>
<span style="color: #008800; font-style: italic;">'3 Create Anti-item (item that will delete file or directory during extracting). This feature is supported only in 7z format</span>
updateAchiv = <span style="color: #0000ff;">" -u- -up0q3r2x2y2z0w2!"</span> &amp; destinationDiff
<span style="color: #000080; font-weight: bold;">end</span> <span style="color: #000080; font-weight: bold;">if</span>
<span style="color: #000080; font-weight: bold;">case</span> <span style="color: #0000ff;">"e"</span>
cmd = <span style="color: #0000ff;">"e"</span>
extract = <span style="color: #000080; font-weight: bold;">true</span>

destinationDiff = wrap(getDiffmaxFileName(<span style="color: #000080; font-weight: bold;">true</span>))
<span style="color: #000080; font-weight: bold;">case</span> <span style="color: #0000ff;">"x"</span>
cmd = <span style="color: #0000ff;">"x"</span>
destinationDiff = wrap(getDiffmaxFileName(<span style="color: #000080; font-weight: bold;">True</span>))
extract = <span style="color: #000080; font-weight: bold;">true</span>
<span style="color: #000080; font-weight: bold;">case</span> <span style="color: #0000ff;">""</span>
<span style="color: #000080; font-weight: bold;">if</span> f <span style="color: #000080; font-weight: bold;">then</span>
<span style="color: #000080; font-weight: bold;">if</span> outputDir &lt;&gt; vbNullString <span style="color: #000080; font-weight: bold;">then</span>
cmd = <span style="color: #0000ff;">"x"</span>
<span style="color: #000080; font-weight: bold;">else</span>
cmd = <span style="color: #0000ff;">"u"</span>
<span style="color: #000080; font-weight: bold;">end</span> <span style="color: #000080; font-weight: bold;">if</span>
<span style="color: #000080; font-weight: bold;">else</span>
cmd = <span style="color: #0000ff;">"a"</span>
<span style="color: #000080; font-weight: bold;">end</span> <span style="color: #000080; font-weight: bold;">if</span>
<span style="color: #000080; font-weight: bold;">end</span> <span style="color: #000080; font-weight: bold;">select</span>
cmd = cSpace &amp; cmd

destination = cSpace &amp; wrap(destination &amp; cBSlash &amp; archivName &amp; fileSuffix)
<span style="color: #000080; font-weight: bold;">End</span> <span style="color: #000080; font-weight: bold;">Function</span>

<span style="color: #000080; font-weight: bold;">Function</span> run7z()
<span style="color: #008800; font-style: italic;">' Parameter für 7Zip anpassen</span>
<span style="color: #000080; font-weight: bold;">On</span> <span style="color: #000080; font-weight: bold;">Error</span> <span style="color: #000080; font-weight: bold;">Resume</span> <span style="color: #000080; font-weight: bold;">Next</span>
<span style="color: #008800; font-style: italic;">'-y sag ja zu allem</span>
<span style="color: #008800; font-style: italic;">'-mx5 Kompressionrate (0-nicht komprimieren...5-default...9-maximal)</span>
<span style="color: #008800; font-style: italic;">'-mmt=on Multiprozessoer ein</span>
<span style="color: #008800; font-style: italic;">'-ssw auch geöffnete Dateien kopieren (wenn möglich)</span>

<span style="color: #000080; font-weight: bold;">If</span> extract <span style="color: #000080; font-weight: bold;">Then</span>
<span style="color: #008800; font-style: italic;">'wsh.CurrentDirectory = destination 'Ordner zum Entpacken festlegen</span>
<span style="color: #000080; font-weight: bold;">stop</span>
s = sevenZipProg &amp; cmd &amp; <span style="color: #0000ff;">" -y"</span> &amp; password &amp; outputDir &amp; destination
i = wsh.Run(s, <span style="color: #0000ff;">1</span>, <span style="color: #000080; font-weight: bold;">True</span>)
s = ExtractFileSuffix(destination, <span style="color: #000080; font-weight: bold;">true</span>)
<span style="color: #008800; font-style: italic;">' Gibt es ein diff Backup? </span>
<span style="color: #000080; font-weight: bold;">if</span> fso.FileExists(destinationDiff) <span style="color: #000080; font-weight: bold;">then</span>
s = sevenZipProg &amp; cmd &amp; <span style="color: #0000ff;">" -y"</span> &amp; password &amp; outputDir &amp; <span style="color: #0000ff;">" "</span> &amp; wrap(destinationDiff)
wsh.Run s, <span style="color: #0000ff;">1</span>, <span style="color: #000080; font-weight: bold;">True</span>
<span style="color: #000080; font-weight: bold;">end</span> <span style="color: #000080; font-weight: bold;">if</span>
stmp2 = <span style="color: #0000ff;">"Archiv '"</span> &amp; destination &amp; <span style="color: #0000ff;">"' wurde nach '"</span> &amp; replace(outputDir, <span style="color: #0000ff;">"-o"</span>, vbNullString, <span style="color: #0000ff;">1</span>, -<span style="color: #0000ff;">1</span>, vbTextCompare) &amp; <span style="color: #0000ff;">"' entpackt."</span>
<span style="color: #000080; font-weight: bold;">else</span>
s = sevenZipProg &amp; cmd &amp; <span style="color: #0000ff;">" -ssw"</span> &amp; password &amp; fileFormat &amp; compression &amp; noSubdir &amp; excludeFilter &amp; includeFilter &amp; filesize &amp; sfx &amp; updateAchiv &amp; destination &amp; sourceFolders
<span style="color: #008800; font-style: italic;">'--- Folgende Zeile muss für den produktiven Betrieb auskommentiert werden. Nur für Test ---</span>
s = InputBox (<span style="color: #0000ff;">"7zip"</span>, <span style="color: #0000ff;">"Nur zur Info / Test"</span>, s)
i = wsh.Run(s, <span style="color: #0000ff;">1</span>, <span style="color: #000080; font-weight: bold;">True</span>)
stmp2 = <span style="color: #0000ff;">"7-Zip hat die Dateien nach '"</span> &amp; Iif(destinationDiff = vbNullString, destination, destinationDiff &amp; <span style="color: #0000ff;">"' (diff.) "</span>) &amp; <span style="color: #0000ff;">" gepackt."</span>
<span style="color: #000080; font-weight: bold;">end</span> <span style="color: #000080; font-weight: bold;">if</span>

<span style="color: #008800; font-style: italic;">'Exit Codes</span>
<span style="color: #000080; font-weight: bold;">Select</span> <span style="color: #000080; font-weight: bold;">case</span> i
<span style="color: #000080; font-weight: bold;">case</span> <span style="color: #0000ff;">0</span> s = <span style="color: #0000ff;">"No error"</span>
<span style="color: #000080; font-weight: bold;">case</span> <span style="color: #0000ff;">1</span> s = <span style="color: #0000ff;">"Warning (Non fatal error(s)). For example, one or more files were locked by some other application, so they were not compressed."</span>
<span style="color: #000080; font-weight: bold;">case</span> <span style="color: #0000ff;">2</span> s = <span style="color: #0000ff;">"Fatal error"</span>
<span style="color: #000080; font-weight: bold;">case</span> <span style="color: #0000ff;">7</span> s = <span style="color: #0000ff;">"Command line error"</span>
<span style="color: #000080; font-weight: bold;">case</span> <span style="color: #0000ff;">8</span> s = <span style="color: #0000ff;">"Not enough memory for operation"</span>
<span style="color: #000080; font-weight: bold;">case</span> <span style="color: #0000ff;">255</span> s = <span style="color: #0000ff;">"User stopped the process"</span>
<span style="color: #000080; font-weight: bold;">end</span> <span style="color: #000080; font-weight: bold;">select</span>

<span style="color: #000080; font-weight: bold;">if</span> i = <span style="color: #0000ff;">0</span> <span style="color: #000080; font-weight: bold;">then</span>
s = stmp2
j = vbInformation
<span style="color: #000080; font-weight: bold;">elseif</span> i = <span style="color: #0000ff;">1</span> <span style="color: #000080; font-weight: bold;">then</span>
s = stmp2 &amp; <span style="color: #0000ff;">" (mit Warnungen)"</span> &amp; vbCrLf &amp; stmp2
j = vbExclamation
<span style="color: #000080; font-weight: bold;">else</span>
s = <span style="color: #0000ff;">"Fehler sind aufgetreten:"</span> &amp; vbCrLF &amp; stmp2
j = vbCritical
<span style="color: #000080; font-weight: bold;">end</span> <span style="color: #000080; font-weight: bold;">if</span>
<span style="color: #000080; font-weight: bold;">if</span> quiet <span style="color: #000080; font-weight: bold;">then</span>
wscript.echo s
<span style="color: #000080; font-weight: bold;">else</span>
wsh.popup s, <span style="color: #0000ff;">6</span>, cHeader, vbOKOnly + j
<span style="color: #000080; font-weight: bold;">end</span> <span style="color: #000080; font-weight: bold;">if</span>
<span style="color: #000080; font-weight: bold;">End</span> <span style="color: #000080; font-weight: bold;">Function</span>

<span style="color: #000080; font-weight: bold;">function</span> getDiffmaxFileName(fExtract)
<span style="color: #000080; font-weight: bold;">if</span> diffCount = vbNullString <span style="color: #000080; font-weight: bold;">then</span>
getDiffmaxFileName = destination &amp; cBSlash &amp; archivName &amp; diffName &amp; fileSuffix
<span style="color: #000080; font-weight: bold;">else</span>
<span style="color: #000080; font-weight: bold;">for</span> i = <span style="color: #0000ff;">1</span> <span style="color: #000080; font-weight: bold;">to</span> diffCount
sTmp = destination &amp; cBSlash &amp; archivName &amp; replace(diffName, diffWildcard, addLeadingZero(i), <span style="color: #0000ff;">1</span>, -<span style="color: #0000ff;">1</span>, vbTextCompare) &amp; fileSuffix
<span style="color: #000080; font-weight: bold;">if</span> <span style="color: #000080; font-weight: bold;">not</span> fso.FileExists(sTmp) <span style="color: #000080; font-weight: bold;">then</span>
<span style="color: #000080; font-weight: bold;">exit</span> <span style="color: #000080; font-weight: bold;">for</span>
<span style="color: #000080; font-weight: bold;">else</span>
sTmp2 = sTmp
<span style="color: #000080; font-weight: bold;">end</span> <span style="color: #000080; font-weight: bold;">if</span>
<span style="color: #000080; font-weight: bold;">next</span>
getDiffmaxFileName = iif(fExtract = <span style="color: #000080; font-weight: bold;">true</span>, sTmp2, sTmp)
<span style="color: #000080; font-weight: bold;">end</span> <span style="color: #000080; font-weight: bold;">if</span>
<span style="color: #000080; font-weight: bold;">end</span> <span style="color: #000080; font-weight: bold;">Function</span>

<span style="color: #000080; font-weight: bold;">Function</span> wrap(v)
<span style="color: #000080; font-weight: bold;">Dim</span> i, s, va
va = v
<span style="color: #000080; font-weight: bold;">If</span> IsArray(va) <span style="color: #000080; font-weight: bold;">Then</span>
<span style="color: #000080; font-weight: bold;">for</span> i = <span style="color: #0000ff;">0</span> <span style="color: #000080; font-weight: bold;">To</span> UBound(va)
s = Replace(va(i), cSlash, cBSlash, <span style="color: #0000ff;">1</span>, -<span style="color: #0000ff;">1</span>, vbTextCompare)
<span style="color: #000080; font-weight: bold;">If</span> InStr(<span style="color: #0000ff;">1</span>, s, cSpace, vbTextCompare) <span style="color: #000080; font-weight: bold;">Then</span>
va(i) = cDQ &amp; s &amp; cDQ
<span style="color: #000080; font-weight: bold;">Else</span>
va(i) = s
<span style="color: #000080; font-weight: bold;">End</span> <span style="color: #000080; font-weight: bold;">If</span>
<span style="color: #000080; font-weight: bold;">Next</span>
<span style="color: #000080; font-weight: bold;">ElseIf</span> va &lt;&gt; vbNullString <span style="color: #000080; font-weight: bold;">Then</span>
va = Replace(va, cSlash, cBSlash, <span style="color: #0000ff;">1</span>, -<span style="color: #0000ff;">1</span>, vbTextCompare)
<span style="color: #000080; font-weight: bold;">If</span> InStr(<span style="color: #0000ff;">1</span>, va, cSpace, vbTextCompare) <span style="color: #000080; font-weight: bold;">Then</span> va = cDQ &amp; va &amp; cDQ
<span style="color: #000080; font-weight: bold;">End</span> <span style="color: #000080; font-weight: bold;">If</span>
wrap = va
<span style="color: #000080; font-weight: bold;">End</span> <span style="color: #000080; font-weight: bold;">Function</span>

<span style="color: #000080; font-weight: bold;">Function</span> ChrAnsi(v)
<span style="color: #000080; font-weight: bold;">Dim</span> a, b
<span style="color: #008800; font-style: italic;">'ASCII ist OK</span>
ChrAnsi = <span style="color: #000080; font-weight: bold;">False</span>
<span style="color: #000080; font-weight: bold;">For</span> a = <span style="color: #0000ff;">1</span> <span style="color: #000080; font-weight: bold;">To</span> Len(v)
b = asc(Mid(v, a, <span style="color: #0000ff;">1</span>))
<span style="color: #000080; font-weight: bold;">If</span> b &gt; <span style="color: #0000ff;">126</span> <span style="color: #000080; font-weight: bold;">Then</span>
ChrAnsi = <span style="color: #000080; font-weight: bold;">True</span> <span style="color: #008800; font-style: italic;">'Ansi-Zeichensatz</span>
<span style="color: #000080; font-weight: bold;">Exit</span> <span style="color: #000080; font-weight: bold;">For</span>
<span style="color: #000080; font-weight: bold;">End</span> <span style="color: #000080; font-weight: bold;">If</span>
<span style="color: #000080; font-weight: bold;">Next</span>
<span style="color: #000080; font-weight: bold;">End</span> <span style="color: #000080; font-weight: bold;">Function</span>

<span style="color: #000080; font-weight: bold;">Function</span> addLeadingZero(number)
<span style="color: #000080; font-weight: bold;">if</span> diffCount &gt; <span style="color: #0000ff;">9</span> <span style="color: #000080; font-weight: bold;">then</span>
number = <span style="color: #0000ff;">"0"</span> &amp; number
<span style="color: #000080; font-weight: bold;">elseif</span> diffCount &gt; <span style="color: #0000ff;">99</span> <span style="color: #000080; font-weight: bold;">then</span>
number = <span style="color: #0000ff;">"00"</span> &amp; number
<span style="color: #000080; font-weight: bold;">elseif</span> diffCount &gt; <span style="color: #0000ff;">999</span> <span style="color: #000080; font-weight: bold;">then</span>
number = <span style="color: #0000ff;">"000"</span> &amp; number
<span style="color: #000080; font-weight: bold;">end</span> <span style="color: #000080; font-weight: bold;">if</span>
addLeadingZero = number
<span style="color: #000080; font-weight: bold;">End</span> <span style="color: #000080; font-weight: bold;">Function</span>

<span style="color: #000080; font-weight: bold;">Function</span> getSevenZipProg()
<span style="color: #000080; font-weight: bold;">Const</span> c7Z = <span style="color: #0000ff;">"7z.exe"</span>
<span style="color: #008800; font-style: italic;">' sevenZipProg = "PFAD_ZUR_7z.EXE" 'eintragen falls sie nicht gefunden wird</span>
sevenZipProg = wsh.ExpandEnvironmentStrings(<span style="color: #0000ff;">"%ProgramFiles%"</span>) &amp; <span style="color: #0000ff;">"\7-Zip\"</span> &amp; c7Z <span style="color: #008800; font-style: italic;">'c:\Programme</span>
<span style="color: #000080; font-weight: bold;">If</span> <span style="color: #000080; font-weight: bold;">Not</span> fso.FileExists(sevenZipProg) <span style="color: #000080; font-weight: bold;">Then</span>
sevenZipProg = wsh.ExpandEnvironmentStrings(<span style="color: #0000ff;">"%ProgramFiles(x86)%"</span>) &amp; <span style="color: #0000ff;">"\7-Zip\"</span> &amp; c7Z <span style="color: #008800; font-style: italic;">'c:\Program Files (x86)</span>
<span style="color: #000080; font-weight: bold;">If</span> <span style="color: #000080; font-weight: bold;">Not</span> fso.FileExists(sevenZipProg) <span style="color: #000080; font-weight: bold;">Then</span>
sevenZipProg = wsh.ExpandEnvironmentStrings(<span style="color: #0000ff;">"%SystemDrive%"</span>) &amp; <span style="color: #0000ff;">"\7-Zip\"</span> &amp; c7Z <span style="color: #008800; font-style: italic;">'c:\</span>
<span style="color: #000080; font-weight: bold;">If</span> <span style="color: #000080; font-weight: bold;">Not</span> fso.fileexists(sevenZipProg) <span style="color: #000080; font-weight: bold;">Then</span>
sevenZipProg = Replace(WScript.ScriptFullName ,WScript.ScriptName, vbNullString, <span style="color: #0000ff;">1</span>, -<span style="color: #0000ff;">1</span>, vbTextCompare) &amp; c7Z <span style="color: #008800; font-style: italic;">'Scriptpfad</span>
<span style="color: #000080; font-weight: bold;">If</span> <span style="color: #000080; font-weight: bold;">Not</span> fso.FileExists(sevenZipProg) <span style="color: #000080; font-weight: bold;">Then</span>
sevenZipProg = Replace(WScript.ScriptFullName ,WScript.ScriptName, vbNullString, <span style="color: #0000ff;">1</span>, -<span style="color: #0000ff;">1</span>, vbTextCompare) &amp; <span style="color: #0000ff;">"7-Zip\"</span> &amp; c7Z <span style="color: #008800; font-style: italic;">'Scriptpfad</span>
<span style="color: #000080; font-weight: bold;">If</span> <span style="color: #000080; font-weight: bold;">Not</span> fso.FileExists(sevenZipProg) <span style="color: #000080; font-weight: bold;">Then</span>
wsh.popup c7Z &amp; <span style="color: #0000ff;">" wurde nicht gefunden"</span>, <span style="color: #0000ff;">10</span>, , vbExclamation + vbSystemModal
Wscript.Quit
<span style="color: #000080; font-weight: bold;">End</span> <span style="color: #000080; font-weight: bold;">If</span>
<span style="color: #000080; font-weight: bold;">End</span> <span style="color: #000080; font-weight: bold;">If</span>
<span style="color: #000080; font-weight: bold;">End</span> <span style="color: #000080; font-weight: bold;">If</span>
<span style="color: #000080; font-weight: bold;">End</span> <span style="color: #000080; font-weight: bold;">If</span>
<span style="color: #000080; font-weight: bold;">End</span> <span style="color: #000080; font-weight: bold;">If</span>
sevenZipProg = wrap(sevenZipProg)
<span style="color: #000080; font-weight: bold;">End</span> <span style="color: #000080; font-weight: bold;">Function</span>

<span style="color: #000080; font-weight: bold;">Function</span> Iif(v, vTrue, vFalse)
<span style="color: #000080; font-weight: bold;">If</span> v <span style="color: #000080; font-weight: bold;">Then</span>
Iif = vTrue
<span style="color: #000080; font-weight: bold;">Else</span>
Iif = vFalse
<span style="color: #000080; font-weight: bold;">End</span> <span style="color: #000080; font-weight: bold;">If</span>
<span style="color: #000080; font-weight: bold;">End</span> <span style="color: #000080; font-weight: bold;">Function</span>

<span style="color: #008800; font-style: italic;">' Damit 7-Zip keine Unterordner in das Archiv kopiert muss der include Filter nach sourceFolders übertagen werden</span>
<span style="color: #000080; font-weight: bold;">function</span> prepFilterNoSubdirectories()
<span style="color: #000080; font-weight: bold;">dim</span> i, j, k, s, fExclude, oFolder, oSubFolder, arr, re
<span style="color: #000080; font-weight: bold;">for</span> i = <span style="color: #0000ff;">0</span> <span style="color: #000080; font-weight: bold;">to</span> UBound(includeFilter)
<span style="color: #000080; font-weight: bold;">if</span> includeFilter(i) = (<span style="color: #0000ff;">"*"</span>) <span style="color: #000080; font-weight: bold;">then</span> includeFilter(i) = (<span style="color: #0000ff;">"*.*"</span>)
<span style="color: #000080; font-weight: bold;">next</span>
<span style="color: #000080; font-weight: bold;">For</span> i = <span style="color: #0000ff;">0</span> <span style="color: #000080; font-weight: bold;">To</span> UBound(sourceFolders)
<span style="color: #000080; font-weight: bold;">Set</span> oFolder = fso.GetFolder(sourceFolders(i))
<span style="color: #000080; font-weight: bold;">for</span> <span style="color: #000080; font-weight: bold;">each</span> oSubfolder <span style="font-weight: bold;">in</span> oFolder.SubFolders
<span style="color: #000080; font-weight: bold;">For</span> j = <span style="color: #0000ff;">0</span> <span style="color: #000080; font-weight: bold;">To</span> UBound(includeFilter)
s = replace(replace(includeFilter(j), <span style="color: #0000ff;">"+"</span>, <span style="color: #0000ff;">"\+"</span>),<span style="color: #0000ff;">"."</span>, <span style="color: #0000ff;">"\."</span>, <span style="color: #0000ff;">1</span>, -<span style="color: #0000ff;">1</span>, vbTextCompare) <span style="color: #008800; font-style: italic;">'Quantoren kapseln</span>
s = replace(s, <span style="color: #0000ff;">"*"</span>, <span style="color: #0000ff;">".*"</span>, <span style="color: #0000ff;">1</span>, -<span style="color: #0000ff;">1</span>, vbTextCompare) <span style="color: #008800; font-style: italic;">'Quantoren Asterix für Regex anpassen</span>
<span style="color: #000080; font-weight: bold;">Set</span> re = <span style="color: #000080; font-weight: bold;">new</span> regexp
re.pattern = s
re.IgnoreCase = <span style="color: #000080; font-weight: bold;">True</span>
<span style="color: #000080; font-weight: bold;">if</span> re.Test(oSubfolder.Name) <span style="color: #000080; font-weight: bold;">then</span>
k = ubound(excludeFilter) + <span style="color: #0000ff;">1</span>
<span style="color: #000080; font-weight: bold;">redim</span> preserve excludeFilter(k)
excludeFilter(k) = oSubfolder.Name
fExclude = <span style="color: #000080; font-weight: bold;">true</span>
<span style="color: #000080; font-weight: bold;">end</span> <span style="color: #000080; font-weight: bold;">if</span>
<span style="color: #000080; font-weight: bold;">set</span> re = <span style="color: #000080; font-weight: bold;">nothing</span>
<span style="color: #000080; font-weight: bold;">next</span>
<span style="color: #000080; font-weight: bold;">next</span>
<span style="color: #000080; font-weight: bold;">set</span> oFolder = <span style="color: #000080; font-weight: bold;">Nothing</span>
<span style="color: #000080; font-weight: bold;">next</span>

j = UBound(includeFilter) + <span style="color: #0000ff;">1</span>
i = UBound(sourceFolders) + <span style="color: #0000ff;">1</span>
<span style="color: #000080; font-weight: bold;">ReDim</span> arr((i * j) - <span style="color: #0000ff;">1</span>)
<span style="color: #000080; font-weight: bold;">For</span> i = <span style="color: #0000ff;">0</span> <span style="color: #000080; font-weight: bold;">To</span> UBound(sourceFolders)
<span style="color: #000080; font-weight: bold;">for</span> j = <span style="color: #0000ff;">0</span> <span style="color: #000080; font-weight: bold;">To</span> UBound(includeFilter)
s = sourceFolders(i) &amp; cBSlash &amp; includeFilter(j)
arr(i + j) = s
<span style="color: #000080; font-weight: bold;">Next</span>
<span style="color: #000080; font-weight: bold;">Next</span>
sourceFolders = wrap(arr)
includeFilter = vbnullstring
<span style="color: #000080; font-weight: bold;">End</span> <span style="color: #000080; font-weight: bold;">Function</span>

<span style="color: #000080; font-weight: bold;">Function</span> ExtractFileName(sFilePath, fTrimSuffix)
<span style="color: #000080; font-weight: bold;">Dim</span> i, s
<span style="color: #000080; font-weight: bold;">If</span> <span style="color: #000080; font-weight: bold;">Not</span> IsNull(sFilePath) <span style="color: #000080; font-weight: bold;">Then</span>
sFilePath = Replace(sFilePath, cSlash, cBSlash, <span style="color: #0000ff;">1</span>, -<span style="color: #0000ff;">1</span>, vbTextCompare)
i = InStrRev(sFilePath, gcBSlash, -<span style="color: #0000ff;">1</span>, vbTextCompare)
s = right(sFilePath, len(sFilePath) - i)
<span style="color: #000080; font-weight: bold;">if</span> fTrimSuffix = <span style="color: #000080; font-weight: bold;">true</span> <span style="color: #000080; font-weight: bold;">then</span>
i = InStrRev(s, <span style="color: #0000ff;">"."</span>, -<span style="color: #0000ff;">1</span>, vbTextCompare)
<span style="color: #000080; font-weight: bold;">if</span> i &gt; <span style="color: #0000ff;">0</span> <span style="color: #000080; font-weight: bold;">then</span> s = left(s, i - <span style="color: #0000ff;">1</span>)
<span style="color: #000080; font-weight: bold;">end</span> <span style="color: #000080; font-weight: bold;">if</span>
<span style="color: #000080; font-weight: bold;">else</span>
s = sFilePath
<span style="color: #000080; font-weight: bold;">End</span> <span style="color: #000080; font-weight: bold;">If</span>
ExtractFileName = s
<span style="color: #000080; font-weight: bold;">End</span> <span style="color: #000080; font-weight: bold;">Function</span>

<span style="color: #000080; font-weight: bold;">Function</span> ExtractFileSuffix(sFilePath, fDot)
<span style="color: #000080; font-weight: bold;">Dim</span> i, s
<span style="color: #000080; font-weight: bold;">If</span> <span style="color: #000080; font-weight: bold;">Not</span> IsNull(sFilePath) <span style="color: #000080; font-weight: bold;">Then</span>
sFilePath = Replace(sFilePath, cSlash, cBSlash, <span style="color: #0000ff;">1</span>, -<span style="color: #0000ff;">1</span>, vbTextCompare)
i = InStrRev(sFilePath, <span style="color: #0000ff;">"."</span>, -<span style="color: #0000ff;">1</span>, vbTextCompare)
s = right(sFilePath, len(sFilePath) - i + iif(fDot, <span style="color: #0000ff;">1</span>, <span style="color: #0000ff;">0</span>))
<span style="color: #000080; font-weight: bold;">else</span>
s = sFilePath
<span style="color: #000080; font-weight: bold;">End</span> <span style="color: #000080; font-weight: bold;">If</span>
ExtractFileSuffix = s
<span style="color: #000080; font-weight: bold;">End</span> <span style="color: #000080; font-weight: bold;">Function</span>

<span style="color: #000080; font-weight: bold;">Function</span> ExtractFilePath(sFilePath)
sFilePath = Replace(sFilePath, cSlash, cBSlash, <span style="color: #0000ff;">1</span>, -<span style="color: #0000ff;">1</span>, vbTextCompare)
ExtractFilePath = Left(sFilePath, InStrRev(sFilePath, cBSlash))
<span style="color: #000080; font-weight: bold;">If</span> Left(ExtractFilePath, <span style="color: #0000ff;">1</span>) = cDQ <span style="color: #000080; font-weight: bold;">Then</span> ExtractFilePath = Right(ExtractFilePath, Len(ExtractFilePath) - <span style="color: #0000ff;">1</span>)
<span style="color: #000080; font-weight: bold;">End</span> <span style="color: #000080; font-weight: bold;">Function</span>
</pre>
</div>
<p><strong>Commandline Aufruf von 7z.exe<br /> </strong> <a href="http://sevenzip.sourceforge.jp/chm/cmdline/switches/index.htm" data-cke-saved-href="http://sevenzip.sourceforge.jp/chm/cmdline/switches/index.htm">Alle Schalter erklärt in Englisch</a></p>
<table border="0" class="cke_show_border" cellspacing="3" cellpadding="5">
<tbody>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td valign="top">-p</td>
<td valign="top">Passwort</td>
<td>Wird ohne ein Leerzeichen nach dem Optionsschalter angegeben. Sollte das PW ein Leerzeichen enthalten dann muss es mit Anführungszeichen gekapselt werden.</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td colspan="3">Spezielle Parameter fürs Packen</td>
</tr>
<tr>
<td>-sfx</td>
<td>&nbsp;</td>
<td>Ein selbstenpackendes Archiv erzeugen (*.exe)</td>
</tr>
<tr>
<td>-mhe</td>
<td>&nbsp;</td>
<td>
<div>Betrachten der Dateiliste und Struktor des Archivs unterbinden</div>
</td>
</tr>
<tr>
<td valign="top">-m{0..9}</td>
<td>&nbsp;</td>
<td>-m{Parameters}: Kompressionsrate (0-nicht komprimieren...5-default...9-maximal)</td>
</tr>
<tr>
<td valign="top">&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td valign="top">
<div>-t{ArrchiveType}</div>
</td>
<td>&nbsp;</td>
<td>ohne Angabe dieses Parameters wird der Archiv-Typ nach Dateiendung verwendet.<br />
<div>Mögliche Archivtypen: 7z, split, zip, gzip, bzip2, tar</div>
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td colspan="3">Entpacken Parameter</td>
</tr>
<tr>
<td>-o</td>
<td>&nbsp;</td>
<td>Zielordner für die zu entpackenden Dateien</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</tbody>
</table>
<div>&nbsp;</div>
<p><strong><span style="text-decoration: underline;">Packen:</span></strong></p>
<div><strong>Befehl:</strong> a (Packen)<br />
<div><strong>Archiv-Datei:<span style="color: #0000ff;"> </span></strong>z.B <span style="color: #0000ff;">c:\sicherung\daten.7z<br /> </span><strong>Quell-Daten:</strong><span style="color: #0000ff;"> </span><span style="color: #800000;">Datei.Liste durch Leerzeichen getrennt</span><span style="color: #800000;">. Platzhalter möglich * (Asterix) und ?</span><br /><span style="color: #0000ff;"> </span></div>
<strong>7z.exe</strong> <span style="color: #ff0000;">a</span> -p "geheimes Passwort" -mhe <span style="color: #0000ff;">Zieldatei </span>(mit .7z als Prefix) <span style="color: #800000;">Quell-Datei1 Quell-Datei2 ...</span></div>
<p>&nbsp;</p>
<div><span style="text-decoration: underline;"><strong>Entpacken: </strong></span></div>
<div><strong>Befehl:</strong><br /> <span style="color: #ff0000;">e</span> (entpacken ohne Rücksicht auf die Quellpfade. Es wird in den Zielordner entpackt. Gleiche Datei-Namen im Archiv für dazu das Dateien überschrieben werden)</div>
<div><span style="color: #ff0000;">x</span> (entpacken in die relative Ordnerstrucktur der Original-Pfade)<br />
<div><strong>Archiv-Datei: </strong>z.B <span style="color: #0000ff;">c:\sicherung\daten.7z</span></div>
<strong>Zielpfad: </strong>z.B&nbsp; <span style="color: #800000;">c:\test </span></div>
<div><strong>7z.exe</strong> <span style="color: #ff0000;">x</span> -p "geheimes Passwort" -o<span style="color: #800000;">Zielordner </span><span style="color: #0000ff;">7Zip-Archiv.</span></div>
<div>&nbsp;</div>