Home

PDF Batch-Programmierung

image

Contents

1. Wird eine negative zweite Zahl eingesetzt so gibt ihr Betrag an wie viele Zeichen vom Rest ab rechts bergangen werden sollen Dieser Ausdruck liefert daher ebenfalls al M chte man beispielsweise nur einen Teil der Zeichenkette ab links so ist nach diesen Regeln als erste Zahl eine Null anzugeben set str Hallo set str str 0 2 echo str Dieser Ausdruck liefert daher Ha Mehr zu Stringmanipulation 5 7 Arithmetische Operationen set a Seit Windows NT 4 kann man mit dem set Befehl auch rechnen Ein Beispiel set a 1 2 3 Man kann das Ergebnis auch in Variablen schreiben set a n 5 5 10 echo n 10 CMD nimmt Folgendes entgegen Auszug aus der Hilfe O Gruppierung t7 un re Operatoren h arithmetische Operatoren bedeutet Modulo arithmetische Operatoren lt lt gt gt logische Verschiebung amp bitweise UND bitweise exklusives ODER bitweise ODER x f Zuordnung Trennzeichen fiir Ausdriicke Mit Klammern set a 1 1 4 3 2 Modulo Zeichen muss zweimal hintereinander geschrieben werden set a 11 5 1 6 http www dostips com DtTipsStringManipulation phpt t_Toc135152735 44 Ein und Ausgaben in Variablen speichern set p 5 8 Ein und Ausgaben in Variablen speichern set p 5 8 1 Benutzereingaben Seit Windows 2000 kann man mit dem set Befehl auch Eingaben abfragen und einer Variable z
2. Beispiel set set 1 amp start dpnx0 min cmd c 0 r amp set amp goto eof http www google de url sa tksource web amp ct res amp cd 1k amp ved 0CAgQF j AAkurl http34 2F 2Fwww microsoft com 2Fdownloads 2Fdetails aspx 3FFamilyIDf 3D9D467 A69 57FF 4AE7 96EE B18C4790CFFD amp rct jkq ms resourcetkitkei SEtGS8H6FYfM Qai2tRtg usg AFQjCNEU130wz1C_161SaIBsG99a7Lccrg http groups google co uk group alt msdos batch nt msg d11e951a822bc420 dmode source ol Programmierungshilfen 52 Noch eine Variante der oben gezeigten Beispiele die bei mir funktioniert da ich mit der Konstruktion ohne Labels auf einem x64 System Probleme hatte if 1 start min cmd exe C dpnx0 x amp goto eof 6 0 12 Mittels start LOW die Priorit t festlegen Manchmal ist es hilfreich wenn die Batchdatei mit einer niedrigen Priorit t l uft Das kann man mittels start LOW erreichen Weitere Optionen sind NORMAL HIGH REALTIME ABOVENORMAL und BELOWNORMAL Das Beispiel zeigt wie eine Batchdatei quasi sich selber in die niedrige Priorit t versetzten kann In dem Fall klappt es allerdings nur wenn beim ersten Start kein Parameter tibergeben wurde echo off if wy ques start WAIT LOW B cmd exe V C sO weiter_machen goto eof echo Jetzt laufe ich mit niedriger Priorit t echo berpr fe es im Taskmanager pause Funktionsweise Das Prinzip ist eigentlich ganz einfach Wenn kein Parameter berge b
3. If conditions are imposed on you whether by court order agreement or otherwise that contradict the conditions of this License they do not excuse you from the conditions of this License If you cannot con vey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations then as a con sequence you may not convey it at all For example if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program the only way you could satis fy both those terms and this License would be to refrain entirely from conveying the Program 13 Use with the GNU Affero General Public License Notwithstanding any other prov you have permis sion to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single com bined work and to convey the resulting work The terms of this License will continue to apply to the part which is the covered work but the special requirements of the GNU Affero General Public License s tion 13 concerning interaction through a network will apply to the combination as such 14 Revised Versions of this License The Free Software Foundation may publish revised and or new versi ons of the GNU General Public License from time to time Such new versions will be similar in spirit to the present version but may differ in detail to address
4. The Title Page means for a printed book the title page itself plus such following pages as are needed to hold legibly the material this Li requires to appear in the title page For works in formats which do not have any title page as such Title Page means the text ne ar the most prominent appearance of the work s title preceding the beginning of the body of the text The publisher means any the Document to the public person or entity that distribut opies of A section Entitled XYZ means a named subunit of the Document whose title either is precisely XYZ or contains XYZ in parentheses following text that translates XYZ in another language Here XYZ stands for a spec ction name mentioned below such as Acknow ledgements Dedications Endorsements or History To Pre serve the Title f such a section when you modify the Document means that it remains a section Entitled XYZ ccording to this definition The Document may include Warranty Disclaimers next to the noti which states that this License applies to the Document These War ranty Disclaimers are considered to be included by reference in this License but only as regards disclaiming warranties any other impli cation that these Warranty Disclaimers may have is void and has no effect on the meaning of this License 2 VERBATIM COPYING You may copy and distribute the Document in any medium either commercially or noncomme
5. CAL ENABLEEXTENSIONS aktiviert werden Hier das korrekte Beispiel echo off SetLocal EnableDelayedExpansion echo Die aktuelle Zeit ist time 0 8 echo bitte 5 Sec warten ping 1 2 3 4 n 1 w 5000 gt NUL echo jetzt sind 5 Sec vergangen TIME liefert TIMEZ das ist OK echo Jetzt gibt auch die FOR Schleife die korrekte Zeit aus for L AN IN 0 1 3 DO echo TIME pause echo echo Auch in z amp nbsp B IF Schleifen ist es jetzt richtig if TRUE TRUE echo 1 Zeit in der If Schleife TIME 2 48 Kapitel 2 23 auf Seite 14 muss unbedingt Befehl SETLO Ein und Ausgaben in Variablen speichern set p echo Warte 5 Sec ping 1 2 3 4 n 1 w 5000 gt NUL echo 2 Zeit in der If Schleife TIME echo Warte nochmals 5 Sec ping 1 2 3 4 n 1 w 5000 gt NUL echo 3 Zeit in der If Schleife TIME echo Es ist jetzt TIME EndLocal pause 6 0 5 Ausgaben besser anzeigen Wenn man nicht die Ausgabe von Befehlen per echo off Ausblendet kann man am besten das Prompt ndern sodass man besser erkennen kann was passiert prompt G Der Prompt ist dann gt 6 0 6 Unterroutinen und Unterprogramme Unterroutinen kann man mittels goto oder call und Unterprogramme mit Hilfe von call realisieren call unterroutine Hallo echo Fertig goto eof unterroutine echo Ubergebener Parameter an Unterroutine 1 goto eof Beachten Sie dass Sie beim Aufruf von Unterrout
6. http www computerhope com forum index php topic 107102 0 Kapitel 5 auf Seite 39 SETLOCAL ENDLOCAL c gt set VARIABLENNAME test2 c gt echo VARIABLENNAMEY test2 C gt set p test Dies ist ein Test 3 28 SETLOCAL ENDLOCAL Syntax e Windows XP SETLOCAL SETLOCAL EnableDelayedExpansion SETLOCAL EnableExtensions DisableExtensions Links e http ss64 com nt setlocal html Siehe auch Batchbefehle Variablen und Set Befehl 3 29 TIME Gibt die aktuelle Zeit aus und erm glicht dem Benutzer die nderung der Uhrzeit Wird der Befehl mit dem Parameter t aufgerufen so wird nur die aktuelle Zeit ausgegeben time kann auch als Variable benutzt werden so kann man zum Beispiel mit time 0 5 die ersten 5 Zeichen tibernehmen Beispiele C gt time Aktuelle Zeit 10 03 04 63 Geben Sie die neue Zeit ein c gt echo time 10 03 04 63 c gt echo time 0 5 10 03 Bei einigen Betriebssystemversionen erfordert das Andern der Systemzeit administrative Rechte 3 30 TITLE Dieser Befehl ndert die Fenstertiberschrift des Programmfensters title Beispiel 22 Kapitel 5 auf Seite 39 23 Kapitel 3 29 auf Seite 33 33 4 Batch Operatoren 4 1 amp Befehlsverkettung mehrere Batch Befehle in einer Zeile k nnen hintereinander ausgef hrt werden Syntax befeh11 amp befehl2 Stapelanweisung Ab bis Windows 7 Beispiel Inhalt echo Hallo amp echo und Tsch
7. rungsfenster offen bleibt So kann man Ausgaben nachlesen oder evtl aufgetretene Fehler entdecken Nun k nnte man einfach am Ende eine pause einfiigen Dabei kann der User einfach das Fenster schlie en oder ENTER dr cken Man kann aber auch einfach eine zeitliche Pause mit ping realisieren echo off echo Ich schlie e gleich ping localhost n 2 gt NUL Dabei kann man die Zeit mit dem Parameter n variieren Bei installiertem ResourceKit steht der Befehl sleep zur Verf gung welcher dieselbe Funktionalitat zeitliche Pause bietet 6 0 11 Minimiert ausf hren Hin und wieder ist es sinnvoll dass die Batchdatei minimiert ausgef hrt wird z B eine Login Batch Datei Es ist m glich dass man die Batchdatei normal startet und sie sich selber minimiert ausf hrt Der Nachteil ist allerdings dass sich kurzzeitig ein Eingabeaufforderungs Fenster ffnet echo off if not 1 goto 1 start MIN cmd exe C nxO begin goto eof begin echo Hallo ich laufe minimiert pause goto eof Noch eine Konstruktion ganz ohne Labels nach diesem Newsgroup Beitrag set set 1 amp start dpnx0 min cmd c 0 r amp set amp goto eof Anmerkung Sollte die Command Processor Option DelayedExpansion in der Registry aktiviert sein siehe unter Hilfe cmd l sst sich ein als Variablenname nicht verwenden In diesem Fall bzw sinnvollerweise immer den Variablennamen ndern auf x oder y oder oder
8. Auferdem sind oftmals mehrere Durchg nge n tig bis das Laufwerk wirklich vollst ndig defragmentiert ist Mit dieser kleinen Batch Datei werden alle Partitionen immer wieder hintereinander defragmentiert Wenn man wieder arbeiten will kann man einfach das Eingabefenster schliefen Auch bei laufendem defrag passiert dabei nichts weil defrag im Hintergrund die aktuelle Arbeit sauber beendet Damit aber nicht defekte Laufwerke einfach blind defragmentiert werden habe ich eine etwas aufwendige Prozedur eingebaut die die Laufwerke mit chkdsk erst berpr ft Wenn dabei ein Fehler auftritt wird mit fsutil das dirty Bit gesetzt Das bewirkt dass beim n chsten Systemstart die Fehler behoben werden Au erdem werden die Partitionen in dem loop ausgelassen welche schon als dirty markiert sind Eine kleine Routine war auch n tig damit Netzwerklaufwerke ausgelassen werden echo off cd d C loop for hi in c d e f g h i j k l1 m n o p q r s t u v w x y z do if exist i NUL call defrag Zhi echo echo pause ping localhost n 10 gt NUL goto loop defrag call check 1 69 Beispiele if ok nein echo Laufwerk 1 wird ausgelassen echo goto eof echo echo echo chkdsk 1 v chkdsk 1 if errorlevel NEQ O if errorlevel NEQ 2 echo 1 chkdsk Fehler echo Errorlevel errorlevel echo echo setzte dirty Bit fsutil dirty set 1 echo echo Versuche Reparatur chkdsk 1 v
9. OOONNNAN RR SR RR RRE RA OGCUI CH RS ee BNO NMNNNMNNFRFP CG FP PR HA OO 15 15 15 15 16 16 17 18 III Inhaltsverzeichnis o ey Sh pda dat bee aad BE eae Bos deta OOF ACU a ee eee Oe oii Dir teas E A A ceed thee els ESO a doe Bret at ENCODER A ee ee A 3 12 COMMAND 3 ouaaa le Hed ro have El 313 IT ps on hoe teen Ni ob a ab ak eae aed eda Beas SI ECHO AAA 3 15 ERRORLEVEL a a Biche ee ge ka she ad it 3 16 ENDLOCAL SETLOCAL 0 a cee eee ae SUT LI tak GAM A E waded liv Re Are Maes Dele OD se tei RI E a cok ee he ER IE ET GE A re OE anna Ges cies WR Ae SE DEEE te x Bx Bee dh phat Rites ah iad bela a Bets ote hes gs SOMME VE scat mics ay IAN 399 PAUSE al ade rca tios Mth re ee ne 393 PROMPT AR A AAA lead 3 24 PUSHD POD cn 2 2 a ae will ote ah ODE A A A 326 RENAME A ee Ga ai ate dd hts see De SD E nin ao rie eek Ae tenets Boat eae nes Ae BSD ae deed RUS el 3 28 SETLOCAL ENDLOCAL doe ak wegen neat han te seth en tet 329 TIME ists a ict dors doc tag en Ns He Gt ek rr Se a Shh ork 330 TITLE dei Sa Bos a Sean ane aed ate Deere 4 Batch Operatoren AN OE AS IA tee Bde AS TS tec RE Re te BL es ee NY ea 5 Erweiterungen unter Windows NT 5 1 Variablen Kurz bersicht 2 2 22 oo nor nn 5 2 Variablenerstellung zuweisung und abruf o 5 3 G ltigkeitsbereich von Variablen 5 4 Umgebungsvariablen Windows Environment Variables 5 5 Weitere Variabl
10. Translation is considered a kind of modification so you may di translations of the Document under the terms of section 4 Replacing Invariant Sections with translations requires special permission from their copyright holders but you may include translations of some or all Invariant Sections in addition to the original versions of these Inva riant Sections You may include a translation of this License and all the license notices in the Document and any Warranty Disclaimers provided that you also include the original English version of this Li cense and the original versions of those notices and disclaimers In case of a disagreement between the translation and the original version of this License or a notice or disclaimer the original version will prevail Tf a ser tions ion in the Document is Entitled Acknowledgements Dedica or History the requirement section 4 to Preserve its Title You should have received a copy of the GNU General Publi along with this program If not see lt http www gnu org lic Also add information on how to contact you by electronic and paper mail If the program does terminal interaction make it output a short notice like this when it starts in an interactive mode lt program gt Copyright C lt year gt lt name of author gt This program comes with ABSOLUTELY NO WARRANTY for details type show w This is free software and you are welcome to redistri
11. erase L scht eine Datei die sich im aktuellen Verzeichnis befindet Als Parameter muss mindestens der Dateiname angegeben werden Weitere Parameter sind optional e p sollen mehrere Dateien gel scht werden muss jede einzelne L schung best tigt wer den e f auch schreibgesch tzte Dateien werden gel scht e s l scht auch Dateien die sich in den Unterverzeichnissen befinden e q Unterbindet Best tigung Beispiel erase H zul schendedatei bat Wichtige DOS Kommandos 2 8 deltree L scht Verzeichnis se inkl untergeordnete Dateien Unter Windows XP lautet der Befehl rmdir Deltree kennt es nicht mehr Anmerkung rmdir rd versteht keine Wildcards oder im Verzeichnisnamen 2 9 dir Der Befehl dir directory zeigt alle Verzeichnisse und Unterverzeichnisse an Verzeichnisse werden seit Windows 95 als Ordner bezeichnet unterscheiden sich allerdings nicht von Verzeichnissen Der dir Befehl hat zahlreiche Optionen e b Nur der Dateiname wird ausgegeben Die Ausgabe aller weiteren Informationen wie beispielsweise Datum Gr e oder Datentr gerbezeichnung wird unterdr ckt e c Die Dateigr e wird mit einem Punkt als Trennzeichen zwischen jeweils drei Dezimal stellen angegeben also beispielsweise 343 232 Standardeinstellung Soll dies unterdr ckt werden geben Sie als Option c an e p Bei jedem Seitenumbruch wird die Ausgabe unterbrochen bis der Anwender eine Taste dr ckt
12. m glich z B dp0 Laufwerk Pfad 8 0 16 Alle verf gbaren PCs im aktuellen Netzwerk suchen Dieses Batch Skript pingt alle IP Adressen eines IP Bereichs an und zeigt dann die PCs an die verf gbar sind echo off if exist ips txt del ips txt gt nul echo Bitte geben Sie den ersten Teil der IP ein set p ip for L N IN 1 1 255 DO echo Die IP ip N wird nun angepingt ping ip h N n 1 w 1 find TTL amp amp echo ZiphAAN gt gt ips txt cls type ips txt pause gt nul Hinweis Die Datei ips txt wird nicht gel scht damit man sie fiir weitere Zwecke benutzen kann 8 0 17 Hosts Datei mit einem Aliasnamen und der aktuellen IP Adresse aktualisieren H ufig werden Webserver oder hnliche Programme unter Angabe eines Aliasnamens installiert damit sie leicht auf einen anderen Rechner verschoben werden k nnen falls der urspr ngliche Rechner defekt ist Oder die Aplikationl uft unter VM Ware auf einen Laptop bei dem sich die IP Adressen h ufig ndern Dann kann mit dem Skript der Host namenalias mit der aktuellen IP Adresse aktualisiert werden Idealerweise wird das Script automatisch beim Start von Windows oder beim Anmelden des Anwenders ausgef hrt echo off set HOST_ALIAS myserver myserver mydomain org set HOST_FILE SystemRoot System32 drivers etc hosts set TEMP_FILE TEMP hosts tmp REM vorhandenen Eintrag entfernen und den Rest in TEMP Datei schreiben type HOST_FILEY find v myser
13. mewhere other than this MMC and subsequently incorporated in whole or in part into the MMC 1 had no cover texts or invariant sections and 2 were thus incorporated prior to November 1 2008 s License singif it is licensed under thi The operator of an MMC Site may republish an MMC contained in the site under CC BY SA on the same site at any time before August 1 2009 provided the MMC is eligible for relicensing ADDENDUM How to use this License for your documents To use this Li n a document you have written include a copy of the License in the document and put the following copyright and license notices just after the title page Copyright C YEAR YOUR NAME Permission is granted to copy distribute and or modify this document under the terms of the GNU Free Documentation License Version 1 3 or any later version publis hed by the Free Software Foundation with no Invariant Sections no Front Cover Texts and no Back Cover Texts A copy of the license is included in the section entitled GNU Free Documentation Licens ions Front Cover Texts and Back Cover Texts line with thi If you have Invariant Sec Texts replace the with with the Invariant Sections being LIST THEIR TITLES with the Front Cover Texts being LIST and with the Back Cover Texts being LIST If you have Invariant Sections without Cover Texts or some other combination of the three merge those two alternati
14. provided that you also meet all of these conditions a The work must carry prominent notices stating that you modified it and giving a relevant date b The work must carry prominent notices stating that it is released under this License and any conditions added under section 7 This requirement modifies the requirement in ion 4 to keep intact all notices c You must license the entire work as a whole under this License to anyone who comes into pos session of a copy This License will therefore apply along with any applicable section 7 additional terms to the whole of the work and all its parts regardless of how they are packaged This License gives no permission to license the work in any other way but it does not invalidate such permission if you have separately received it d If the work has interactive user interfaces each must display Appropriate Legal Notices however if the Program has interactive interfaces that do not display Appropriate Legal Notices your work need not make them do so A compilation of a covered work with other separate and independent works which are not by their nature extensions of the covered work and which are not combined with it such as to form a larger program in or on a volume of a storage or distribution medium is called an aggregate if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation s
15. tangible personal property which is normally used for personal family or household purposes or 2 anything designed or sold for incorpora tion into a dwelling In determining whether a product is a consumer product doubtful cases shall be resolved in favor of coverage For a particular product received by a particular user normally used re fers to a typical or common use of that class of product regardless of the status of the particular user or of the way in which the particular user actually uses or expects or is expected to use the product A product is a consumer product regardless of whether the product has substantial commercial industrial or non consumer uses unless such uses represent the only significant mode of use of the product Installation Information for a User Product means any methods pro cedures authorization keys or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made If you convey an object code work under this section in or with or specifically for use in a User Product and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to
16. 2 2 Das hei t nicht dass unter Windows NT und Nachfolgern der Befehl set a 1 keinen Effekt h tte sondern dieser wird in einer gesch tzten Umgebung ausgef hrt die dann au erhalb dieser Umgebung keinen Effekt mehr hat F r die aufgerufene Variante von command ist a nach dem set Befehl sehr wohl gleich 1 41 Erweiterungen unter Windows NT 5 3 2 Giiltigkeitsbereich setzen setlocal Mit dem Befehl setlocal l sst sich der G ltigkeitsbereich von Variablen kontrollieren F r weitere Informationen helfen folgende Links e http ss64 com nt setlocal html e http technet microsoft com en us library bb491001 aspx Noch eine nderung Variable betreffend 5 4 Umgebungsvariablen Windows Environment Variables Umgebungsvariablen werden verwendet um Variablen anwendungs bergreifend und skript bergreifend zu speichern e Umgebungsvariablenreferenz auf ss64 com e Anleitung zur Nutzung von Umgebungsvariablen auf vlaurie com e Weitergehende allgemeine Informationen zu Umgebungsvariablen auf de wikipedia org 2 3 5 5 Weitere Variablenarten Parameter lassen sich bedingt mit Variablen vergleichen und werden zur Werte berga be beim Aufrufen von Batchdateien verwendet Auch bei For Schleifen wird eine Art Parametervariable verwendet 5 5 1 bergabeparameter Syntax e Windows XP batchdateiname cmd PARAMETER PARAMETER2 PARAMETERS Web Links e Windows XP Professional Product Documentation e http w
17. 25 words A Transparent copy of the Document means a machine readable copy represented in a format whose specification is available to the general public that is suitable for revising the document straightfor wardly with generic text editors or for images composed of pixels ge neric paint programs or for drawings some widely available drawing editor and that is suitable for input to text formatters or for automatic translation to a variety of formats suitable for input to text formatters A copy made in an otherwise Transparent file format whose markup or absence of markup has been arranged to thwart or discourage sub quent modification by readers is not Transparent An image format not Transparent if used for any substantial amount of text A copy that is not Transparentis called Opaque Examples of suitable formats for Transparent copies include plain ASCII without markup Texinfo input format LaTeX input for mat SGML or XML using a publicly available DTD and standard conforming simple HTML PostScript or PDF designed for human mo dification Examples of transparent image formats include PNG XCF and JPG Opaque formats include proprietary formats that can be re ad and edited only by proprietary word processors SGML or XML for which the DTD and or processing tools are not generally available and the machine generated HTML PostScript or PDF produced by some word processors for output purposes only
18. Batch 11 W ichtige DOS Kommandos So kann man zum Beispiel mit more C eins txt gt gt D zwei txt den Inhalt der eins txt an den Inhalt der zwei txt anh ngen eins txt wird dabei nicht ver ndert 2 16 move Verschieben von einer oder mehrerer Dateien von einem Verzeichnis in ein anderes oder ein Verzeichnis umbenennen move test test_neu 2 17 path Durch die Angabe eines Pfades wird das Betriebssystem auf der Kommandozeile dazu aufgefordert neben dem aktuellen Verzeichnis auch in weiteren Verzeichnissen zu suchen Wird der Befehl ohne Parameter ausgef hrt so werden alle aktuellen Pfade ausgegeben 2 18 rd rmdir Der Befehl rd oder rmdir remove directory l scht ein Verzeichnis wenn dieses leer ist Parameter e s L scht einen ganzen Verzeichnisbaum mit Dateien e q L scht ohne Nachfrage ganze Verzeichnisb ume Kann in Batch Dateien praktisch sein Der Verzeichnisname darf keine Wildcards enthalten oder rmdir s q C temp 12 2 19 ren oder rename Datei en umbenennen 2 20 start Syntax START Titel D lt Pfad gt I MIN MAX SEPARATE SHARED LOW NORMAL HIGH REALTIME WAIT B Befehl Programm Parameter Optionen e Titel Der Titel des neuen Fensters e D lt Pfad gt Startverzeichnis e I Die neue Umgebung soll die dem CMD EXE beim Aufruf bergebene sein und nicht die aktuelle Umgebung e MIN Sta
19. Doppelpunkt hat auch die Funktion der Manipulation von Variablen wenn er direkt hinter einer Variablen steht Siehe Kapitel Variablen in dieser Publikation OD Mau 16 http ss64 com nt delayedexpansion html http stackoverflow com questions 15309422 batch adding users to multiple groups through for loop http de wikipedia org wiki Allokation_ 28Informatik 29 http ss64 com nt delayedexpansion html doppelter Doppelpunkt Syntax NAMEDERSPRUNGMARKE Sprungmarken k nnen eine beliebige L nge haben unter MS DOS und lteren Windows Versionen werden allerdings nur die ersten 8 Zeichen beachtet der Rest wird ignoriert Kommen in einer Batch also Sprungmarkel und Sprungmarke2 vor so wird unter Um st nden nur die erste beim Aufruf einer der Beiden gefunden Also besser ziel1 oder 1st schreiben Grof und Kleinschreibung wird nicht unterschieden Man kann jedoch mithilfe von Anf hrungszeichen daf r sorgen dass der komplette Sprungname beachtet wird Beispielsweise Sprungname Wenn man den kompletten Code mit Sprungmar ken verbindet kann man zur besseren Unterscheidung verschiedener Sprungmarken eine Leerzeile verwenden Beispiel Inhalt if exist C blabla txt goto EDITBLA goto END Kommentarzeile sofern es erforderlich ist einen Kommentar zu schreiben Zur Unterscheidung von Sprungmarken verwende ich zwei EDITBLA edit c blabla txt END Sofern die Datei C blabla txt existier
20. Zeigt alle Dateien im Verzeichnis temp an Es werden nur Dateien keine Verzeich nisse angezeigt Um Verzeichnisse anzuzeigen siehe Liste der FOR Optionen unten Der Parameter R bewirkt dass alle Unterverzeichnisse mit einbezogen werden Rekursive Schleife Inhalt echo off for R temp AL in do echo hf REM Den Befehl k nnte man auch einzeilig schreiben pause Ausgabe Alle Temp Dateien Bitte beliebige Taste driicken 12 24 Kapitel 3 1 auf Seite 15 FOR Z hlschleifen Mit solchen Schleifen kann man Aktionen eine bestimmte Anzahl oft ausf hren Dazu muss man den Parameter L angeben Syntax for L Variable IN Startzahl Schrittweite Endzahl DO Aktion REM Schreibe Text 5 Mal for L N IN 1 1 5 DO echo Nummer N Ausgabe C gt for L N IN 1 1 5 DO echo Nummer N C gt echo Nummer 1 Nummer 1 C gt echo Nummer 2 Nummer 2 C gt echo Nummer 3 Nummer 3 C gt echo Nummer 4 Nummer 4 C gt echo Nummer 5 Nummer 5 verschachtelte Z hlschleife for L AN IN 1 1 5 DO for L N IN 1 1 N DO echo Nummer N Ausgabe C gt for L N IN 1 1 5 DO for L N IN 1 1 N DO echo Nummer N C gt for L N IN 1 1 1 DO echo Nummer N C gt echo Nummer 1 Nummer 1 C gt for L N IN 1 1 2 DO echo Nummer N C gt echo Nummer 1 Nummer 1 C gt echo Nummer 2 Nummer 2 C gt for L N IN 1 1 3 DO echo Nummer N C g
21. at least the title year new authors and publisher of the Modified Version as given on the Title Page If there is no section Entitled His the Document create one stating the title year authors and publisher of the Document as given on its Title Page then add an item describing the Modified Version as stated in the previous sentence J Preserve the network location if any given in the Document for publi to a Transparent copy of the Document and likewise the network locations given in the Document for previous versions it was based on These may be placed in the History ection You may omit a network location for a work that was published at least four years before the Document itself or if the original publisher of the version it i ion Entitled Acknowledge ments r Dedications Preserve the Title of the ion and preserve in the section all the substance and tone of each of the contributor acknowledgements and or dedications given therein L Preserve all imer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms reviewing courts shall apply local law that most closely approximates an absolu te waiver of all civil liability in connection with the Program unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee END OF TERMS AND CONDITIONS
22. e on Gibt das Verzeichnis alphabetisch sortiert aus e w Mehrere Eintr ge in einer Zeile werden angezeigt e ah Versteckte Dateien werden angezeigt e a Alle versteckten und System Dateien werden angezeigt e s Zeigt auch den Inhalt der Unterverzeichnisse an Mit dem Befehl dir Dateiname ist es auch m glich Dateien im aktuellen Verzeichnis zu suchen Alternativ kann auch der Platzhalter bspw dir verwendet werden um nach bestimmten Dateien zu suchen Mit dir werden nur Objekte ohne Dateinamen Erweiterung angezeigt In der Regel haben Ordner keine Erweiterung und Dateien eine Erweiterung In diesem Fall werden nur Ordner angezeigt Ordner werden im DOS mit vor dem Ordnernamen gekennzeichnet 2 9 1 Kombinationen dir w o s p durchsucht den aktuellen Pfad inklusive Unterordner nach einer Datei und stellt das Ergebnis seitenweise dar 10 edit 2 10 edit Mit edit wird ein Editor ge ffnet zum Beispiel zum Bearbeiten von Batch oder Textdateien 2 11 find Mit dem Befehl find kann auch in mehreren Dateien nach einer Zeichenfolge gesucht werden Auch find kann mit Parametern gesteuert werden find i ignoriert Gro Kleinschreibung beim Suchbegriff find v Zeigt alle Zeilen an die die Zeichenfolge NICHT enthalten find c Zeigt nur die Anzahl der die Zeichenfolge enthaltenden Zeilen an find n Zeigt die Zeilen mit ihren Zeilennummern an 2 12 format Formatiert die Festplatte o
23. its contributor version In the following three paragraphs a patent license is any expr agreement or commitment however denominated not to enforce a pa tent such as an express permission to practice a patent or covenant not to sue for patent infringement To grant such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party Tf you conve overed work knowingly relying on a patent license and the Corresponding Source of the work is not available for anyone to copy free of charge and under the terms of this License through a pu blicly available network server or other readily accessible means then you must either 1 cause the Corresponding Source to be so available or 2 arrange to deprive yourself of the benefit of the patent license for this particular work or 3 arrange in a manner consistent with the re quirements of this License to extend the patent license to downstream recipients Knowingly relying means you have actual knowledge that but for the patent license your conveying the covered work in a coun try or your recipient s use of the covered work in a country would infringe one or more identifiable patents in that country that you have eason to believe are valid If pursuant to or in connection with a single transaction or arrange ment you convey or propagate by procuring conveyance of a covered work and g
24. n tzliche Funktionalit t erweitern Mit Hilfe von mping erh lt man eine Nachricht sobald der gepingte Computer wieder erreichbar ist Um das Script global zu verwenden muss es z B als mping cmd in Windows Installationsordner System32 gespeichert werden und kann von nun an z B mit mping google com aufgerufen werden echo off wenn kein remote Host angegeben ist dann gehe zu Syntax IF 1 GOTO Syntax IF 1 GOTO Syntax IF 1 h GOTO Syntax IF 1 help GOTO Syntax 68 NET mainloop pinge den Host 1 mal und leite die Ausgabe nach nul um keine sichtbare Ausgabe ping 1 n 1 gt nul speichere den Errorlevel in die Variable status set status errorlevel sende eine Nachricht sobald der remote Host online ist if status 0 msg username 1 online amp amp exit 0 minimalistische Fortschrittsanzeige Set P i lt NUL sleep workaround wer eine bessere einfachere genauere amp universellere M glichkeit kennt bitte korrigieren pinge den lokalen Computer 10 mal ping localhost n 10 gt nul gehe zur ck zum anfang goto mainloop Syntax echo echo Syntax 7 n0 Hostname oder IP echo echo mping echo echo Pingt einen offline Host und gibt eine Meldung echo aus sobald er wieder online ist echo 8 0 14 Defrag mit Endlos Schleife Das eingebaute Defrag Tool erlaubt ja immer nur die gleichzeitige Defragmentierung eines Laufwerks
25. permissions of this License applicable to that copy 3 Object Code Incorporating Material from Library Header Files The object code form of an Application may incorporate material from a header file that is part of the Library You may convey such object code under terms of your choice provided that if the incorporated ma terial is not limited to numerical parameters data structure layouts and accessors or small macros inline functions and templates ten or fewer lines in length you do both of the following a Give prominent notice with each copy of the object code that the Library is used in it and that the Library and its use are covered by this License b Accompany the object code with a copy of the GNU GPL and this license document 4 Combined Works You may convey a Combined Work under terms of your choice that ta ken together effectively do not restrict modification of the portions of the Library contained in the Combined Work and reverse engineering for debugging such modifications if you also do each of the following a Give prominent notice with each copy of the Combined Work that the Library is used in it and that the Library and its use are covered by this License b Accompany the Combined Work with a copy of the GNU GPL and this license document c For a Combined Work that displays copyright notices during execution include the copyright notice for the Library among these notices as w
26. pfung kombiniert werden Bei einer ODER Verkniipfung wird der Code ausgef hrt sobald eine der Bedingungen wahr ist Wenn alle Bedingungen gepr ft wurden und keine erfolgreich war werden die Befehle im ELSE Zweig ausgef hrt set A true set B false if YA true goto WAHR Diese Zeile ist doch erf llt also sollte der in WAHR springen if B true goto WAHR REM keine der Bedingungen ist zu WAHR gesprungen wir sind also im ELSE Zweig REM hier waere FALSCH echo Weder A noch B ist TRUE goto eof WAHR echo A oder B ist TRUE F r ein UND wird in den ELSE Zweig gesprungen FALSCH sobald eine der Bedin gungen nicht zutrifft Nur wenn alle Bedingunen zutreffen wird der Code ausgef hrt set A true set B false if A NEQ true goto FALSCH if B NEQ true goto FALSCH REM wird sind durch die IFs gekommen also hat keine der Bedingungen angeschlagen REM hier waere die WAHR Sprungmarke echo A und B sind beide TRUE goto eof FALSCH echo A oder B oder beide sind FALSE Eine weitere gut lesbare UND Variante ist zwei oder mehrere IF Bedingungen nachein ander zu schreiben 29 Batch Befehle set Pi Frankreich set P2 Spanien if P1 Frankreich if P2 Spanien echo Die Nachbarl nder von Andorra sind P1 UND P2 Diese beiden Beispiele lassen sich einfach durch Kopieren der IF Zeile um beliebig viele Bedingungen erweitern Ein Mischen von UND u
27. program could make it effectively proprietary To prevent this the GPL assures that patents cannot be used to render the program non free The precise terms and conditions for copying distribution and modi fication follow TERMS AND CONDITIONS 0 Definitions This License refers to version 3 of the GNU General Public License Copyright also means copyright like la of works such as semiconductor masks that apply to other kinds The Program refers to any copyrightable work licensed under this Li cense Each licensee is addressed as you Licensees and recipients may be individuals or organizations To modify a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission other than the making of an exact copy The resulting work is called a modified version of the earlier work or a work based on the earlier work A covered work means either the unmodified Program or a work ba sed on the Program To propagate a work means to do anything with it that without per mission would make you directly or secondarily liable for infringement under applicable copyright law except executing it on a computer or modifying a private copy Propagation includes copying distribution with or without modification making available to the public and in some countries other activities as well To convey a work means
28. simultan von den Suchmaschinen durchsucht Findet man dann immer noch keine Antwort kann man die Frage in einem der gefundenen Foren sel ber stellen Zur Zeit aktive Foren f r Hilfestellungen bei der Erstellung von Batchdateien sind e Administrator de 11 2 Ungeordnete Links Seiten mit tutorien Referenzen Beispielen etc e bersicht der Unterschiede cmd Befehle in Windows XP Vista 7 http www script example com themen cmd_Batch_Befehle php e http www heise de ct 03 16 136 default shtm1 c t 16 2003 S 136 Windows Befehlszeile e http www ss64 com nt index html NT XP Batch Befehle en e http www admini de Umfangreiche Informationen ber Batchprogrammierung un ter NT 2000 XP e http www fpschultze de Batch Scripting Site mit vielen Beispielen e http sven of nine de site doku php faq batch Umfangreiche Funktions sammlung f r Batchprogrammierer e http www knowware de cat 6 1 amp book batch Leicht verst ndliche Einf hrung e http download knowware de batch pdf als PDF Download e http publibz boulder ibm com cgi bin bookmgr _0S390 BOOKS IEA2B510 englischsprachiges JCL Benutzerhandbuch e http www plogmann net w 2 54 index htm Optionen des Befehls XCOPY e http www antonis de dos download Diverse Beispielskripte e http www easy coding de shellscripting html s 5fb492fd4b515b0c880795a6a7d92ef5c4aed29c Forum ber Shellscripting e http home mnet online de horst muc maind htm Eine Samml
29. ss Ausgabe Hallo und Tsch ss 4 2 Befehlsverkettung mittels pipe der zweite Befehl bekommt die Ausgabe des ersten Befehls als Eingabe Syntax befehli befehl2 Stapelanweisung Ab DOS nur f r more als zweiter Befehl allgemein verwendbar ab WindowsNT bis Windows 7 Beispiel Inhalt type test txt more Ausgabe Zeile 1 Zeile 2 Zeile 24 More nach Dr cken einer beliebigen Taste werden die n chsten Zeilen angezeigt 4 3 amp amp bedingte Befehlsverkettung der zweite Befehl wird nur ausgef hrt wenn der erste Befehl erfolgreich war Syntax befehl1 amp amp befehl2 Stapelanweisung Ab bis Windows 7 Beispiel Inhalt copy test txt test2 txt amp amp echo Kopieren erfolgreich 35 Batch Operatoren 36 Ausgabe Kopieren erfolgreich falls test txt existiert und nach test2 txt kopiert werden konnte 4 4 bedingte Befehlsverkettung der zweite Befehl wird nur ausgefiihrt wenn der erste Befehl fehlschlug Syntax befehl1 befehl2 Stapelanweisung Ab bis Windows 7 Beispiel Inhalt copy test txt test2 txt echo Fehler beim Kopieren Ausgabe Fehler beim Kopieren falls test txt nicht existiert oder test2 txt nicht geschrieben bzw berschrieben werden konnte 4 5 lt Umleitung der Eingabe Syntax befehl lt file Beispiel Inhalt echo Hallo gt tmp txt set P v lt tmp txt echo v Ausgabe Hallo set P v w rde eine Zeile
30. the recipient in perpetuity or for a fixed term regardless of how the transaction is characterized the Corresponding Source conveyed under this section must be accompanied by the In stallation Information But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product for example the work has been installed in ROM The requirement to provide Installation Information does not include a requirement to continue to provide support service warranty or up en modified or installed by the rec for the User Product in which it has been modified or installed Acc to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network ss Corresponding Source conveyed and Installation Information provi ded in accord with this section must be in a format that is publicly documented and with an implementation available to the public in code form and must require no special password or key for unpacking reading or copying 7 Additional Terms soure Additional permissions are terms that supplement the terms of this License by making exceptions from one or more of its conditions Ad ditional permissions that are applicable to the entire Program shall be treated as though they were included in this License to t
31. users beyond what the individual works permit Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate 6 Conveying Non Source Forms You may convey a covered work in object code form under the terms of sections 4 and 5 provided that you also convey the machine readable Corresponding Source under the terms of this License in one of these ways a Convey the object code in or embodied in a physical product in cluding a physical distribution medium accompanied by the Corre sponding Source fixed on a durable physical medium customarily used for software interchange b Convey the object code in or embodied in a physical product including a physical distribution medium ac companied by a written offer valid for at least three years and valid for as long as you offer spare parts or customer support for that pro duct model to give anyone who possesses the object code either 1 a copy of the Corresponding Source for all the software in the product that is covered by this License on a durable physical medium custo marily used for software interchange for a price no more than your reasonable cost of physically performing this conveying of source or 2 access to copy the Corresponding Source from a network server at no charge c Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source This alte
32. Batch Programmierung de wikibooks org 26 August 2014 On the 28th of April 2012 the contents of the English as well as German Wikibooks and Wikipedia projects were licensed under Creative Commons Attribution ShareAlike 3 0 Unported license A URI to this license is given in the list of figures on page 87 If this document is a derived work from the contents of one of these projects and the content was still licensed by the project under this license at the time of derivation this document has to be licensed under the same a similar or a compatible license as stated in section 4b of the license The list of contributors is included in chapter Contributors on page 83 The licenses GPL LGPL and GFDL are included in chapter Licenses on page 91 since this book and or parts of it may or may not be licensed under one or more of these licenses and thus require inclusion of these licenses The licenses of the figures are given in the list of figures on page 87 This PDF was generated by the ATEX typesetting software The KIEX source code is included as an attachment source 7z txt in this PDF file To extract the source from the PDF file you can use the pdfdetach tool including in the poppler suite or the http www pdflabs com tools pdftk the pdf toolkit utility Some PDF viewers may also let you save the attachment to a file After extracting it from the PDF file you have to rename it to source 7z To uncompress the resulting archive we recommend
33. Eignet sich besonders bei Standard Drucksprachen wie Postscript und HPGL 2 echo off rem pl bat sendet einzelne Druckdateien an bel Drucker direkt rem eignet sich besonders bei Standard Drucksprachen wie Postscript und HPGL 2 rem Laesst sich in Windows bequem einbinden z B rechte Maustaste Senden an Plotter voreingestellt set server 192 168 0 5 rem server IP von Printserver oder Name von Freigaberechner set druckerbeschreibung 192 168 0 5 Freigabename EPSON rem druckerbeschreibung damit der Drucker leichter identifiziert werden kann set drucker EPSONNT rem drucker das muss der Freigabename im Netzwerk auf dem Freigaberechner sein if 1 drucker01 goto drucker01 if 1 drucker02 goto drucker02 if 1 canon goto canon goto datei drucker01 shift goto datei drucker02 set server 42 1 1 240 set druckerbeschreibung HP DJ 755CM im Sekretariat set drucker hpdj755 tcp shift goto datei canon set server 192 168 0 1 set druckerbeschreibung Canon s w Laser im EG set drucker CanonLBP shift goto datei datei if Z71 goto aufruf goto plot splot echo echo Dateiname 1 echo Druckserver server echo Freigabename drucker echo Beschreibung druckerbeschreibung echo print d server drucker 1 goto eof aufruf echo echo aufruf pl plotter Datei echo plotter drucker01 drucker02 canon voreingestellt ist drucker01 echo 66 NE
34. How to Apply These Terms to Your New Programs If you develop a new program and you want it to be of the greatest possible use to the public the best way to achieve this is to make it free software which everyone can redistribute and change under these terms To do so attach the following notices to the program It is safest to h them to the start of each source file to most effectively state the exclusion of warranty and each file should have at least the copyright line and a pointer to where the full notice is found lt one line to give the program s name and a brief idea of what it does gt Copyright C lt year gt lt name of author gt This program is free software you can redistribute it and or modify it under the terms of the GNU General Public Lic as published by the Free Software Foundation either version 3 of the License or at your option any later version This program is distributed in the hope that it will be useful but WITHOUT ANY WARRANTY without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PUR POSE See the GNU General Public Li for more details the Invariant Sections of the Document unaltered in their text and in their titles Section numbers or the equivalent are not considered part of the section titles M Delete any section Entitled Endorsements Such a section may not be included in the Modified Version N Do not retitle any existing e
35. OULD THE PROGRAM PROVE DE FECTIVE YOU UME THE COST OF ALL NECESSARY SER VICING REPAIR OR CORRECTION 16 Limitation of Liabilit IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER OR ANY OTHER PARTY WHO MODIFIES AND OR CONVEYS THE PROGRAM AS PERMITTED ABOVE BE LIABLE TO YOU FOR DAMAGES INCLUDING ANY GENERAL SPECIAL INCI DENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING REN DERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPE RATE WITH ANY OTHER PROGRAMS EVEN IF SUCH HOL DER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSI BILITY OF SUCH DAMAGES 17 Interpretation of Sections 15 and 16 13 2 GNU Free Documentation License Version 1 3 3 November 2008 Copyright 2000 2001 2002 2007 2008 Free Software Foundation Inc lt http fsf org gt Everyone is permitted to copy and distribute verbatim copies of this license document but changing it is not allowed 0 PREAMBLE The purpose of this License is to make a manual textbook or other functional and useful document freein the sense of freedom to assu py and redistribute it with or re yone the effective freedom to without modifying it either commercially or noncommercially Secon darily this License preserves for the author and publisher a way to get credi
36. PL for conveying Corresponding Source 5 Combined Libraries You may place library facilities that are a work based on the Library side by side in a single library together with other library facilities that are not Applications and are not covered by this License and convey such a combined library under terms of your choice if you do both of the following a Accompany the combined library with a copy of the same work based on the Library uncombined with any other library faciliti conveyed under the terms of this License b Give prominent notice with the combined library that part of it is a work based on the Libra ry and explaining where to find the accompanying uncombined form of the same work 6 Revised Versions of the GNU Lesser General Public License The Free Software Foundation may publish revised and or new versi ons of the GNU Lesser General Public License from time to time Such new versions will be similar in spirit to the present version but may differ in detail to address new problems or con ns Each version is given a distinguishing version number If the Library as you received it specifies that a certain numbered version of the GNU Lesser General Public License or any later version applies to it you have the option of following the terms and conditions either of that pu blished version or of any later version published by the Free Software Foundation If the Library as yo
37. RFP RPE PR SR O Hp ROO0O0O Dada waN o H PEE PETERPPP E PEPR EPEE EPE pep tqtetetetetete te tte tate tte tt tt tt a et de de tp de tp de de de de tp de de de de tp de tp de de de de tp de de de de tp de wikibooks wikibooks wikibooks wikibooks wikibooks wikibooks wikibooks wikibooks wikibooks wikibooks wikibooks wikibooks wikibooks wikibooks wikibooks wikibooks wikibooks wikibooks wikibooks wikibooks wikibooks Albin Autor Aza 25C3 25AB1 Bastie org wiki Benutzer org wiki Benutzer org wiki Benutzer org wiki Benutzer org wiki Benutzer org wiki Benutzer org wiki Benutzer org wiki Benutzer org wiki Benutzer org wiki Benutzer org wiki Benutzer org wiki Benutzer org wiki Benutzer org wiki Benutzer org wiki Benutzer org wiki Benutzer org wiki Benutzer org wiki Benutzer org wiki Benutzer org wiki Benutzer org wiki Benutzer Batchscripter93 Buchfreund CorneliusWasmund Daniel_B Dirk_Huenniger DonQuichot E 255E nix Enomil F _F _Fjodor Flominator Genrich Global667 Haddock Hardy42 Heuler06 Hjherbert Jaho4896 Autoren NS ar amp bw WN DRFRRrFNMNWrRN DY ON DS 2 al Fr OrRrFF Wb Jan Juetho Klartext Klaus Eifert LilT V MF Warburg MichaelFrey gt MichaelFrey Tool Michfrm Mjchael Ocrho Pc wor
38. Reference en 82 ttp www administrator de Workshop_Batch_for_Runaways_ _Part_I_ _Beispiel_ indLongPath Bat_Bedenklich_lange_Pfade_finden html ttp www administrator de Workshop_Batch_for_Runaways_ _Part_II_ __Ein_bisschen_ andwerkszeug html tp www administrator de Workshop_Batch_for_Runaways_ _Part_III_ _Datums _und_ itvariablen_im_Batch html tp www administrator de Tutorial_zur_FOR Schleife html tp www administrator de Wie_Arbeite_ich_mit_Batch_UmgebungsVariablen 3F_ rstellung_Umgang_Erweiterungen_Ver C3 A4nderungen html tp www amazon com Windows Command Line Administrators Pocket Consultant dp 735622620 ttp en wikibooks org wiki Windows_Batch_Scripting at tO dA tp technet microsoft com en us library cc722159 aspx tp technet microsoft com en us library bb490890 aspx tp www microsoft com resources documentation windows xp all proddocs en us cmds mspx mfr true tp technet microsoft com de de library cc785423 aspx tp technet microsoft com en us library cc754340 aspx FPePepPyPPPOyPHRAPFPOFNPe NS 12 Autoren Edits 78 bo 13 w Onee N Bor FP BR NFR FH User Albin Autor Aza l Bastie Batchscripter93 Buchfreund Cornelius Wasmund Daniel B Dirk Huenniger DonQuichot E nix Enomil F F Fjodor Flominator 4 Genrich Global66716 Haddock Hardy42 8 Heuler06 Hjherbert Jaho4896 OANDOKWNH NNFP
39. Skripts sinnvoll bei Windows Doppelklicks Wildcards Ist die Pfadangabe eindeutig kann der Ordnername durch Nutzen von Wildcards z b win f r windows oder winnt abgek rzt werden Dies ist jedoch im Batchbetrieb nicht ratsam Remotesysteme Pfade von nicht als Laufwerken verbundenen Remotesystemen k nnen Berechtigung vorausgesetzt entweder ber die Administrative Freigabe oder durch das Verbin den eines Netzlaufwerks angesprochen werden Beispiel f r administrative Freigabe comp oder fc computername laufwerk Weiterer Pfad Pfad in Variable Der Befehl set PFAD cd schreibt das aktuelle Verzeichnis in die Variable PFAD als letztes im Batch Script mit cd PFAD wieder ins Startverzeichnis wechseln 2 5 comp oder fc Vergleicht den Inhalt zweier Dateien und stellt die Unterschiede dar compare file compare 2 6 x copy robocopy Mit dem Befehl copy k nnen eine Datei oder mehrere Dateien kopiert werden xcopy ist die erweiterte Version von copy die mehr Optionen bietet Diese ist nicht in allen Windows Versionen verfiigbar Das weitaus m chtigere robocopy ist ab Vista standardm ig wieder verf gbar bei Win dows XP und 2000 fehlt dieses Programm zun chst Microsoft stellt robocopy aber im Windows Server 2003 Resource Kit Tools 2003 auch fiir diese Betriebssystemversionen be reit Mit dem Befehl copy b DATEI DATEI NEUE DATEI kann man Dateien zu sammenf gen 2 7 del
40. T Anmerkung zur Nutzung dieses Scriptes e Der Printbefehl schickt die Datei OHNE Interpretation direkt an den Drucker Eine Bilddatei im JPEG Format wiirde statt der Grafik also lediglich einen haufen wirrer Zeichen ergeben e Der Drucker muss in der Lage sein selbst ASCII Zeichen zu verarbeiten und aus zu geben Dies ist bei lteren Druckern vor ca 1996 sicher immer der Fall Heute beherrschen meist nur noch PostScript f hige Drucker diese Fahigkeit Billigen GDI Druckern muss man etwas auf die Spr nge helfen mit dem verwendeten Druck prozessor im Windows Druckertreiber e Zum Umschalten zun chst die Drucker bersicht ffnen Zu finden unter Start Drucker und Faxger te e Dann die Eigenschaften des gew nschten Druckers ausrufen Rechtsklick Eigenschaften e Auf dem Reiter Erweitert den Button Druckprozessor klicken e In dem erscheinenden Dialogfeld gibt es 2 Felder mit Eintr gen Im rechten Feld Standartdatentypen findet sich neben verschiedenen anderen auch der Eintrag Text Diesen markieren und dann alles mit OK wieder schlie en Der Druckprozessor von Windows ist nun in der Lage Ausgaben entsprechend zu Inter pretieren und dem GDI Drucker als Grafik zu liefern Es k nnen aber nur stur 80 Zeichen maximal auf ca 60 Zeilen verteil werden Manchmal sind es bis zu 66 Zeilen 8 0 12 Copy Kopieren von Dateien Der Befehl copy test txt c temp kopiert die Datei test tzt aus dem aktuelle
41. USE Netzlaufwerke verbinden NET USE kann genutzt werden um eine Verbindung zu Netzwerk oder Samba Freigaben herzustellen Ublicherweise wird hierbei ein Laufwerksbuchstabe verwendet dies ist je doch nicht zwingend Syntax NET USE x name oder ip des rechners freigabe Wenn fiir die Verbindung die Fingabe von Zugangsdaten erforderlich ist k nnen diese auch mit angegeben werden NET USE x USER benutzer name oder ip des rechners freigabe passwort Wenn f r einen Rechner Zugangsdaten ben tigt werden und diese nicht oder falsch ange geben wurden so wird der Benutzer nach diesen gefragt Es kann auch nur ein Benutzer angegeben werden indem das Passwort durch einen Asterisk ersetzt wird Die Eingabe von NET USE ohne Parameter zeigt bereits verbundene Laufwerke an Bei Windows Freigaben wird auch ein Status angezeigt bei Samba Freigaben jedoch nicht 7 6 2 NET SEND Nachrichten an andere Rechner senden Mit NET SEND k nnen kurze Nachrichten an andere Rechner geschickt werden Der Empf nger sieht diese dann normalerweise in einer Message Box Die Benutzung empfiehlt sich nur bedingt da moderne Firewalls solche Nachrichten normalerweise blocken siehe Hinweis unten Syntax NET SEND Empf nger Nachricht Empf nger kann dabei sein e IP Adresse e Domain e Domain mit Benutzerangabe domain name e Rechnername im lokalen Netzwerk e Benutzername im lokalen Netzwerk e Asteris
42. actical works are designed to take away your freedom to share and change the works By con trast the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program to make sure it remains free software for all its users We the Free Software Foun dation use the GNU General Public License for most of our software it applies also to any other work released this way by its authors You an apply it to your programs too When we speak of free software we are referring to freedom not price Our General Public Licenses are designed to make sure that you have the freedom to distribute copies and charge for them if you wish that you receive source code or can get it if you want it that you can change the software or use pieces of it in new free programs and that you know you can do these things To protect your rights we need to prevent others from denying you these rights or asking you to surrender the rights Therefore you have certain responsibilities if you distribute copies of the software or if you modify it responsibilities to respect the freedom of others For example if you distribute copies of such a program whether gratis or for a fee you must pass on to the recipients the same freedoms that you received You must make sure that they too receive or can get the source code And you must show them these terms so they know their rights Developers tha
43. ahren mit Windows 95 diese Restriktionen offiziell beseitigt hat Oft k nnen dafiir OpenSource Tools wie SFK Swiss File Knive und Sed sehr erfolg reich in die Batch Programmierung eingebunden werden Fiir das Verpacken und Kom primieren von Dateien l sst sich das freie 7 Zip gut ber die Kommandozeile steuern Das GPL Programm Gnuplot eignet sich hervorragend f r die Visualisierung von Da ten im CSV Format und l sst sich einfacher und schneller scripten als MS Excel oder OO org Calc Zum Herunterladen von Dateien und Webseiten kann Wget verwendet wer den Auch f r Batch Dateien gibt es diverse kostenlose Batch Compiler die die Datei in eine ausf hrbare exe Datei umwandeln und den Code vor Manipulation und oder Copyright Verletzungen sch tzen F r gehobenere Scripting Anspr che und komplexere Vorhaben mit einer l ngeren Lebensdauer sollten dezidierte Scripting Sprachen z B Awk Perl Python Ruby oder Tel in Erw gung gezogen werden f r die gl cklicherweise das GNU Projekt freie und quelloffene Alternativen bietet Eine kostenlose Alternative zum Batching bietet Microsoft selbst auf seiner Homepage mit dem Tool PowerShell Weitere Tools sind im Abschnitt WebLinks aufgelistet Ae UNa http swissfileknife sourceforge net http de wikipedia org wiki Sed 20 28Unix 29 http www 7 zip org http de wikibooks org wiki Perl 75 10 Referenz 10 1 help Die Hilfe Funktion steht in allen Windows System
44. any kind of propagation that enables other parties to make or receive copies Mere interaction with a user through a computer network with no transfer of a copy is not conve An interactive user interfac the extent that it in displays Appropriate Legal Notices to cludes a convenient and prominently visible feature that 1 displays an appropriate copyright notice and 2 tells the user that there is no warranty for the work except to the extent that war ranties are provided that licensees may convey the work under this License and how to view a copy of this License If the interface pres ents a list of user commands or options such as a menu a prominent item in the list meets this criterion 1 Source Code The source code for a work means the preferred form of the work for making modifications to it Object code means any non source form of a work A Standard Interface means an interface that either is an official standard defined by a recognized standards body or in the case of interfaces specified for a particular programming language one that is widely used among developers working in that language The System Libraries of an executable work include anything other than the work as a whole that a is included in the normal form of packaging a Major Component but which is not part of that Major Component and b serves only to enable use of the work with that Major Componen
45. ariablen in For Schleifen F r For Schleifen werden auch eine Art von Parameter Variable verwendet um die Anzahl der Schleifendurchl ufe zu kontrollieren Links e http ss64 com nt for html For Schleife auf ss64 com e http ss64 com nt syntax args html Parameter auf ss64 com siehe Abschnitt FOR parameters 5 6 Stringoperationen Manipulation von Strings in Variablen Mit folgender Syntax lassen sich Teile aus einer Zeichenkette extrahieren set str Hallo set str str 1 echo str Die angegebene positive Zahl gibt an wie viele Zeichen links bergangen werden sollen Dieser Ausdruck liefert daher den Teilstring allo von Hallo set str Hallo set str str 47 echo str Wird eine negative Zahl eingesetzt so gibt ihr Betrag an wie viele Zeichen von rechts genommen werden sollen Dieser Ausdruck liefert daher ebenfalls allo ber die Angabe einer zweiten Zahl kann definiert werden was mit dem Rest nach Auswertung der ersten Zahl entsprechend obiger Regeln geschehen soll W hrend die erste Zahl die Zeichenkette links beschneidet beschneidet die zweite Zahl sie rechts und zwar nach folgenden Regeln set str Hallo set str str 1 2 echo str 43 Erweiterungen unter Windows NT Eine positive zweite Zahl gibt an wie viele Zeichen ab links vom Rest genommen werden sollen Dieser Ausdruck liefert daher al set str Hallo set str str 1 2 echo str
46. atum ist diese Angabe hier nicht n tig da dieses standardm ig im tt mm jjjj Format ausgegeben wird Wer aber nur das Jahr haben will kann date 4 eingeben und erh lt damit die letzten 4 Zeichen F r ein sortiergerechtes Datum in der Umgebungs variablen sortdate sorgt z B set SORTDATE 4date 4 fdate 3 2 date 0 2 echo SORTDATE Wert der Umgebungsvariablen 2009 04 20 Beachte In einer Batchdatei kann die Verwendung von DATE und insbesondere von TIME dazu f hren dass sich die ausgegebene Uhrzeit nicht aktualisiert Hierzu folgendes Beispiel echo off echo Die aktuelle Zeit ist TIME echo bitte 5 Sec warten ping 1 2 3 4 n 1 w 5000 gt NUL echo jetzt sind genau 5 Sec vergangen TIME liefert TIMEZ das ist noch OK echo doch in der FOR Schleife wird bereits die alte Zeit verwendet for L 4N IN 0 1 3 DO echo time pause echo und dies bleibt f r jede Ausgabe innerhalb der FOR Schleife so echo echo Auch in z amp nbsp B IF Schleifen ist das so if TRUE TRUE echo 1 Zeit in der If Schleife TIME echo Warte 5 Sec ping 1 2 3 4 n 1 w 5000 gt NUL echo 2 Zeit in der If Schleife TIME echo Warte nochmals 5 Sec ping 1 2 3 4 n 1 w 5000 gt NUL echo 3 Zeit in der If Schleife TIME echo Dabei ist es bereits TIME pause Damit DATE und TIME die richtigen Werte ausgeben die verz gerte Erweiterung von Umgebungsvariablen mit dem
47. ausgegeben werden k nnen for F tokens f in dir S b C Windows Temp temp dat do echo IE Z hlvariablen in Zeichenketten einbetten Um die Z hlvariable f f auf der Kommandozeile in einer Zeichenfolge zu verwen den wird einfach die Variable in dem String eingebettet FOR IN ABCDE DO echo mitten fdrinnen 3 19 GOTO Mit dem Batchbefehl goto wird eine Sprungmarke s o angesprungen Syntax goto NAMEDERSPRUNGMARKE Beispiel Siehe unter Doppelpunkt 3 20 IF Der IF Befehl erm glicht eine einfache Verzweigung und wird oft zusammen mit dem GOTO Befehl eingesetzt IF erm glicht hierbei sowohl die Pr fung auf eine Gleichheit als auch auf das Vorhandensein von Dateien Beispiel 1 echo off IF exist c temp my log echo gt c temp my log echo Log Datei erstellt gt gt c temp my log Beispiel 1 pr ft ob eine Logdatei vorhanden ist und erstellt ggf eine Neue Beispiel 2 echo off IF COMPUTERNAME Bastie GOTO WAHR REM hier landet man wenn der if Ausdruck falsch ist GOTO WEITER WAHR REM hier landet man wenn der if Ausdruck wahr ist echo Willkommen Zuhause 13 14 Kapitel 3 5 auf Seite 16 Kapitel 3 19 auf Seite 27 27 Batch Befehle REM Jetzt wird der if Zweig verlassen GOTO WEITER WEITER echo Have a nice Day Beispiel 3 IF COMPUTERNAME Bastie echo Willkommen zu Hause ELSE echo Du bis
48. bute it under certain conditions type show c for details The hypothetical commands show w and show c should show the appropriate parts of the General Public License Of course your pro gram s commands might be different for a GUI interface you would use an about box You should also get your employer if you work as a programmer or school if any to sign a copyright disclaimer for the program if ne cessary For more information on this and how to apply and follow the GNU GPL see lt http www gnu org licenses gt The GNU General Public License does not permit incorporating your program into proprietary programs If your program is a subroutine library you may consider it more useful to permit linking proprietary applications with the library If this is what you want to do use the GNU Lesser General Public License instead of this License But first please read lt http www gmu org philosophy why not Igpl html gt section 1 will typically require changing the actual title 9 TERME NATION You may not copy modify sublicense or distribute the Document ex cept as expressly provided under this License Any attempt otherwise to copy modify sublicense or distribute it is void and will automat cally terminate your rights under this License However if you cease all violation of this Licens o then your license from a particular copyright holder is
49. chiede alternativer Verwendungen Zu den Unterschieden von REM oder 20 3 26 RENAME Mit dem rename Befehl kann man Dateien umbenennen Syntax Windows 7 8 RENAME Laufwerk Pfad Dateinamei Dateiname REN Laufwerk Pfad Dateiname1 Dateiname Um Informationen zu anderen Betriebssystemen wird noch gebeten 3 27 SET Syntax e Windows XP set a expression p variable string Links e http www scriptcode com batchfilecommands set html Verwendung Wird haupts chlich verwendet um einer Variablen einen Wert zuzuweisen Siehe Batch befehle Variablen und Set Befehl Ohne Parameter gibt set eine Liste aller Umbegebungsvariablen aus Der Parameter p kann dazu verwendet werden der Variable eine Benutzereingabe zuzuweisen Der Parameter a kann dazu verwendet werden um mit den Variablen Rechenoperation durchzuf hren Beispiel zur Wertezuweisung Inhalt Batchdatei set VARIABLENNAME test echo VARIABLENNAME set VARIABLENNAME test2 echo VARIABLENNAME Ausgabe gek rzt c gt set VARIABLENNAME test c gt echo VARIABLENNAMEY test 16 17 18 19 20 21 32 http www microsoft com resources documentation windows xp all proddocs en us rem mspx mfr true http superuser com questions 82231 how do i do comments at a windows command prompt http www febooti com products command line email batch files first dos batch script continue html http www obrienpc net dos y rem html
50. ck test Man sollte meinen dass der Wert von test in beiden Ausgaben 2 ist Doch leider ist es nicht so Denn innerhalb des IF Blocks wird das Neusetzen der Variable test von 1 auf 2 noch nicht aktiv und somit ist das Ergebnis Wert von test im IF Block 1 Erst nach dem IF Block ist der Wert aktualisiert Wert von test nach IF Block 2 L sung cmd exe V In einer Batchdatei die mit cmd V gestartet wurde werden Variablen innerhalb von Befehlsbl cken aktualisiert Jedoch kann man sie nicht gewohnt mit test ansprechen sondern mit test echo off if 199 0 11 start WAIT B cmd exe V C 0 machen goto eof set test 1 if test 1 set test 2 echo Wert von test Prozent in dem IF Block test echo Wert von test Ausrufezeichen in dem IF Block test echo Wert von test nach dem IF Block test pause 6 0 14 Ausgaben Fehler unterdriicken Manchmal m chte man per Batch ein Programm starten aber es soll dabei keine Ausgabe gemacht werden Das ist recht einfach MeinProgramm exe gt NUL Es k nnte aber sein dass evtl Fehler dennoch ausgegeben werden Das liegt daran da die Programme in dem Fall auf stderr statt stdout schreiben Um auch in dem Fall die Ausgabe zu unterdr cken kann man mit einem zus tzlichen 2 gt amp 1 die Ausgaben von stderr auf stdout umleiten Da stdout dann nach NUL verschoben wird sieht man absolut nichts MeinProgramm exe gt NUL 2 gt amp 1 6 0 15 Professionelle Me
51. config 55 Netzwerkumgebung Ausgabe Windows IP Konfiguration Ethernetadapter VMware Network Adapter VMnet8 Verbindungsspezifisches DNS Suffix IP Adresse Subnetzmaske Standardgateway 192 168 0 1 255 255 255 0 192 168 0 11 Ethernetadapter VMware Network Adapter VMnet1 Verbindungsspezifisches DNS Suffix IP Adresse e A Subnetzmaske Standardgateway Ethernetadapter LAN Verbindung 3 Verbindungsspezifisches DNS Suffix IP Adresse ao Subnetzmaske Standardgateway Ci gt 192 168 2 1 255 255 255 0 192 168 2 11 myhost local 192 168 1 1 255 255 255 0 192 168 1 11 7 2 1 ipconfig all Eine detailliertere Auskunft erh lt man mit dem Parameter all Beispiel C gt ipconfig all Ausgabe Windows IP Konfiguration Hostname bap Prim res DNS Suffix Knotentyp aa IP Routing aktiviert WINS Proxy aktiviert DNS Suffixsuchliste cestmoi mypc local Unbekannt Nein Nein mypc local mypc local Ethernetadapter VMware Network Adapter VMnet8 Verbindungsspezifisches DNS Suffix Beschreibung VMnet8 Physikalische Adresse DHCP aktiviert IP Adresse Bact VMware Virtual Ethernet Adapter for 01 23 45 67 89 AB Nein 192 168 0 1 56 tracert 7 2 2 ipconfig renew Sollten die Netzwerkkonfigurationen nicht mehr aufzufinden sein dann hilft oft der Pa rameter renew Beis
52. criptpath D Maier Net User lt name gt homedir D Maier Net User lt name gt homedirreq Yes Net User lt name gt homedirreq No Damit wird eingestellt wo sich die Benutzerdaten befinden Der Ort der Benutzerdaten wird in der Umgebungsvariable USERPROFILE gespeichert 2000 XP Net User lt name gt countrycode 049 Damit wird die L ndereinstellung ver ndert 2000 XP 61 Netzwerkumgebung Net User lt name gt workstations Damit wird es dem Benutzer erlaubt sich von anderen Rechnern aus an diesem Rechner anzumelden Anstatt kann hier auch eine Liste von Computernamen angegeben werden Dann darf sich der Benutzer nur von diesen Computern anmelden 2000 XP Hinweis Diese Arbeitsvorg nge gehen auch mit der Windows Benutzerkontensteuerung Diese kann erreicht werden durch Start Einstellungen Systemsteuerung Benutzer Hinweis Der Name des aktuell angemeldeten Benutzers ist in des Umgebungsvariable UserName Hinweis Hilfe zum Befehl Net User erh lt man durch Eingabe von Net User help Beispiel Um den Benutzer Otto mit dem Password Frieda einzurichten kann folgende Batch Datei ausgefiihrt werden net net net net net user user user user user Otto Frieda add Otto expires never Otto comment Default USER from This Computer Otto active Yes Otto 62 8 Beispiele 8 0 7 Regedit exe Eine kleine Batchdatei um mit regedit exe direkt e
53. ction consisting of the Document and other docu ments released under this License and replace the individual copies of this License in the various documents with a single copy that is inclu ded in the collection provided that you follow the rules of thi for verbatim copying of each of the documents in all other res of this License into the extr ted doc ument and follow thi 5 in all other regarding verbatim copying of that doc AGGREGATION WITH INDEPENDENT WORKS A compilation of the Document or its derivatives with other separate and independent documents or works in or on a volume of a storage or distribution medium is called an ggregateif the copyright resulting from the compilation is not used to limit the legal rights of the com pilation s users beyond what the individual works permit When the Document is included in an aggregate this License does not apply to the other works in the aggregate which are not themselves derivative works of the Document If the Cover Text requirement of section 3 is applicable to these copies of the Document then if the Document is less than one half of the entire aggregate the Document s Cover Texts may be placed on co vers that bracket the Document within the aggregate or the electronic equivalent of covers if the Document is in electronic form Otherwi they must appear on printed covers that bracket the whole aggregate 8 TRANSLATION
54. den lokalen Giiltigkeitsbereich von Umgebungs nderun gen in einer Batchdatei L scht eine oder mehrere Dateien Beendet das Programm CMD EXE Befehlsinterpreter Vergleicht zwei oder mehr S tze von Dateien und zeigt die Un terschiede an Sucht eine Zeichenkette in einer oder mehreren Datei en Sucht Zeichenketten in Dateien F brt einen angegebenen Befehl fiir jede Datei in einem Datei ensatz aus Formatiert einen Datentr ger fiir die Verwendung mit Windows Zeigt die Dateitypen an die bei den Zuordnungen f r die ent sprechenden Dateierweiterungen verwendet werden bzw ndert sie Zeigt unter Windows XP SP2 die Mac Adresse an Setzt den Windows Befehlsinterpreter auf eine markierte Zeile in einem Batchprogramm Erm glicht Windows Sonderzeichen im Grafikmodus anzuzei gen Zeigt Hilfeinformationen zu Windows Befehlen an Verarbeitet Ausdriicke in einer Batchdatei abhangig von Bedin gungen Erstellt ndert oder l scht die Bezeichnung eines Volumes Erstellt ein Verzeichnis Erstellt ein Verzeichnis Konfiguriert ein Systemgerat Zeigt Ausgabe auf dem Bildschirm seitenweise an Verschiebt ein oder mehrere Dateien von einem Verzeichnis in ein anderes Verbindet einen Computer mit einer freigegebenen Ressource oder trennt die Verbindung und zeigt Informationen tiber die Verbindungen eines Computers an Der Befehl steuert au erdem standige Netzwerkverbindungen Legt den Suchpfad f r ausf hrbare Dateien fest od
55. der Diskette Mit format c wird die Festplatte c formatiert Mit format a wird die Diskette im Laufwerk a formatiert Mit format c s bzw format a s kann man die Festplatte Diskette mit Systemdateien formatieren so dass sie nachher bootfahig sind 2 13 loadhigh Ladt Programme in freie UMB Upper Memory Blocks 2 14 md mkdir Der Befehl md make directory legt ein neues Verzeichnis an 2 15 more Mit der Ausgabeumleitung more bspw type Dateiname more wird bei Seitenwechsel zur Best tigung aufgefordert Damit besteht die M glichkeit ber mehrere Seiten f hrende Dokumente anzuzeigen more ist der einzige Befehl bei der auch in der DOS Welt die sogenannte Pipe verwendet wird Bei der Pipe handelt es sich um das Zeichen fehlt es auf der Tastatur ist es auch bei hierzu gedr ckt gehaltener ALT Taste und der Eingabe der Zahlenfolge 124 auf dem Ziffernblock zu erzeugen das Zeichen erscheint dann nach dem Loslassen der ALT Taste Mit diesem Zeichen ist es m glich zwei Befehle miteinander auf eine spezielle Weise zu verbinden Dabei wird der erste Befehl ausgef hrt seine Ausgaben werden jedoch nicht auf den Bildschirm geschrieben sondern in einen Puffer Der zweite Befehl wird auf eine Weise gestartet dass er seine Eingaben nicht von der Tastatur sondern von ebendiesem Puffer bekommt Mit more ist es ebenfalls m glich den Inhalt einer Datei an eine andere Datei anzuh ngen 2 http de wikibooks org wiki
56. dification of the Modified Version to whoever pos a copy of it In addition you must do these things in the Modified Version Jse in the Title Page and on the covers if any a title di tinct from that of the Document and from those of previous versions which should if there were any be listed in the History section of the Document You may use the same title as a previous version if the original publisher of that version gives permission B List on the Title Page as authors one or more persons or enti for authorship of the modifications in the Modified Ve with at least five of the principal authors of the Document all of its principal authors if it has fewer than five unless they release you from this requirement C State on the Title page the name of the publisher of the Modified Version as the publisher D Preserve all the copyright notices of the Document E Add an appropriate co pyright notice for your modifications adjacent to the other copyright notices F Include immediately after the copyright notices a license notice giving the public permission to use the Modified Version under the terms of this License in the form shown in the Addendum below G Preserve in that license notice the full lists of Invariant Sec and required Cover Texts given in the Document s license notic H Include an unaltered copy of this License I Pr Entitled History Preserve its Title and add to it an item stating
57. e any further restrictions on the exercise of the rights granted or affirmed under this License For example you may not impose a license fee royalty or other charge for exercise of rights granted under this License and you may not initiate litigation in cluding a cross claim or counterclaim in a lawsuit alleging that any patent claim is infringed by making using selling offering for sale or importing the Program or any portion of it 11 Patents A contributor is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based The work thus licensed is called the contributor s contributor v A contributor s essential patent claims are all patent claims owned or controlled by the contributor whether already acquired or hereaf ter acquired that would be infringed by some manner permitted by this License of making using or selling its contributor version but do not include claims that would be infringed only as a consequence of further modification of the contributor version For purposes of this definition control includes the right to grant patent subli manner consistent with the requirements of this License Each contributor grants you a non exclusive worldwide royalty free patent license under the contributor s essential patent claims to make use sell offer for sale import and otherwise run modify and propagate the contents of
58. efetch 73 Beispiele 74 diskperf n ipconfig flushdns 8 0 20 FLV MP4 WAV zu MP3 konvertieren FFMPEG Batch FFMPEG EXE nach C kopieren und Batch Datei in einem beliebigen Ordner mit FLV MP4 WAV Dateien anlegen Sobald die Batch Datei gestartet wird geht sie alle FLV MP4 WAV Files durch und encodiert diese als MP3 VBR 226 kbit Am Ende werden alle MP3 Dateien in den Ordner MP3 verschoben mkdir MP3 FOR X IN flv DO C ffmpeg exe y i WAR q a O nX mp3 FOR X IN mp4 DO C ffmpeg exe y i X q a O nX mp3 FOR X IN wav DO C ffmpeg exe y i X q a O nX mp3 FOR X IN mp3 DO MOVE X MP3 Vorteile Stabil und leistungsstark FFMPEG Konsole keine tiberladene GUI man muss keine Bloatware installieren nutzt Mehrkernprozessoren aus variable Bitrate kommt mit Sonderzeichen klar z B 1 kopiert nicht nur den Audiostream und Vi deo nach null sondern enkodiert alles neu keine defekten MP3s mehr bzw keine Spriinge oder sonstiges mehr Einfach den Text kopieren in eine Textdadei und zur bat machen 9 Zusatz Tools Viele Aufgaben sind mit der Batchprogrammierung bzw mit Windows Scripting alleine kaum oder nur sehr umst ndlich zu l sen So kann das Umwandeln von Dateien Texter setzungen aufgrund der nicht ganz sauberen Behandlung von Sonder bzw Operations zeichen zur Qual werden Erstaunlich fiir ein Betriebssystem welches seit nun mehr tiber 10 J
59. eien Theoretisch k nnte man auch mit den kurzen Dateinamen 8 3 arbeiten aber diese sind nicht eindeutig und k nnen von Laufwerk zu Laufwerk unterschiedlich sein Daher besser nicht verwenden Kombiniert in der gegebenen Reihenfolge zwei oder mehrere durch verbundene Text dateien in einer neuen Gesamtdatei In diesem Zusammenhang muss auf die Bedeutung der Parameter A fiir ASCII Format der Standardwert und B fiir Bin r Format eingegangen werden die jedem Dateinamen in obigem Beispiel mit einem Leerzeichen Abstand vorangehen k nnen DOS Textdateien enthalten ein Dateiendezeichen Dezimal 26 Hexadezimal 1A Beim Kopier vorgang darf in der Gesamtdatei nur als letztes Zeichen ein Dateiendezeichen erscheinen sonst wiirde der Text nach der ersten Endmarkierung nicht mehr angezeigt copy ko piert ohne das abschlie ende Zeichen und f gt als letztes wieder eines zur Gesamtdatei hinzu M chte man Dateien mit bin ren Inhalten zusammenf gen z B PostScript Dateien die auch bin re Abschnitte enthalten k nnen so w rde ohne Parameter B ebenfalls nur bis zu einem zuf llig vorkommenden Dateiendezeichen kopiert und damit das Ergebnis unbrauchbar copy b seite 1 ps b seite 2 ps Neue Datei ps Als Zieldatei sollte man keine der Quelldateien verwenden da m glicherweise sonst der Inhalt berschrieben wird 8 0 13 Message Ping Mit Hilfe des folgenden Scripts kann man Windows um eine
60. eit begab man sich mit einem Stapel Lochkarten aus Pappe auf denen sich das Programm und die Daten in gestanzter Form befanden zum Rechenzentrum und tibergab dem Operator seinen Stapel Die Stapel aller Benutzer wurden gesammelt und dann sequentiell an den Rechner tibergeben Nach einiger Zeit konnte man sich dann die meist ausgedruckten Ergebnisse abholen 1 4 Wie erstelle ich eine Batchdatei Wie bereits gesagt reicht ein einfacher Editor aus Empfehlen kann man guten Gewissens den quelloffenen und kostenlosen Notepad Editor als bessere Alternative zu MS No tepad Unter DOS bis Windows 98 Speichern Sie dann die Datei mit der Endung bat ab Anschliefend mtissen Sie nur die Datei starten Dies k nnen Sie entweder direkt in Windows oder indem Sie in der Einga beaufforderung in das entsprechende Verzeichnis wechseln und den Dateinamen eingeben Ab Windows NT 2000 XP Vista 7 F r Windows NT kompatible Betriebssysteme gibt es seit Windows 2000 auch Batchda teien mit der Endung cmd Diese werden genau wie Batchdateien mit der Endung bat verarbeitet bzw ausgefiihrt Nach allgemeiner Konvention sollte man bei Batchdateien erstellt fiir Windows NT die Endung CMD w hlen Die Endung cmd wurde urspriing lich aus Kompatibilit tsgr nden zu OS 2 einem Betriebssystem das MS urspr nglich in Kooperation mit IBM entwickelte mit Windows NT 3 x eingef hrt 1 5 Weiterf hrende Informationen und Links e Allgemeine In
61. ell as a reference direc ting the user to the copies of the GNU GPL and this license document d Do one of the following o 0 Convey the Minimal Corresponding Source under the terms of this License and the Corresponding Appli cation Code in a form suitable for and under terms that permit the user to recombine or relink the Application with a modified version of the Linked Version to produce a modified Combined Work in the manner specified by section 6 of the GNU GPL for conveying Cor responding Source o 1 Use a suitable shared library mechanism for linking with the Library A suitable mechanism is one that a uses at run time a copy of the Library already present on the user s com puter system and b will operate properly with a modified version of the Library that is interface compatible with the Linked Version e Provide Installation Information but only if you would otherwise be required to provide such information under section 6 of the GNU GPL and only to the extent that such information is necessary to in stall and execute a modified version of the Combined Work produced by recombining or relinking the Application with a modified version of the Linked Version If you use option 4d0 the Installation Information must accompany the Minimal Corresponding Source and Correspon ding Application Code If you use option 4d1 you must provide the Installation Information in the manner specified by section 6 of the GNU G
62. en au er Win9X d h 95 98 ME zur Verfiigung Der allgemeine Befehl hierzu lautet help Als Ausgabe wird eine Liste mit einem Teil der verfiigbaren Kommandozeilen Befehle ausgegeben Diese Listen umfasst den Befehlsnamen linke Spalte und eine Beschreibung rechte Spalte Soll ein Befehl genauer erklart werden so lautet die Eingabe help BEFEHLSNAME oder auch BEFEHLSNAME Diese Eingabe in die Kommandozeile f rdert detaillierte Informationen und z T auch Beispiele zu einem Befehl zu Tage Es werden jedoch nicht alle Befehle die es im DOS gibt angezeigt 10 1 1 help als Einzelbefehl Der Befehl help listet diverse interne und externe Befehle auf Diese Liste ist aber bei weitem nicht vollst ndig zumal die externen Batch Befehle durch das Hinzuf gen von neuen Programmen erg nzt werden k nnen z B durch die Verwendung von Datenkom pressionsprogrammen die per Kommandozeile aufrufbar sind Folgende Befehlsliste erh lt man als Ausgabe in diesem Beispiel unter Windows XP ASSOC Zeigt Dateierweiterungszuordnungen an bzw ndert sie AT Legt eine Zeit fest zu der Befehle und Programme auf diesem Computer ausgef hrt werden ATTRIB Zeigt Dateiattribute an bzw ndert sie BREAK Schaltet die erweiterte berpr fung f r STRG C ein bzw aus CACLS Zeigt Datei ACLs Access Control List an bzw ndert sie CALL Ruft eine Batchdatei aus einer anderen Batchdatei heraus auf CD Zeigt den Namen des aktuellen Verzeichnisses an bzw
63. en wird wird angenommen da die Batchdatei zum ersten mal gestartet wurde Die if 1 Bedingung ist also erf llt Mittels start wird dann dieselbe Batchdatei mit ver nderter Priorit t gestartet allerdings mit einem angeh ngten Parameter wei ter machen K nnte auch irgendwas anderes sein Somit ist beim n chsten Aufruf die if 1 Bedingung nicht mehr erf llt und der normale Teil der Batchdatei wird abgearbeitet Wenn man der Batchdatei einen Parameter bergeben m chte z B ein Dateiname o muss man alle Parameter verschieben echo off if nyon start WAIT LOW B cmd exe V C sO 1 weiter_machen goto eof echo Jetzt laufe ich mit niedriger Priorit t echo Nun kann 1 bearbeitet werden pause Anmerkungen Normalerweise k nnte man statt s0 auch 70 bei der cmd exe Zeile verwenden Allerdings klappt das nicht richtig wenn Leerzeichen in der Batch Datei vorhanden sind Mit s0 wird der komplette Pfad zur Batchdatei als Kurznamen angegeben In dem Pfad kommt dann keine Leerzeichen vor 6 0 13 Probleme mit Variablen Wenn man sich die Hilfeseiten zu set mittels set durchliest st t man auf das Thema verz gerte Erweiterung von Variablen Das will ich hier mal anhand von Beispielen erkl ren Das Problem set test 1 if test 1 set test 2 Ein und Ausgaben in Variablen speichern set p echo Wert von test im IF Block test echo Wert von test nach IF Blo
64. enarten o e 5 6 Stringoperationen Manipulation von Strings in Variablen 5 7 Arithmetische Operationen set a 5 8 Ein und Ausgaben in Variablen speichern set p 6 Programmierungshilfen 7 Netzwerkumgebung PL PA A ee en ee ae ne Be Ne tee ee 1 2 PLOMO A AA A A A A ee IV Inhaltsverzeichnis 10 EIS SEE ACCT af ot ol Seta eek A Altes ee Oh a DL yy de TA Metstab Ll eee re Ot ees a ath ee So ee ea A ee ee 1 9 Netsh A A re an a ra A Bae he ee Gh ek Seg ted eS 1 62 NE Ares os A o hee a abe a ee Bo ese Sn ae de Beispiele Zusatz Tools Referenz TOL help dr o A an a ee aes dr A 11 WebLinks 12 11 1 Foren Hilfe zur Batch Programmierung finden 11 2 Ungeordnete Links Seiten mit tutorien Referenzen Beispielen etc TIS Tutorials Di A er Bes ITA Bl icher ax ae o a er An ae ee She ee See E T15 Referenzen 1 bas doe Sarg ia eh are re ae Gls ea Beet Autoren Abbildungsverzeichnis 13 Kategorie Buch mit Druckversion Licenses 13 1 GNU GENERAL PUBLIC LICENSE 13 2 GNU Free Documentation License 222 2 m m nn nn 13 3 GNU Lesser General Public License 2 2 2222 2 2 nn nn nn 1 1 http de wikibooks org wiki Kategorie 3ABuch 20mit 20Druckversion 63 75 77 77 81 81 81 82 82 82 83 87 1 Allgemeine Information 1 1 In diesem Buch behandelte und nicht behandel
65. er zeigt die sen an help PAUSE POPD PRINT PROMPT PUSHD RD RECOVER REM REN RENAME REPLACE RMDIR SET SETLOCAL SHIFT SORT START SUBST TASKLIST TASKKILL TIME TITLE TREE TYPE VER VERIFY VOL XCOPY H lt die Ausf hrung einer Batchdatei an und zeigt eine Mel dung an Wechselt zu dem Verzeichnis das durch PUSHD gespeichert wurde Druckt eine Textdatei Andert die Eingabeaufforderung Speichert das aktuelle Verzeichnis und wechselt dann zu einem anderen Verzeichnis Entfernt ein Verzeichnis Stellt lesbare Daten von einem besch digten Datentr ger wieder her Leitet Kommentare in einer Batchdatei bzw CONFIG SYS ein Benennt eine Datei bzw Dateien um Benennt eine Datei bzw Dateien um Ersetzt Dateien L scht ein Verzeichnis Setzt oder l scht die Umgebungsvariablen bzw zeigt sie an Beginnt den lokalen Giiltigkeitsbereich von Umgebungs nderun gen in einer Batchdatei Ver ndert die Position ersetzbarer Parameter in Batchdateien Sortiert die Eingabe Startet ein eigenes Fenster um ein bestimmtes Programm oder einen Befehl auszuf hren Weist einem Pfad einen Laufwerksbuchstaben zu Zeigt alle zurzeit laufenden Aufgaben inklusive der Dienste an Bricht einen laufenden Prozess oder eine Anwendung ab oder beendet ihn bzw sie Zeigt die Systemzeit an bzw legt sie fest Legt den Fenstertitel f r das Eingabeaufforderungsfenster fest Zeigt die Ordnerstruktur eines Laufw
66. erial or e Declining to grant rights under trademark law for use of some trade names trademarks or service marks or f Requiring indemnification of licensors and authors of that material by anyone who conveys the material or modified versions of it with contractual assumptions of liability to the recipient for any liability that these contractual assumptions directly impose on those licensors and authors All other non permissive additional terms are considered further re strictions within the meaning of section 10 If the Program as you received it or any part of it contains a notice stating that it is gover ned by this License along with a term that is a further restriction you may remove that term If a license document contains a further restri tion but permits relicensing or conveying under this License you may add to a covered work material governed by the terms of that license document provided that the further restriction does not survive such relicensing or c If you add terms to a covered work in accord with this s must place in the relevant source files a statement of the additional terms that apply to those files or a notice indicating where to find the applicable terms ion you Additional terms permissive or non permissive may be stated in the form of a separately written license or stated as exceptions the above requirements apply either way 8 Termination You ma
67. erks oder Pfads grafisch an Zeigt den Inhalt einer Textdatei an Zeigt die Windows Version an Legt fest ob berwacht werden soll ob Dateien korrekt auf den Datentr ger geschrieben werden Zeigt die Datentr gervolumebezeichnung und die Seriennummer an Kopiert Dateien und Verzeichnisb ume 10 1 2 help in Kombination mit anderen Befehlen In Kombination mit einem weiteren Batchbefehl z B help md erh lt man weitere In formationen ber diesen Folgende Bildschirmausgabe erh lt man bei der Eingabe des Befehls in der Kommandozeile unter WindowsXP Microsoft Windows XP Version 5 1 2600 C Copyright 1985 2001 Microsoft Corp C gt help md Erzeugt ein Verzeichnis 79 Referenz 80 MKDIR Laufwerk Pfad MD Laufwerk Pfad Wenn die Befehlserweiterungen aktiviert sind wird MKDIR folgenderma en ver ndert MKDIR erzeugt wenn n tig jedes Zwischenverzeichnis Wenn zum Beispiel das Verzeichnis a nicht existiert dann entspricht mkdir a b c d der folgenden Befehlsfolge mkdir a chdir a mkdir b chdir b mkdir c chdir c mkdir d Diese Folge von Befehlen muss angegeben werden wenn die Befehlserweiterungen nicht aktiviert sind Ge 11 WebLinks 11 1 Foren Hilfe zur Batch Programmierung finden Am besten lassen sich Beispiele z B ber Google mit einem oder mehreren Schl ssel w rtern finden batch cmd windows commandozeile etc Viele aktive Foren z B Administrator de werden dann
68. erlust f hrt weshalb ich die Benutzung von REM nicht empfehlen w rde echo off Verhindert dass dieser Kommentar angezeigt wird 1 2 Kapitel 3 5 auf Seite 16 Kapitel 3 25 auf Seite 31 15 Batch Befehle Ohne echo off C gt Dieser Kommentar wird so angezeigt 3 4 Ausrufezeichen Syntax e Windows XP VARIABLENAME Web Links e EnableDelayedExpansion auf SS64 com e Beispiel zur fehlerhaften Verwendung von inkl Erkl uterung engl Batch Ad ding Users to Multiple Groups Through For Loop auf stackoverflow com e Allgemeine Info zur Allokation von Variablen Erkl rung Zur verz gerten bersetzung von Variablen Bewirkt dass die Variable nicht zur Kompi lierzeit sondern erst zur Laufzeit bersetzt wird setzt die Verwendung von SETLOCAL zur Aktivierung von verz gerter bersetzung voraus Verwendung Beispielsweise zur besser differenzierten Ausf hrung von For Schleifen siehe LINK Beispiele Inhalt der Batchdatei Setlocal EnableDelayedExpansion Set _var first Set _var second amp Echo _var _var Ausgabe unter XP first second 3 5 Doppelpunkt Erkl rung Sprungmarke f r ein Unterprogramm bzw eine Kommentarzeile Sprungmarken werden ben tigt wenn mittels der Batchdatei eine Bedingung berpr ft und erf llt bzw nicht erf llt wird und entsprechend weiter verfahren werden soll Mit dem Batchbefehl goto wird die Sprungmarke angesprungen Anmerkung Der
69. et 217 173 128 45 3 139 ms 35 ms 36 ms bbcr01 ams titannetworks nl 217 173 143 17 4 40 ms 43 ms xsr03 asd002a surf net 195 69 144 34 5 41 ms 34 ms 35 ms AZ 500 XSR01 AmsterdamiA surf net 145 145 80 21 6 39 ms 38 ms 37 ms KNCSWOO1 router Customer surf net 145 145 18 158 7 41 ms 43 ms 37 ms gi0 24 csw2 knams wikimedia org 145 97 32 29 8 38 ms 38 ms 36 ms rr knams wikimedia org 145 97 39 155 Ablaufverfolgung beendet C gt 7 4 netstat Dieser Befehl zeigt alle offenen TCP IP ICMP UDP usw Verbindungen an netstat Mit der Erweiterung p Protokoll lassen sich auch nur Verbindungen zum Entsprechenden Protokoll auslesen meist TCP netstat p TCP 7 5 netsh Ohne Parametereingabe ergibt sich ein neuer Kontext Weitere Hilfe mit Beispiel netsh interface dump gt ipconfl dat Diese Zeile als Batch Datei ausgef hrt legt die momentane IP Konfiguration in einer Datei namens ipconfl dat ab Umgekehrt kann aus einer Datei z B namens ipconf2 dat eine neue IP Konfiguration geladen und bernommen werden netsh f ipconf2 dat 58 So lasst sich eine IP Konfiguration ohne Umherklicken in Systemmeniis ablegen und mo difiziert wieder zuriickholen 7 6 NET NET ist ein Tool zur Uberwachung und Manipulation von Netzwerkaktivit ten sowie Windows Diensten Es hat einen recht grofen Funktionsumfang von dem ich hier jedoch nur einige kurz vorstelle NET 7 6 1 NET
70. fen oder auszugeben wird der Variablenname von Prozentzeichen umgeben Der Befehl echo meinName w rde die Ausgabe Peter erzeugen Links mit umfassenden Informationen zur Variablenverwendung und zum Set Befehl e http commandwindows com variables htm 5 3 G ltigkeitsbereich von Variablen 5 3 1 Allgemeine Info zum G ltigkeitsbereich von Variablen Unter DOS und Windows 9x ME speichern alle Anwendungen und Skripte ihre Umge bungsvariablen in der gleichen Umgebung Unter Windows NT basierten Betriebssyste men ist dies etwas anders Zun chst gibt es einen systemweiten Bereich Dieser enth lt Variablen die f r alle Benut zer und alle Anwendungen zug nglich sind Zus tzlich hat jeder Benutzer seinen eigenen Variablenraum Jede Anwendung die n n vom System gestartet wird erh lt einen eigenen Variablenraum der als Kopie aus dem der aufrufenden Anwendung erzeugt wird ndert das Programm etwas Wert nderung neue Variable wirkt sich dies nicht auf parallel ge startete Anwendungen oder das System aus Lediglich Prozesse die von der Anwendung gestartet werden erhalten eine Kopie des Anwendungsvariablenraumes Dadurch ist es nicht m glich dass Anwendungen Umgebungsvariablen setzen die dann anschlie end in einer Batchdatei verwertbar sind Beispiel echo off set a 2 echo hah command c set a 1 echo hah Unter Dos wtirde die Ausgabe lauten 2 1 Unter Windows NT 2000 XP
71. formationen Wikipedia batch or http notepad plus sourceforge net de site htm 6 http de wikipedia org wiki Stapelverarbeitung Weiterfiihrende Informationen und Links e Infos zur cmd exe Wikipedia cmd exe e Die fiir Windows XP verfiigbaren Kommandos k nnen auch im Hilfesystem von Win dows direkt eingesehen werden e START Hilfe und Support e Befehlszeilenreferenz A Z in das Suchfeld eintragen F r englisches Windows Command line reference A Z 7 http de wikipedia org wiki cmd exe 2 Wichtige DOS Kommandos Man unterscheidet bei Batch Befehlen grunds tzlich zwischen internen und externen Befeh len vergleiche FreeDOS Kompendium Befehle Interne Befehle sind Bestandteil der Shell selbst w hrend externe Befehle als eigene Programme vorliegen Befehle die interessant fiir die Batch Programmierung sein k nnten sind im Folgenden aufgelistet 2 1 assoc Mit Hilfe dieses Befehls kann man die Dateierweiterungen bearbeiten bzw anzeigen lassen assoc dateiendung Dateibeschreibung 2 2 attrib ndert das Dateiattribut M glich sind schreibgesch tzt r r versteckt h h systemdatei s s und archiv a a 2 3 cacls ndert die Rechte Access Controll List auf NTFS Partitionen oder zeigt diese an cacls E T G Bob C F gt beispielsweise dem User Bob das Recht ndern f r alle Dateien und Ordner im aktuellen und allen Unterordnern hin
72. gt Ausgabe unter Win 8 Beta C gt cmd Microsoft Windows Version 6 2 8250 Copyright c 2012 Microsoft Corporation Alle Rechte vorbehalten C gt 3 11 COLOR Mit dem Befehl COLOR kann man die Vorder und Hintergrundfarbe ver ndern Die COLOR Werte bestehen aus zwei HEX Werten wobei der erste HEX Wert fiir die Hin tergrundfarbe und der zweite HEX Wert fiir die Vordergrundfarbe steht Jede Ziffer kann einen der folgenden Werte annehmen http www microsoft com resources documentation windows xp all proddocs en us ntcmds mspx mfr true 20 COMMAND HEX Wert Farbe HEX Wert Farbe F Wei Hellgrau Der folgende Befehl ergibt z B einen dunkelgr nen Hintergrund mit wei er Schrift COLOR 2F 3 12 COMMAND Syntax e DOS Windows 95 98 98 SE ME command Laufwerk PfadGer t e 1 u P MSG LOW Y cl k Befehl Web Links Erkl rung Verwendung Startet einen neuen Kommandointerpreter dieser kann mit exit wieder beendet werden Beispiel Inhalt command Ausgabe unter Windows 95 C WINDOWS gt command Microsoft R Windows 95 C Copyright Microsoft Corp 1981 1996 C WINDOWS gt 3 13 DATE Gibt das aktuelle Datum aus und erm glicht dem Benutzer die nderung des Datums Wird der Befehl mit dem Parameter t aufgerufen so wird nur das aktuelle Datum ausgegeben DATE kann auch als Variable benutzt werden so kann man zum Beispiel mit date 6 4 auf das Jah
73. he extent that they are valid under applicable law If additional permissions ap ply only to part of the Program that part may be used separately under those permissions but the entire Program remains governed by this License without regard to the additional permissions When you convey a copy of a covered work you may at your option remove any additional permissions from that copy or from any part of it Additional permissions may be written to require their own re moval in certain cases when you modify the work You may place additional permissions on material added by you to a covered work for which you have or can give appropriate copyright permission Notwithstanding any other provision of this License for material you add to a covered work you may if authorized by the copyright holders of that material supplement the terms of this License with terms a Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License or b Requiring pre servation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it or c Prohibiting misrepresentation of the origin of that material or requiring that modified versions of such material be marked in reasonable ways as different from the original version or d Limiting the use for publicity purposes of names of licensors or aut hors of the mat
74. his Lic give permission to use their names for publicity for or to assert or imply endorsement of any Modified Version 5 COMBINING DOCUMENTS e You may combine the Document with other documents released under this License under the terms defined in section 4 above for modified versions provided that you include in the combination all of the In variant Sections of all of the original documents unmodified and list them all as Invariant Sections of your combined work in its lic notice and that you preserve all their Warranty Disclai The combined work need only contain one copy of this License and multiple identical Invariant Sections may be replaced with a single copy If there are multiple Invariant Sections with the same name but different contents make the title of each such section unique by ad ding at the end of it in parentheses the name of the original author or publisher of that section if known or else a unique number Make the same adjustment to the section titles in the list of Invariant Sections in the license notice of the combined work Tn the combination you must combine any sections Entitled History n the various original documents forming one section Entitled Histo ry likewise combine any sections Entitled cknowledgements and any sections Entitled Dedications You must delete all sections En titled ndorsements 6 COLLECTIONS OF DOCUMENTS You may make a colle
75. his file allows anyone to use it for any purpose provided that the copyright holder is properly attributed Redistribution derivative work commercial use and all other use is permitted e EURO This is the common reverse face of a euro coin The copyright on the design of the common face of the euro coins belongs to the European Commission Authorised is reproduction in a format without relief drawings paintings films provided they are not detrimental to the image of the euro e LFK Lizenz Freie Kunst http artlibre org licence lal de e CFR Copyright free use 87 Abbildungsverzeichnis e EPL Eclipse Public License http www eclipse org org documents epl v10 php Copies of the GPL the LGPL as well as a GFDL are included in chapter Licenses Please note that images in the public domain do not require attribution You may click on the image numbers in the following table to open the webpage of the images in your webbrower 48 Kapitel 13 auf Seite 91 88 Abbildungsverzeichnis 89 13 Licenses 13 1 GNU GENERAL PUBLIC LICENSE 29 June 2007 Version 3 Copyright 2007 Free Software Foundation Inc lt http fsf org Everyone is permitted to copy and distribute verbatim copies of this license document but changing it is not allowed Preamble The GNU General Public License is a free copyleft license for software and other kinds of works The licenses for most software and other pr
76. i einer nderung der Sicherheitsrichtlinien per Registrierungs editor nicht vollst ndig vernachl ssigt werden 6 0 17 Status ber bearbeitete Zeilen ausgeben H ufig bearbeitet man eine Liste von Objekten mit einer FOR Schleife Damit man dar ber informiert ist wie weit die Bearbeitung bereits fortgeschritten ist kann man die Anzahl der Bearbeiteten Objekte im titel der DOS Box ausgeben lassen Schritt 1 Ermitteln z hlen der zu bearbeitenden Zeilen dies geht am besten mit folgender FOR Schleife FOR F eol tokens 1 2 3 YA IN find c liste txt DO echo C Zeilen Wobei das ein Zeichen sein muss das in jeder zu verarbeitenden Zeile vorkommt Dies ist am schnellsten Will man wirklich jede Zeile z hlen unabh ngig vom Inhalt dann kann man auch folgenden Befehl verwenden FOR F delims A IN findstr N liste txt DO echo A Zeilen Jetzt bedarf es noch des SET Befehl zum Berechnen der aktuellen Zeile und setLocal EnableDelayedExpansion dann k nnte das Script folgenderma en aussehen echo off setLocal EnableDelayedExpansion set COUNT 0 set COUNTMAX 0 FOR F eol tokens 1 2 3 A IN find c liste txt DO set COUNTMAX C for f eol tokens 1 delims j in liste txt do set A COUNT 1 title 0 COUNT Zeilen von COUNTMAX bearbeitet echo Tue etwas mit dem Token j REM der ping wird nur zur Verz gerung ausgefiihrt damit man der Titel Zeile besser verfolgen kann
77. inen bestimmten REG Zweig anzu springen set LastKey HKEY_LOCAL_MACHINE SOFTWARE Microsoft Windows NT CurrentVersion Hotfix set Key HKEY_CURRENT_USER Software Microsoft Windows CurrentVersion Applets Regedit reg add Key v LastKey d LastKey start regedit exe Erl uterung e LastKey ist der Reg Schl ssel der als Letztes angezeigt wurde und dieser wird beim Start von regedit direkt angesprungen diesen Schl ssel kann man nach Belieben an passen e Key ist der Reg Schl ssel in dem sich der Wert LastKey befindet LastKey wird mittels reg add in die Registry eingespielt und danach wird regedit gestartet Das Ganze funktioniert allerdings nur wenn regedit exe noch nicht l uft Und hier noch eine kleine Batchdatei um mit regedit exe Werte aus der Registry auszu lesen set K ey HKEY_CURRENT_USER Software Microsoft Windows CurrentVersion Applets Regedit regedit exe e c temp inhalt reg Key Achtung Die Datei inhalt reg ist im Unicode Format Ein Tipp dazu Der type Befehl kann Unicode lesen 8 0 8 TaskList Abfrage Eine Routine um das Laufen eines Prozesses mittels tasklist exe festzustellen In diesem Beispiel wird gepr ft ob Prozess exe l uft echo off set ProgEXE Prozess exe set tempdatei temp TempDatei txt tasklist FI IMAGENAME eq ProgEXE FO CSV gt tempdatei for F skip 2 tokens 1 delims f in ftempdatei do echo gefiltert 4 if YAE YProgEXE echo Prozess Pr
78. inen per call Probleme mit Filehandles bekommen k nnen Dies liegt darin begriindet dass ein Aufruf per call als Aufruf eines Unterprogramms interpretiert wird w hrend es sich bei goto stets um Unterroutines handelt Anmerkung goto eof ist eine Spezialmarke mit der Sie stets zum Ende Ihres Skriptes bzw Ihrer Unterroutine springen 6 0 7 Benutzereingaben mittels set P Cecho off set P w ilnstallieren d eInstallieren REM die option I beim if bewirkt dass nicht REM zwischen Gross und Kleinschreibung REM unterschieden wird if I Yw i goto Install if I Yw d goto Deinstall echo Fehler w goto ende Install echo installieren ausgew hlt goto ende Deinstall echo deInstallieren ausgew hlt goto ende ende 49 Programmierungshilfen 50 echo pause 6 0 8 stdout in Umgebungsvariable speichern Falls man den stdout in einer Umgebungsvariablen speichern m chte muss man das komplizierter umsetzen Es gibt zwei verschiedene M glichkeiten dies anzugehen befehl set P variable funktioniert n mlich nicht Stattdessen braucht man BEFEHL gt temp txt set p Befehl0utput lt temp txt del temp txt Oder FOR F i IN C BEFEHL DO set BefehlOutput i Oder mit usebackq Option FOR F usebackq i IN C BEFEHL DO set Befehl0utput 7 4i Die Zeichenkette zwischen den einfachen Anf hrungszeichen wird dabei als Befehlszeile betrachtet und von einer untergeordneten CMD EXE a
79. k containing the Document or a portion of it either copied verbatim or with modifica tions and or translated into another language A SSecondary Sectionis a named appendix or a front matter section of the Document that deals exclusively with the relationship of the publis hers or authors of the Document to the Document s overall subject or to related matters and contains nothing that could fall directly within that overall subject Thus if the Document is in part a textbook of mathematics a Secondary Section may not explain any mathematics The relationship could be a matter of historical connection with the subject or with related matters or of legal commercial philosophical ethical or political position regarding them The Invariant Sections re certain Secondary Sections whose titles are designated as being those of Invariant Sections in the notice that says that the Document is released under this License If a section does not fit the above definition of Secondary then it is not allowed to be designated as Invariant The Document may contain zero Invari ant Sections If the Document does not identify any Invariant Sections then there are none The Cover Textsiire certain short passages of text that are listed as Front Cover Texts or Back Cover Texts in the notice that says that the Document is released under this License A Front Cover Text may be at most 5 words and a Back Cover Text may be at most
80. k fiir alle erreichbaren lokalen Rechner Hinweis Da NET SEND leider sehr oft fiir Spam missbraucht wird wurde empfiehlt es sich es abzuschalten Dies geschieht ber den Windows Service Nachrichtendienst Dadurch k nnen weder Nachrichten gesendet noch empfangen werden NET STOP Mes senger 7 6 3 NET START Startet Windows Dienste Syntax 59 Netzwerkumgebung NET START Dienstname Entweder Messenger oder Nachrichtendienst je nach Regions Spracheinstellungen Die Eingabe von NET START ohne Parameter zeigt die aktuell gestarteten Windows Dienste an 7 6 4 NET STOP Stoppt Windows Dienste Gleiche Syntax wie NET START 7 6 5 NET VIEW Zeigt erreichbare Computer des lokalen Netzwerks bzw deren Freigaben an Syntax NET VIEW computername Einfache Eingabe von NET VIEW zeigt alle Computer an wenn ein Computername mit angegeben wird werden die Freigaben angezeigt Dies funktioniert nur bei Windows Rechnern UNIX Rechner mit Samba Freigaben werden zwar in der Ubersicht angezeigt die Freigaben k nnen aber nicht abgefragt werden 7 6 6 NET USER Mit diesem Befehl k nnen Benutzerkonten verwaltet werden Dazu sind Administrator rechte erforderlich Syntax NET USER Dieser Befehl allein zeigt nur alle Benutzer des Rechners an 2000 XP Net User lt name gt Durch diesen Befehl wird die Einstellung des Benutzerkontos des Benutzers lt name gt ange
81. ks org wiki Benutzer ThePacker tp de wikibooks org wiki Benutzer Trixium tp de wikibooks org wiki Benutzer Wolfgangbeyer Referenzen 3 Worker 47 http de wikibooks org wiki Benutzer Worker 85 Abbildungsverzeichnis e GFDL Gnu Free Documentation License http www gnu org licenses fdl html e cc by sa 3 0 Creative Commons Attribution ShareAlike 3 0 License http creativecommons org licenses by sa 3 0 e cc by sa 2 5 Creative Commons Attribution ShareAlike 2 5 License http creativecommons org licenses by sa 2 5 e cc by sa 2 0 Creative Commons Attribution ShareAlike 2 0 License http creativecommons org licenses by sa 2 0 e cc by sa 1 0 Creative Commons Attribution ShareAlike 1 0 License http creativecommons org licenses by sa 1 0 e cc by 2 0 Creative Commons Attribution 2 0 License http creativecommons org licenses by 2 0 e cc by 2 0 Creative Commons Attribution 2 0 License http creativecommons org licenses by 2 0 deed en e cc by 2 5 Creative Commons Attribution 2 5 License http creativecommons org licenses by 2 5 deed en e cc by 3 0 Creative Commons Attribution 3 0 License http creativecommons org licenses by 3 0 deed en e GPL GNU General Public License http www gnu org licenses gp1 2 0 txt e LGPL GNU Lesser General Public License http www gnu org licenses lgpl html e PD This image is in the public domain e ATTR The copyright holder of t
82. l calc exe Taschenrechner mshta exe Scripthost f r HTA HTML Scripting W CScript exe Beides Bestandteil des Windows Scripthostes f r JS und VBS iexplore exe Microsoft Windows Internet Explorer Standardbrowser f r Windows firefox exe Mozilla Firefox Internetbrowser dialer exe Windows Hilfeprogramm f r DFU Einwahlverbindungen Notepad exe Standard Textbearbeitungsprogramm von Microsoft cmd exe Microsoft Windows Befehlsprozessor f r Batch winword Microsoft Word 13 Wichtige DOS Kommandos 2 21 taskkill Ab Windows XP kann man mit diesem Befehl einen Prozess beenden beispielsweise wenn dieser nicht mehr reagiert Unter Einbindung von t werden auch alle untergeordneten Prozesse beendet und wenn man f hinzufiigt wird das Beenden erzwungen taskkill f iexplore exe t 2 22 tasklist Dieser Befehl listet alle aktiven Prozesse auf die gerade auf diesem Computer laufen Damit l sst sich zum Beispiel der Name eines zu beendenden Prozesses ermitteln siehe unter taskkill Mit einem hinzugef gten nh werden die Spalten berschriften ausgeblen det Der Befehl tasklist ist erst ab Windows XP verfiigbar 2 23 type Gibt den reinen Text Inhalt der angegebenen Datei z B bat cmd oder txt aus 14 3 Batch Befehle 3 1 Wichtiger Hinweis zu diesem Abschnitt Diese Liste ist nicht vollstandig weitere Befehle werden in den anderen Kapiteln dieses Buches erkl rt Mit der Zeit s
83. ld Prince Kassad Produnis Prog Reseka Robert Schneijo Smarties Spectrums Stefan Majewsky StefanTiran ThePacker Trixium Wolfgangbeyer 41 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 PRryrppppprpyrPpypypeypypppyppypyPyPyPyPyryey PS tqeteteatete tte tte tte tte tt tt tt tet tet tet te et cc ct 84 tp de wikibooks org wiki Benutzer Jan tp de wikibooks org wiki Benutzer Juetho tp de wikibooks org wiki Benutzer Klartext tp de wikibooks org wiki Benutzer Klaus_Eifert tp de wikibooks org wiki Benutzer LilTV tp de wikibooks org wiki Benutzer MF Warburg tp de wikibooks org wiki Benutzer MichaelFrey tp de wikibooks org wiki Benutzer MichaelFreyTool tp de wikibooks org wiki Benutzer Michfrm tp de wikibooks org wiki Benutzer Mjchael tp de wikibooks org wiki Benutzer Ocrho tp de wikibooks org wiki Benutzer Pc world de wikibooks org wiki Benutzer Prince_Kassad tp de wikibooks org wiki Benutzer Produnis tp de wikibooks org wiki Benutzer Prog tp de wikibooks org wiki Benutzer Reseka tp de wikibooks org wiki Benutzer Robert tp de wikibooks org wiki Benutzer Schneijo tp de wikibooks org wiki Benutzer Smarties tp de wikibooks org wiki Benutzer Spectrums tp de wikibooks org wiki Benutzer Stefan_Majewsky tp de wikibooks org wiki Benutzer StefanTiran tp de wikiboo
84. lfe unterschiedlicher Param ter http www microsoft com resources documentation windows xp all proddocs en us ntcmds mspx mfr true fest e Hinweis Der Prompt kann auch permanent ber eine Umgebungs variable ge ndert werden http www hanselman com blog ABetterPROMPTForCMDEXEOrCoolPromptEnvironmentVariablesAndANiceTransparentMultiprompt aspx 3 24 PUSHD POPD pushd wechselt zum angegebenen Pfad und speichert den aktuellen Pfad bis zum Aufruf von popd popd wechselt zum gespeicherten Pfad Die Befehle k nnen geschachtelt werden Syntax pushd pfad popd Beispiel C WINDOWS gt pushd c temp C temp gt pushd c C gt popd C temp gt popd C WINDOWS gt 3 25 REM Syntax rem comment Erkl rung REM leitet einen Kommentar ein Die Zeile wird ignoriert beachten Sie jedoch dass REM von einem Leerzeichen Tabulator gefolgt werden muss sonst wird die Ausfiihrung der Batchdatei unmittelbar beendet Alternativ k nnen zwei Doppelpunkte hinterein andergeschrieben werden um einen Kommentar anzuf hren hier ist ein Leerzeichen nicht notwendig Alternativ k nnen auch Sprungmarken oder der Echobefehl echo verwendet werden Beispiele REM kill iexplore exe kill iexplore exe kill iexplore exe echo kill iexplore exe Web Links 31 Batch Befehle Windows XP Professional Product Documentation Syntax Link Unterschiede alternativer Verwendungen Unterschiede alternativer Verwendungen Unters
85. lstring Syntax 39 Erweiterungen unter Windows NT 40 var n m Ergibt den Teilstring von var beginnend mit dem n ten Zeichen von links und einer Lange von m Zeichen Gez hlt wird ab 0 d h das erste Zeichen hat die Position 0 und nicht 1 Werden negative Werte verwendet so wird vom Ende des Strings von rechts nach links gez hlt Beispiel Inhalt set str myfile bat set name str 0 6 echo name In diesem Beispiel wird der Teilstring von str vom ersten Zeichen an mit einer L nge von 6 Zeichen ausgegeben Ausgabe myfile Stringsubstitution Syntax var stri str2 Mithilfe der Syntax var strl str2 kann die Zeichenkette str1 des Inhalts der Variablen var durch str2 ersetzt werden Beispiel Inhalt set str mycommand p m file echo str set str str p m t echo str In diesem Beispiel werden die Optionen p m des Befehls mycommand durch die Option t ersetzt Ausgabe mycommand p m file mycommand t file 5 1 5 Mit Variablen rechnen Arithmetische Operationen Rechnungen mit Variablen sind erst mit der Option a m glich Beispiel set WERT1 2 set WERT2 21 set a WERT1 WERT1 WERT2 echo WERT1 5 2 Variablenerstellung zuweisung und abruf Wertezuweisung Wertezuweisung Mit dem Befehl set kann einer Variablen ein Wert zugewiesen werden z B set mein Name Peter Werteabruf G ltigkeitsbereich von Variablen Um den Wert einer Variable abzuru
86. luminous to fit legibly you should put the first ones listed as many as fit reasonably on the actual cover and continue the rest onto adjacent pages If you publish or distribute Opaque copies of the Document numbering more than 100 you must either include a machine readable Transpa rent copy along with each Opaque copy or state in or with each Opaque copy a computer network location from which the general network using public has access to download using public standard network protocols a complete Transparent copy of the Document free of added material If you use the latter option you must take reasonably pru dent steps when you begin distribution of Opaque in quantity to ensure that this Transparent copy will remain thus accessible at the stated location until at least one year after the last time you distribute an Opaque copy directly or through your agents or retailers of that edition to the public It is requested but not required that you contact the authors of the Document well before redistributing any large number of copies to give them a chance to provide you with an updated version of the Document 4 MODIFICATIONS You may copy and distribute a Modified Version of the Document un der the conditions of sections 2 and 3 above provided that you release the Modified Version under precisely this License with the Modified Version filling the role of the Document thus licensing distribution and mo
87. ments r to con flict in title with any Invariant Section O Preserve any Warranty Disclaimer If the Modified Version includes new front matter sections or appendi ces that qualify as Secondary Sections and contain no material copied from the Document you may at your option designate some or all of these sections as invariant To do this add their titles to the list of Invariant Sections in the Modified Version s license notice These titles must be distinct from any other section titles You may add a section Entitled ndorsements provided it conta ins nothing but endorsements of your Modified Version by various parties for example statements of peer review or that the text has been approved by an organization as the authoritative definition of a standard You mi y add a passage of up to five words as a Front Cover Text assage of up to 25 words as a Back Cover Text to the end st of Cover Texts in the Modified Version Only one passage of Front Cover Text and one of Back Cover Text may be added by or through arrangements made by any one entity If the Document already includes a cover text for the same cover previously added by you or by arrangement made by the same entity you are acting on behalf of you may not add another but you may replace the old one on explicit permission from the previous publisher that added the old one The author s and publisher s of the Document do not by t
88. n Ordner in den Ordner c temp Der Befehl copy c test txt c temp kopiert die Datei test tzt aus dem Ordner c in den Ordner c temp Datei und Pfadnamen mit Sonderzeichen hier das Leerzeichen sowie m ssen beim Copy Kommando und den meisten anderen Kommandos in doppelten Anf hrungszeichen angegebenen werden zum Beispiel copy f Beispiel cmd c Dokumente und Einstellungen Siegfried Eigene Dateien Wie man sieht kann man beide Schreibweisen mischen Dagegen k nnen sich mehrfach vorhandene Anf hrungszeichen wieder aufheben Deshalb m ssen vom Benutzer angege bene Anf hrungszeichen erst entfernt werden bevor man in der eigenen Batchdatei neue setzt 67 Beispiele echo off echo Kopiert eine Datei in das eigene Benutzerprofil rem Die Anf hrungszeichen in der folgenden Zeile werden nur ben tigt rem damit zwischen dem Doppelpunkt und der Eingabe ein Abstand entsteht set p name Bitte geben Sie einen Dateinamen an rem In der folgenden Zeile werden alle Anf hrungszeichen entfernt da rem nach dem Gleichheitszeichen kein Ersattext folgt siehe auch set rem Das Set Kommando kommt sowohl beim Variablennamen als auch beim rem Inhalt ohne Anf hrungszeichen aus set name name rem An dieser Stelle sollte erst gepr ft werden ob die Datei berhaupt rem existiert aber das wiirde den Rahmen hier sprengen copy name HOMEDRIVE HOMEPATH Eigene Dat
89. n mit ECHO Mit Hilfe des echo Befehls k nnen Sie auch in einem Skript Benutzereingaben simulieren indem Sie den Pipe Operator verwenden 10 11 22 Kapitel 3 29 auf Seite 33 Kapitel 3 1 auf Seite 15 ERRORLEVEL Beispiel Uhrzeit anzeigen ohne Nachfrage Das normale Verhalten des time Befehls ist die aktuelle Zeit der verwendeten Systemuhr anzuzeigen und in der n chsten Zeile die Eingabe einer neuen Uhrzeit zu erwarten Dr ckt man auf Enter bleibt die Systemzeit unver ndert Will man die Zeit nur anzeigen lassen z B in einer Batchdatei vor und nach einer Befehlsfolge um zu messen wie lange der PC daf r braucht l sst sich die Bet tigung der Enter Taste durch einen entsprechenden echo Befehl ersetzen echo time ber den Pipe Mechanismus l sst sich dar ber hinaus die Zeile Geben Sie die neue Uhrzeit ein unterdr cken echo time lfind v neue Dabei ist die Gro Kleinschreibung von neue zu beachten oder der Schalter I zu verwenden denn find ist case sensitiv Diese Beispiele dienen allerdings nur zur De monstration denn die Zeitausgabe w re auch ohne Pipes aber erst ab Windows 2000 m glich mit time t oder einfach echo time Sehr n tzlich ist das echo Piping auch zur bergabe von Benutzereingaben welche von einzelnen Befehlen abgefragt werden Beispiel berpr fung einer Festplatte chkdsk c r kann da es sich beim Laufwerk C um das Systemlaufwerk handelt er
90. nd ODER Verkn pfungen ist leider nicht ohne weiteres m glich 3 21 KEYB L dt Tastaturtreiber keyb gr c dos keyboard sys l dt den deutschen Tastaturtreiber keyboard sys muss sich im Verzeichis c dos befinden 3 22 PAUSE Unterbricht die Abarbeitung der Batchdatei und wartet auf einen Tastendruck Syntax pause Interner Befehl Ab MS DOS bis Windows NT 5 1 XP Beispiel 1 Inhalt echo off echo Willkommen zur Batchdatei 0 echo echo Die Batchdatei wird auf einer neuen Seite fortgef hrt pause cls echo Hier f ngt meine Batchdatei an pause Ausgabe Willkommen zur Batchdatei beispiel bat Die Batchdatei wird auf einer neuen Seite fortgefiihrt Bitte beliebige Taste driicken Neue Seite Hier fangt meine Batchdatei an Bitte beliebige Taste driicken Beispiel 2 Inhalt echo off echo Diese Zeile wird angezeigt anstelle von Bitte beliebige Taste driicken pause gt NUL Ausgabe Diese Zeile wird angezeigt anstelle von Bitte beliebige Taste driicken Um eine Pause fiir eine bestimmte Zeitdauer vorzugeben kann der ping Befehl miss braucht werden Das folgende Beispiel erzeugt eine Pause von genau 10 Sekunden durch die Ausgabeumleitung gt nul wird jegliche Meldung unterdr ckt ping 1 2 3 4 n 1 w 10000 gt nul 15 30 Kapitel 7 1 auf Seite 55 PROMPT 3 23 PROMPT e Syntax prompt text e Erkl rung Legt das Aussehen der Eingabezeile mit Hi
91. ndert diesen CHCP Zeigt die aktive Codepagenummer an bzw legt diese fest CHDIR Zeigt den Namen des aktuellen Verzeichnisses an bzw ndert diesen CHKDSK berpr ft einen Datentr ger und zeigt einen Statusbericht an CHKNTFS Zeigt die berpr fung des Datentr gers beim Start an bzw ver ndert sie CLS L scht den Bildschirminhalt CMD Startet eine neue Instanz des Windows Befehlsinterpreters COLOR Legt die Hintergrund und Vordergrundfarben f r die Konsole fest COMP Vergleicht den Inhalt zweier Dateien oder S tze von Dateien COMPACT Zeigt die Komprimierung von Dateien auf NTFS Partitionen an bzw ndert diese 77 Referenz 78 CONVERT COPY DATE DEL DIR DISKCOMP DISKCOPY DOSKEY ECHO ENDLOCAL ERASE EXIT FC FIND FINDSTR FOR FORMAT FTYPE GETMAC GOTO GRAFTABL HELP IF LABEL MD MKDIR MODE MORE MOVE NET USE PATH Konvertiert FAT Volumes in NTFS Das aktuelle Laufwerk kann nicht konvertiert werden Kopiert eine oder mehrere Dateien an eine andere Stelle Zeigt das Datum an bzw legt dieses fest L scht eine oder mehrere Dateien Listet die Dateien und Unterverzeichnisse eines Verzeichnisses auf Vergleicht den Inhalt von zwei Disketten Kopiert den Inhalt von einer Diskette auf eine andere Diskette Bearbeitet Befehlseingaben ruft Windows Befehle zur ck und erstellt Macros Zeigt Meldungen an bzw schaltet die Befehlsanzeige ein oder aus Beendet
92. new problems or concerns Each version is given a distinguishing version number If the Program that a certain numbered version of the GNU General Public License or any later version applies to it you have the option of fol lowing the terms and conditions either of that numbered version or on published by the Free Software Foundation If the Program does not specify a version number of the GNU General Pu blic License you may choose any version ever published by the Free Software Foundation If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used that proxy s public statement of acceptance of a version permanently authorizes you to choose that version for the Program Later li ons Howeve versions may give you additional or different permiss r no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version 15 Disclaimer of Warranty THERE IS NO WARRANTY FOR THE PROGRAM TO THE EXTENT PERMITTED BY APPLICABLE LAW EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOL DERS AND OR OTHER PARTIES PROVIDE THE PROGRAM AS IS WITHOUT WARRANTY OF ANY KIND EITHER EX PRESSED OR IMPLIED INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PRO GRAM IS WITH YOU SH
93. nst deaktivieren machen echo on sc config 41 start Parameter echo off echo echo goto eof 8 0 10 Windows XP SP2 installierte Patches Updates auflisten Zeigt unter Windows XP mit Service Pack 2 alle zusatzlich installierten Patches Updates an echo off set RegHotfixListe HKEY_LOCAL_MACHINE SOFTWARE Microsoft Windows NT CurrentVersion Hotfix set RegHotfixInfo HKEY_LOCAL_MACHINE SOFTWARE Microsoft Updates Windows XP SP3 for F delims tokens 7 in reg query RegHotfixListe do set HotFixNr f CALL Anzeigen echo echo pause goto eof Anzeigen reg query YRegHotfixListe HotFixNr v Installed FIND 0x1 gt NUL if perrorlevel 0 set installiert ja call KB_Info ELSE set installiert nein echo HotFixNr Ist Installiert installiert if not InstalledBy echo HotFixNr installiert von InstalledBy if not YInstalledDate echo HotFixNr am InstalledDate echo goto eof KB_Info set InstalledBy for F tokens 3 c in reg query RegHotfixInfo HotFixNr v InstalledBy 2 gt NUL FIND InstalledBy do set InstalledBy c set InstalledDate for F tokens 3 c in reg query RegHotfixInfo HotFixNr v InstalledDate 2 gt NUL FIND InstalledDate do set InstalledDate c 65 Beispiele goto eof 8 0 11 Printdateien direkt an den Drucker senden Sendet einzelne Druckdateien an im Netzwerk freigegebene Drucker
94. ogEXE l uft goto ende echo Prozess ProgEXE l uft nicht goto ende ende del tempdateiZ 63 Beispiele Alternativ ohne obige tempor re Datei tempdatei zu ben tigen kann man beispielsweise unter Windows XP folgendes verwenden TaskList FI IMAGENAME eq ProgEXE 2 gt NUL Find ProgEXE gt NUL IF ERRORLEVEL 1 ECHO NOT Running GOTO Ende ELSE ECHO Running GOTO Ende 8 0 9 Dienste einrichten echo off prompt G echo echo Manuelle Dienste echo call M helpsvc Hilfe und Support call M ImapiService IMAPI CD Brenn COM Dienste echo echo nicht ben tigte Dienste Deaktivieren echo call D cisvc Indexdienst call D ERSvc Fehlerberichterstattungsdienst echo echo Automatische Dienste echo call A CryptSvc Kryptografiedienste call A MSIServer Windows Installer echo echo echo Fertig echo pause goto eof tA echo 2 auf Automatisch set Parameter auto net start 1 goto machen M echo 2 auf Manuell set Parameter demand net stop 1 goto machen D echo 2 auf Deaktiviert set Parameter disabled net stop 1 goto machen rem Systemstart Ger tetreiber der vom Startladeprogramm geladen wird rem system Ger tetreiber start w hrend der Kernelinitialisierung rem auto automatischer start nach systemstart vor Benutzeranmeldung 64 NET rem demand Dienst der manuell gestartet werden muss rem disabled Die
95. ollen alle Befehle in diese Liste bertragen werden um aus den anderen Kapitel referenziert werden zu k nnen 3 2 Vorsicht Leerzeichen Fehlplazierte oder fehlende Leerzeichen k nnen bei dem Programmieren einer Batch Datei zu Fehlern fiihren Bei den nachfolgenden Beispielen ist also auf die Platzierung von Leerzeichen und auf entsprechende Bemerkungen genau zu achten Scheinbar grund lose Abbriiche beim Ausfiihren einer Batch Datei k nnen ebenfalls fehlplatzierten oder fehlenden Leerzeichen geschuldet sein 33 Q Schaltet die Ausgabe der Befehlszeile auf dem Bildschirm nur f r den aktuellen Befehl aus und ist selbst kein eigener Befehl Syntax befehl Stapelanweisung Ab MS DOS bis Windows 7 Beispiel Inhalt echo Diese Zeile wird mit Befehlszeile ausgefuehrt echo und diese ohne Ausgabe C gt echo Diese Zeile wird mit Befehlszeile ausgefuehrt Diese Zeile wird mit Befehlszeile ausgefuehrt und diese ohne In Batch Files verhindert echo off zu Beginn des Skriptes die Ausgabe aller Be fehlszeilen auf dem Bildschirm bis die Stapelverarbeitung beendet wird abbricht oder mittendrin ein echo on Befehl erfolgt um z B Befehlszeilen tats chlich anzuzeigen und dann auszuf hren Kommentare mit oder REM werden nat rlich auch nicht an gezeigt Ist aber nur ein Nebeneffekt Bei REM sollte man jedoch unbedingt aufpassen da dort ungewollt der remove Befehl gestartet werden kann was zu massiven Datenv
96. peichert sondern bei jedem Aufruf durch einen Interpreter zur Laufzeit in ein f r den Computer verst ndliches Format bersetzt wird Ein Texteditor wie MS Notepad den Win dows von Haus aus mitbringt reicht vollkommen aus um Batchprogramme zu schreiben Batchprogrammierung ist speziell f r die Steuerung des Betriebssystems gedacht f r die Entwicklung von Anwendungen ist sie nicht geeignet Hierzu verwendet man Sprachen wie C C und Java nicht zu verwechseln mit JavaScript http de wikipedia org wiki Cmd exe http de wikibooks org wiki 3Aw 3AWindows_Script_Host http de wikibooks org wiki 3Aw 3AWindows_PowerShell http de wikibooks org wiki Compiler Ae 0N A Allgemeine Information 1 3 Nutzung von Batchprogrammen Viele wiederkehrende Installations und Verwaltungsaufgaben die man traditionell mit Tas tatur und Maus ausf hrt lassen sich mit Stapeldateien ausf hren Hat man gen gend Kom mentarzeilen in die Batchdatei eingef gt gen gt der Ausdruck der Stapeldatei meist als Dokumentation Kommandozeilenbefehle und Batchdateien sind keine veraltete Technologie Auf Wunsch vieler Systemadministratoren hat Microsoft daf r gesorgt dass Windows Server 2003 voll standig von der Kommandozeile installiert und administriert werden kann ohne die Maus zu benutzen Die Begriffe Stapelprogramm und Stapelverarbeitung r hren aus der Zeit her als Per manentspeicher auf Magnetplatten sehr teuer war Zu dieser Z
97. piel C gt ipconfig renew 7 2 3 ipconfig flushdns Situation Eine Homepage wird nicht angezeigt stattdessen wird eine Fehlermeldung angezeigt wie z B Die Website k nnte vor bergehend nicht erreichbar sein versuchen Sie es bitte sp ter nochmals Als Test wird der Server angepingt und es kommt eine Fehlermeldung Zeit berschreitung der Anforderung Der Administrator k mmert sich um das Problem und sagt der Server sei wieder OK aber noch immer kommen Fehlermeldungen und Homepages k nnen nicht angezeigt werden Dann kann es daran liegen dass der DNS Cache noch die Fehlmeldung gespei chert hat und dieser muss geleert werden Anstelle den Rechner neu zu starten gibt man folgendes ein C gt ipconfig flushdns Windows IP Konfiguration Der DNS Aufl sungscache wurde geleert Cr gt 7 2 4 ipconfig release Gibt die vom DHCP Server zugeteilte IP Adresse zuriick Anschliessend kann mit ip config renew eine neue Adresse vom DHCP Server geholt werden 7 3 tracert Mit tracert kann man die Route vom eigenen PC zur Zieladresse verfolgen und evtl R ckschl sse ziehen ob und warum eine Verbindung h ngt Beispiel C gt tracert de wikibooks org Ausgabe 57 Netzwerkumgebung Routenverfolgung zu rr knams wikimedia org 145 97 39 155 ber maximal 30 Abschnitte 1 lt i ms lt i ms lt i ms 123 456 789 1 2 24 ms 18 ms 19 ms adslgw01 fra4 rm com n
98. ping n 1 localhost gt NUL 7 Netzwerkumgebung 7 1 ping Kann verwendet werden um die Verbindung zu einem anderen Rechner zu testen Wenn die Gegenseite antwortet werden Informationen ber die IP Nummer und zur Verbin dungsqualit t angezeigt Zu beachten ist dabei dass aus einer ausbleibenden Antwort nicht zwangsl ufig auf einen missgl ckten Verbindungsversuch geschlossen werden darf manche Administratoren unterbinden diese Art Test aus Sicherheitsgr nden Beispiel C gt ping de wikibooks org Ausgabe Ping rr knams wikimedia org 145 97 39 155 mit 32 Bytes Daten Antwort von 145 97 39 155 Bytes 32 Zeit 67ms TTL 57 Antwort von 145 97 39 155 Bytes 32 Zeit 35ms TTL 57 Antwort von 145 97 39 155 Bytes 32 Zeit 34ms TTL 57 Antwort von 145 97 39 155 Bytes 32 Zeit 39ms TTL 57 Ping Statistik f r 145 97 39 155 Pakete Gesendet 4 Empfangen 4 Verloren 0 0 Verlust Ca Zeitangaben in Millisek Minimum 34ms Maximum 67ms Mittelwert 43ms Cas Hinweis Dies l sst sich durch einen Trick mit dem find Befehl auch automatisieren ping de wikibooks org find TTL goto hostnotfound 7 2 ipconfig e Durch den Parameter help erh lt man kurze Hilfe e Der Aufruf des Befehls ipconfig ohne Parameter teilt die eigene IP Adresse mit e Durch den Befehl ipconfig l sst sich die IP Adresse von Netzwerkverbindungen Ether netkarten verwalten Beispiel C gt ip
99. pplicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996 or similar laws prohibiting or restricting circumvention of such measures When you convey a covered work you waive any legal power to forbid circumvention of technological measures to the extent such vention is effected by exercising rights under this License with respect to the covered work and you disclaim any intention to limit opera tion or modification of the work as a means of enforcing against the work s users your or third parties legal rights to forbid circumvention of technological measures 4 Conveying Verbatim Copies circum You may convey verbatim copies of the Program s source code as you receive it in any medium provided that you conspicuously and appro priately publish on each copy an appropriate copyright notice keep in tact all notices stating that this License and any non permissive terms added in accord with section 7 apply to the code keep intact all noti ces of the absence of any warranty and give all recipients a copy of this License along with the Program You may charge any price or no price for each copy that you con vey and you may offer support or warranty protection for a fee 5 Conveying Modified Source Ve You may convey a work based on the Program or the modifications to produce it from the Program in the form of source code under the erms of section 4
100. pplies to it you have the option of fol lowing the terms and conditions either of that specified version or of any later version that has been published not as a draft by the Free Software Foundation If the Document does not specify a version num ber of this License you may choose any version ever published not as a draft by the Free Software Foundation If the Document spec fies that a proxy can decide which future versions of this Licens be used that proxy s public statement of acceptance of a ve RELICENSING sive Multiauthor Collaboration Site or MMC Site means any World Wide Web server that publishes copyrightable works and also provides prominent facilities for anybody to edit those works A public wiki that anybody can edit is an example of such a server A Massive Multiauthor Collaboration or MMC contained in the site means any set of copyrightable works thus published on the MMC site CC BY SA means the Creative Commons Attribution Share Alike 3 0 license published by Creative Commons Corporation a not for profit corporation with a principal place of business in San Francisco California as well as future copyleft versions of that license published by that same organization incorporate means to publish or republish a Document in whole or in part as part of another Document An MMC is ligible for relic and if all works that were first published under this Licen
101. r auftritt Wenn die Fehlerausgabe in die gleiche Datei wie die Standardausgabe umgeleitet werden soll h ngt man noch 2 gt amp 1 an Beispiel type EineDatei txt gt UmgeleiteteAusgabe txt 2 gt amp 1 Der Inhalt der Datei EineDatei txt wird in die Datei UmgeleiteteAusgabe tat kopiert wenn EineDatei txt existiert type EineDateiDieNichtExistiert txt gt UmgeleiteteAusgabe txt 2 gt amp 1 Wenn die Datei EineDateiDieNichtExistiert tat nicht existiert dann wird die Fehlermel dung stderr nicht im Dos Fenster ausgegeben sondern wird auch in die Datei Umge leitete Ausgabe t xt geschrieben 4 7 gt gt Umleitung der Standard Ausgabe mit Anh ngen des Textes falls die Datei schon exis tiert sonst wird die Datei wie bei gt siehe oben angelegt Syntax befehl gt gt file Stapelanweisung Ab bis Windows 7 Beispiel Inhalt echo Hallo gt tmp txt echo Haallooo gt gt tmp txt type tmp txt Ausgabe Hallo Haallooo Hier gilt analoges f r die Fehler Ausgabe siehe Operator gt oben 37 5 Erweiterungen unter Windows NT 5 1 Variablen Kurztibersicht 5 1 1 Hinweis Diese Seite in diesem Abschnitt eingef gt und berarbeitet enthielt urspr nglich nde rungen des Kommandozeileninterpreters von DOS auf Windows NT und beschrieb mehr oder weniger die Erweiterungen f r Standard Befehle 5 1 2 Scriptvariablen und Systemvariablen Es gibt zweierlei Arten von Variablen Scriptvariablen
102. r zugreifen Beispiele z gt date T 12 06 2013 z gt echo Heute ist der date Heute ist der 12 06 2013 21 Batch Befehle z gt echo date 6 4 2013 Hier werden vom Datum die ersten 6 Zeichen weggelassen und dann vier Stellen angezeigt Bei time funktioniert das analog Bei einigen Betriebssystemversionen erfordert das ndern des Systemdatums adminis trative Rechte XP Die Ausgabe des Datumsformates ist abh ngig von den Einstellungen in den Regions und Sprachoptionen Systemsteuerung Hinweis die Uhrzeit laesst sich mit dem Befehl TIME ermitteln 3 14 ECHO Gibt einen Text aus oder schaltet die Befehlszeilen an aus Wenn ein Text ausgegeben wird k nnen dort auch Variablen angezeigt werden wie z B die Variable ver in Windows XP os Syntax echo text ON OFF oder alternativ echo text Interner Befehl Ab MS DOS bis Windows NT 5 1 XP Beispiel Inhalt echo off echo Die aktuelle Datei hei t 0 echo Die aktuelle Version Ihrer Befehls Konsole oder 0S hei t hver Ausgabe Die aktuelle Datei hei t beispiel bat Die aktuelle Version Ihrer Befehls Konsole oder 0S hei t Windows NT Mit echo k nnen Sie zudem leere Zeilen ausgeben Beispiel Inhalt echo off echo Jetzt gibt es 3 Leere Zeilen zu sehen echo echo echo echo So Da waren sie Ausgabe Jetzt gibt es 3 Leere Zeilen zu sehen So Da waren sie 3 14 1 Benutzereingabe
103. rant a patent license to some of the parties receiving the covered work authorizing them to use propagate modify or convey a specific copy of the covered work then the patent license you grant is automatically extended to all recipients of the covered work and works based on it A patent license is discriminatory if it does not include within the pe of its coverage prohibits the exercise of or is conditioned on the non exercise of one or more of the rights that are specifically granted under this License You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software under which you make payment to the third party based on the extent of your activity of conveying the work and under which the third party grants to any of the parties who would receive the covered work from you a discriminatory patent license a in connection with copies of the covered work conveyed by you or copies made from those copies or b primarily for and in connection with specific products or compilations that contain the covered work unless you entered into that arrangement or that patent license was granted prior to 28 March 2007 Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law 12 No Surrender of Others Freedom
104. rcially provided that this License the co pyright notices and the li ce saying this License applies to and that you add no other conditions whatsoever to those of this License You may not use tech nical measures to obstruct or control the reading or further copying of the copies you make or distribute However you may accept compen sation in exchange for copies If you distribute a large enough number of copies you must also follow the conditions in section 3 You may also lend copies under the same conditions stated above and you may publicly display copies 3 COPYING IN QUANTITY If you publish printed copies or copies in media that commonly have printed covers of the Document numbering more than 100 and the Document s license notice requires Cover Texts you must enclose the copies in covers that carry clearly and legibly all these Cover Texts Front Cover Texts on the front cover and Back Cover Texts on the back cover Both covers must also clearly and legibly identify you as the publisher of these copies The front cover must present the full title with all words of the title equally prominent and visible You may add other material on the covers in addition Copying with changes limited to the covers as long as they preserve the title of the Document and satisfy these conditions can be tre copying in other pi ed as verbatim If the required texts for either cover are too vo
105. reinstated a provisionally less and until the copyright holder explicitly and finally terminates your license and b permanently if the copyright holder fails to no tify you of the violation by some reasonable means prior to 60 days after the c tion Moreover your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means this is the first time you have received notice of violation of this License for any work from that copyright holder and you cure the violation prior to 30 days after your receipt of the notice Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License If your rights have been terminated and not permanently reinstated receipt of a copy of some or all of the same material does not give you any rights to use it 10 FUTURE REVISIONS OF THIS LICENSE The Free Software Foundation may publish new revised versions of the GNU Free Documentation License from time to time Such new versions will be similar in spirit to the present version but may differ in detail to address new problems or concerns See http www gnu org copyleft Each version of the License is given a distinguishing version number If the Document specifies that a particular numbered version of this License r any later version
106. rnative is allowed only occasionally and noncommercially and on ly if you received the object code with such an offer in accord with subsection 6b d Convey the object code by offering access from a designated place gratis or for a charge and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge You need not require recipients to copy the Corre sponding Source along with the object code If the place to copy the object code is a network server the Corresponding Source may be on a different server operated by you or a third party that supports equi valent copying facilities provided you maintain clear directions next to the object code saying where to find the Corresponding Source Re gardless of what server hosts the Corresponding Source you remain obligated to ensure that it is available for as long as needed to satis fy these requirements e Convey the object code using peer to peer transmission provided you inform other peers where the object code and Corresponding Sou of the work are being offered to the general publi ubsection 6d at no charge under A separable portion of the object code whose source code is exclu ded from the Corresponding Source as a System Library need not be included in conveying the object code work A User Product is either 1 a consumer product which means any
107. rtet das Fenster minimiert start e MAX Startet das Fenster maximiert e SEPARATE Startet 16 Bit Windows Programm in separatem Speicherbereich e SHARED Startet 16 Bit Windows Programm in gemeinsamen Speicherbereich e LOW Startet Anwendung in IDLE Priorit tsklasse e NORMAL Startet Anwendung in der NORMAL Priorit tsklasse e HIGH Startet Anwendung in der HIGH Priorit tsklasse e REALTIME Startet Anwendung in der REALTIME Prioritatsklasse e WAIT Startet die Anwendung und wartet auf das Ende e B Startet die Anwendung ohne ein neues Fenster zu ffnen Die Anwendung igno riert STRG C Wenn die Anwendung nicht selbst ndig STRG C berpr ft ist STRG UNTBR die einzige M glichkeit um die Anwendung abzubrechen e Gibt die Hilfe aus Erkl rung e Startet ein Programm als neues eigenes Fenster Beispiel WinXP zum ffnen eines neuen Konsolenfensters in dem eine Datei aufgerufen wird start Name des neuen Fensters WAIT D C temp NORMAL call test bat WAIT Wartet bis Anwendung geschlossen wird NORMAL Startet Anwendung in der NORMAL Priorit tsklasse D Danach folgt das Startverzeichnis N tzliche System Programme Hier eine Liste der n tzlichen System Programme die man so ausf hren kann regedit exe neuer Registrierungseditor regedt32 exe lterer Registrierungseditor explorer exe Windows Ordner Explorer taskmgr exe Windows Taskmanager taskeng exe Aufgabenplanungsmodu
108. s granted under this License are granted for the term of copy right on the Program and are irrevocable provided the stated conditi ons are met This License explicitly affirms your unlimited permission to run the unmodified Program The output from running a covered work is covered by this License only if the output given its content constitutes a covered work This License acknowledges your rights of fair use or other equivalent as provided by copyright law You may make run and propagate covered works that you do not con vey without conditions so long as your license otherwise remains in force You may convey covered works to others for the sole purpose of having them make modifications exclusively for you or provide you with facilities for running those works provided that you comply with the terms of this License in conveying all material for which you do not control copyright Those thus making or running the covered works for you must do so exclusively on your behalf under your direction and control on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you Conveying under any other circumstances is permitted solely under the conditions stated below Sublicensing is not allowed section 10 makes it unnecessary 3 Protecting Users Legal Rights From Anti Circumvention Law No covered work shall be deemed part of an effective technological me asure under any a
109. sches Alphabet 3 9 CLS Mit cls clear screen wird der Bildschirm gel scht Syntax cls Interner Befehl Ab MS DOS bis Windows 8 Beispiel Inhalt echo off echo Hier schreibe ich jetzt ganz viel Text echo Hier kann ich z B hinschreiben dass ich jemanden mag echo echo Aber den Text sieht man gleich sowieso nicht mehr Hihi cls echo War irgendetwas pause gt nul Ausgabe War irgendetwas 3 10 CMD Syntax e Windows 2000 XP Vista 7 und 8 cmd al ul al dl e ON OFF ON OFF v ONIOFF c befehll s kl y e DOS Windows 95 98 ME 19 Batch Befehle entspricht dem Batch Befehl COMMAND CMD ist unter DOS nicht vorhanden Web Links e Windows XP Professional Product Documentation Erkl rung Der Befehl CMD startet eine neue Instanz des Kommandozeileninterpreters cmd exe Verwendung In Kombination mit dem Befehl START ffnet sich die neue Instanz auch in einem neuen Kommandozeilenfester ohne START ffnet sie sich im gleichen Fenster Beispiele Inhalt der Batchdatei cmd Ausgabe unter XP C gt cmd Microsoft Windows XP Version 5 1 2600 C Copyright 1985 2001 Microsoft Corp C gt Ausgabe unter Vista C gt cmd Microsoft Windows Version 6 0 6001 Copyright c 2006 Microsoft Corporation Alle Rechte vorbehalten C gt Ausgabe unter Win 7 C gt cmd Microsoft Windows Version 6 1 7600 Copyright c 2009 Microsoft Corporation Alle Rechte vorbehalten C
110. se Wenn die Befehlserweiterungen aktiviert sind Standard ab Windows 2000 kann man auch Sprungmarken aufrufen und auch Parameter bergeben Beispiel echo off REM Diese Batchdatei ruft eine eigene Sprungmarke auf echo Vor dem Sprung call sprungmarke echo Nach dem Sprung pause goto end sprungmarke echo Sprungmarke aufgerufen goto eof EOF f hrt nicht zum unsichtbaren Ende der Batch Datei wie unten beschrieben sondern f hrt die Batch Datei nach dem Aufruf der Sprungmarke fort end exit Die Ausgabe Vor dem Sprung Sprungmarke aufgerufen Nach dem Sprung Beispiel mit Parameter echo off REM Diese Batchdatei ruft eine eigene Sprungmarke auf echo Vor dem Sprung call sprungmarke meinParameter echo Nach dem Sprung pause goto end sprungmarke echo Sprungmarke aufgerufen und Parameter 1 uebergeben goto eof CHCP end exit Die Ausgabe Vor dem Sprung Sprungmarke aufgerufen und Parameter meinParameter uebergeben Nach dem Sprung goto eof Dieser Befehl springt automatisch zum Ende der Batchdatei beendet die aktuelle Pro zedur 3 8 CHCP Anzeige der aktuellen CodePage oder Setzen einer neuen CodePage change codepage chcp nnn Beispiele f r nnn 437 Die urspriingliche Zeichensatztabelle des IBM PC 720 Arabisches Alphabet 737 Griechisches Alphabet 850 westeurop ische Sprachen DOS Latin 1 857 T rkisches Alphabet 866 Kyrilli
111. ssage Fenster erzeugen Bisher konnte man in Batch keine Fenster erzeugen bzw nur in Windows XP mithilfe des Windows Nachrichtendienstes Doch der ist f r Anwendungen viel zu unpraktisch da man nicht einmal den Fenstertitel bestimmen kann und au erdem ist dieser unter Vista oder Windows 2000 nicht verf gbar Ich habe jedoch ein kleines Schlupfloch gefunden mit dem man dennoch Fenster erzeugen kann echo off Echo msgbox Text 0 Fenstername gt Test vbs ping localhost n 3 w 1000 gt NUL start Test vbs pause 53 Programmierungshilfen 54 Erkl rung Man erzeugt hier mithilfe des Umleitungssymbols Eng pipe gt einen Tem por ren VBScript der in der Lage ist ein Messagefenster zu erzeugen Dies sorgt in Anwendungen fiir mehr Ubersicht und Professionalitat 6 0 16 Falls das nicht funktioniert Falls statt eures Textes die Meldung Der Zugriff auf den Windows Scripthost ist auf diesem Computer deaktiviert er scheint dann ist das Offnen von VBscripts und JScripts aus Sicherheitsgriinden verboten Um das zu ndern ffnet ihr den Windows Registrierungseditor regedit exe und l scht NUR folgenden Wert HKey_Local_ Machine Software Microsoft WindowsScriptHost Enabled dann d rfte es funktionieren Sicherheitshinweise e Erstellt vor der nderung eine Sicherheitskopie eurer Werte e Die Sicherheitsgr nde verringern unter anderem die Angriffsfl che f r W rmer u Sch dlinge dies sollte be
112. st nach einem Systemstart ausgef hrt werden Normalerweise m sste der Benutzer deswegen den Sys temstart durch Eingabe von Y best tigen Diese Aktion kann man in einem Batch so abbilden echo y chkdsk c f r 3 15 ERRORLEVEL Syntax e Windows XP Windows Vista Windows 7 errorlevel Verwendung Zeigt an ob der letzte Befehl erfolgreich war Beispiel del homepath Desktop Ordner echo errorlevel e del homepath Desktop Ordner Im Homepath C Users Username wird im Ordner Desktop der Ordner Ordner gel scht e echo Errorlevel Errorlevel wird angezeigt 1 bedeutet Befehl fehlgeschlagen 0 bedeutet Befehl ausgef hrt 2 bedeutet Unbekannt 3 16 ENDLOCAL SETLOCAL Syntax 23 Batch Befehle e Windows XP ENDLOCAL Links e http ss64 com nt endlocal html Verwendung Schliesst den Befehl SETLOCAL ab Siehe SETLOCAL 3 17 EXIT Beendet die Abarbeitung der Batchdatei bzw die Kommandozeilenfenster 3 18 FOR Erm glicht die Schleifenbearbeitung Syntax for Variablein Satzdo Befehl Parameter Interner Befehl Ab MS DOS bis Windows NT 6 1 Windows 7 ACHTUNG Die Variable darf nur aus einem Buchstaben bestehen t ist erlaubt test nicht Bei der Verwendung mehrerer Befehle muss zwischen DO und der Klammer ein Leerzeichen sein Falsch for Variable in Satz do RICHTIG for Variable in Satz do Befehl1 Befehl2 Beispiel
113. t nul F errorlevel EQU O GOTO W81 VER find Microsoft Windows Version 5 gt nul F errorlevel EQU O GOTO 2003 goto unknown goto end unknown echo unknown goto end 95 echo 95 goto end 98 echo 98 goto end ME echo ME goto end NT echo NT goto end 2 http www administrator de contentid 56044 72 NET 2000 echo 2000 goto end XP echo XP goto end Vista echo Vista goto end W7 echo W7 goto end W8 echo W8 goto end W81 echo Windows 8 1 goto end 2003 echo 2003 goto end end 8 0 19 TEMP Verzeichnis l schen Im TEMP Verzeichnis sammeln sich mit der Zeit viele Dateien und Unterverzeichnisse an Mit diesem Skript werden alle auf einmal gel scht echo off call clean TEMP IF NOT TEMP IMP call clean TMP pause goto eof clean del q Y 1 FOR D D IN 1 DO rmdir s q D goto eof Wahrscheinlich erh lt man ein paar Fehler wenn z B Dateien ge ffnet sind Neue Version Eine Version f r Win XP 2000 WinVista Win7 Echo off del f s q HOMEPATH ALokale Einstellungen Temp del f s q HOMEPATH ALokale Einstellungen Temporary Internet Files del f s q HOMEPATH Lokale Einstellungen Verlauf del s q windir Temp del s q Awindir Prefetch del s q hwindir ATempY x rmdir s q HOMEPATH Lokale Einstellungen Temp rmdir s q windir Pr
114. t or to implement a Standard Interface for which an implementation is available to the public in source code form A Ma jor Component in this context means a major essential component kernel window system and so on of the specific operating system if any on which the executable work runs or a compiler used to produce the work or an object code interpreter used to run it The Corresponding Source for a work in object code form means all the source code needed to generate install and for an executable work run the object code and to modify the work including scripts to control those activities However it does not include the work s System Libraries or general purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work For example Corresponding Source includes in terface definition fil sociated with source files for the work and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require such as by intimate data communication or control flow between those subprograms and other parts of the work The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Sour ce for a work in source code form is that same The Corresponding Sourc work 2 Basic Permissions All right
115. t wird sie mit edit gedffnet sonst wird das Unterprogramm bersprungen und die Batchdatei bei der Marke END fortgesetzt also beendet Seit die Befehlserweiterungen aktiviert sind steht in Batchdateien die Sprungmarke EOF zur Verf gung welche sich unsichtbar am Ende der Batch Datei befindet 3 6 doppelter Doppelpunkt Syntax e Windows 2000 XP KOMMENTAR Erkl rung Der kann zur Einleitung eines Kommentars verwendet werden ist aber eigentlich ein Spezialfall der Verwendung vom Doppelpunkt Label Eine ausf hrliche Erkl rung zu Kommentaren findet sich beim Befehl REM Beispiel Inhalt der Batchdatei echo Ich bin ein Kommentar echo Ich bin ein Befehl Ausgabe der Batchdatei Microsoft Windows XP Version 5 1 2600 C Copyright 1985 2001 Microsoft Corp C gt echo Ich bin ein Befehl T 8 Kapitel 3 1 auf Seite 15 Kapitel 3 25 auf Seite 31 17 Batch Befehle 18 Ich bin ein Befehl Die Zeile Ich bin ein Kommentar bleibt bei der Ausf hrung unber cksichtigt 3 7 CALL Mit call kann man eine andere Batch Datei aufrufen Sobald diese beendet wurde wird die urspr ngliche Batchdatei weiter ausgef hrt Beispiel REM Call cmd echo off echo Diese Batchdatei ruft eine andere auf call anderedatei bat pause REM anderedatei bat echo off echo Die andere Datei Die Ausgabe wenn man die Datei Call cmd startet Diese Batchdatei ruft eine andere auf Die andere Datei Pau
116. t auf Computer COMPUTERNAME echo Sch nen Tag noch Beachten Sie bei der Pr fung von Umgebungsvariablen niemals IF Umgebungsvariable Pr fwert zu schreiben wenn die Umgebungsvariable nicht gesetzt ist Sie erhalten sonst einen Syn taxfehler Der Parameter i unterbindet eine Differenzierung der Gro Kleinbuchstaben ACHTUNG Bei der Verwendung mehrerer Befehle muss zwischen Bedingung und der Klammer ein Leerzeichen sein Falsch IF Bedingung Richtig IF Bedingung Befehl1 Befehl2 3 20 1 Syntaxvergleiche IF lt NOT gt Variablei Variable2 IF Variable EQU Variable2 Befehl An die Stelle von EQU kann jede der Optio nen gesetzt werden NOT Der Befehl wird nur ausgef hrt wenn die Bedingung NICHT Wahr ist Optional ist gleich EQU ist gleich NEQ nicht gleich LSS kleiner als LEQ kleiner als oder gleich GTR gr er als GEQ gr er als oder gleich 28 IF 3 20 2 Hinweis zu UND bzw ODER Verkniipfung Eine UND bzw ODER Verkniipfung von zwei Bedingungen scheint nicht direkt m glich zu sein Beim Vergleichen von Strings hilft es aber eventuell wenn man die beiden Strings miteinander verkettet Beispiel set A true set B false if A B true true echo A und B sind beide TRUE else echo entweder A oder B ist nicht TRUE Als Workaround k nnen mehrere aufeinanderfolgende IFs zu einer UND bzw ODER Verkn
117. t echo Nummer 1 Nummer 1 C gt echo Nummer 2 Nummer 2 C gt echo Nummer 3 Nummer 3 C gt for L N IN 1 1 4 DO echo Nummer N C gt echo Nummer 1 Nummer 1 25 Batch Befehle C gt echo Nummer 2 C gt echo Nummer 3 C gt echo Nummer 4 C gt for C gt echo Nummer 1 C gt echo Nummer 2 C gt echo Nummer 3 C gt echo Nummer 4 C gt echo Nummer 5 Nummer 2 Nummer 3 Nummer 4 L YAN IN 1 1 5 DO echo Nummer N Nummer 1 Nummer 2 Nummer 3 Nummer 4 Nummer 5 Weitere M glichkeiten der FOR Schleife syntax FOR Files FOR parameter IN set DO command syntax FOR Files Rooted at Path FOR R drive path parameter IN set DO command syntax FOR Folders FOR D parameter IN folder_set DO command syntax FOR List of numbers FOR L parameter IN start step end DO command syntax FOR File contents FOR F options parameter IN filenameset DO command FOR F options parameter IN Text string to process DO command syntax FOR Command Results FOR F options parameter IN command to process DO command 26 GOTO Beispiel Sucht im Ordner C Windows Temp rekursiv nach Dateien mit dem Namen temp dat und gibt die Liste aus Die Option token ist notwendig damit die Aus gabe zeilenweise gelesen wird und auch Pfade mit enthaltenem Leerzeichen
118. t einem anderen komfortableren Editor bearbeiten der z B Syntaxhervorhebung Syntaxhighlighting beherrscht Um einen anderen Editor z B Syn zu verwenden muss man in der Registry an der Stelle HKEY_CLASSES_ROOT batfile shell edit command den Standard Wert Standard SystemRoot System32 NOTEPAD EXE 1 auf den Startbefehl des entsprechenden Editors ndern Z B HKEY_CLASSES_ROOT batfile shell edit command Standard c Programme Editor syn syn exe 1 6 0 4 Datum und Uhrzeit anzeigen F r Log Dateien ist es wichtig dass man die Logeintr ge mit Datum und Uhrzeit versehen kann echo date 0 time 0 8 Uhr Ergebnis 11 09 2010 15 59 53 Uhr Hierbei steht 0 8 f r die Angabe der Stellen Mit 0 8 wird angegeben dass die Ausgabe der Zeit bei Position 0 beginnen soll und insgesamt 8 Stellen beinhalten soll Die maximale Stellenanzahl ist 11 0 11 Wobei man beachten muss dass echo time vor 10 Uhr eine Zeit ohne f hrende Null liefert Stattdessen erh lt man ein Leerzeichen was bei einem sortiergerechten Zeitstempel zu Problemen f hren kann Die If Bedingung pr ft in der Variablen sorttime ob das erste Zeichen ein Leerzeichen ist Ist das vor 10 Uhr morgens der Fall wird das Leerzeichen durch eine 0 ersetzt set SORTTIME time 0 2 time 3 2 time 6 2 if SORTTIME 70 1 set SORTTIME 0 SORTTIME 1 6 1 http syn sourceforge net 47 Programmierungshilfen Beim D
119. t for their work while not being considered responsible for modifications made by othe This License is a kind of copyleft which means that derivative works of the document must themselves be free in the same sense It com plements the GNU General Public License which is a copyleft license designed for free software it for manuals for free umentation a free pro gram should come with manuals providing the same freedoms that the software does But this License is not limited to software manuals it can be used for any textual work regardless of subject matter or whether it is published as a printed book We recommend this Licen se principally for works whose purpose is instruction or reference 1 APPLICABILITY AND DEFINITIONS We have designed this License in order to us software because free software needs free do This License applies to any manual or other work in any medium that contains a notice placed by the copyright holder sayi be distributed under the terms of this License Such a notic world wide royalty free license unlimited in duration to use that work under the conditions stated herein The Document below refers to any such manual or work Any member of the public is a licensee and addressed as you You accept the license if you copy modify or ribute the work in a way requiring permission under copyright law dis A Modified Version f the Document means any wor
120. t this Lic a copy of the Program Ancillary propagation of a curring solely as a consequence of using peer to pe ive a copy likewise does not require acceptance However nothing other than this License grants you permission to propagate or modify any covered work These actions infringe copyright if you do not accept this License Therefore by modifying or propagating a covered work you indicate your acceptance of this License to do so 10 Automatic Licensing of Downstream Recipients covered work oc transmission to Each time you convey a covered work the recipient automatically r ceives a license from the original licensors to run modify and propa gate that work subject to this License You are not responsible for enforcing compliance by third parties with this License An entity transaction is a transaction transferring control of an or ganization or substantially all assets of one or subdividing an orga nization or merging organizations If propagation of a covered work results from an entity transaction each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party s predecessor in interest had or could give under the previous paragraph plus a right to possession of the Corresponding Source of the work from the predecessor in interest if the predecessor has it or can get it with reasonable efforts You may not impos
121. t use the GNU GPL protect your rights with two steps 1 assert copyright on the software and 2 offer you this License giving you legal permission to copy distribute and or modify it For the developers and authors protection the GPL clearly explains that there is no warranty for this free software For both users and authors sake the GPL requires that modified versions be marked as changed so that their problems will not be attributed erroneously to authors of previous versions Some devices are designed to deny users access to install or run mo dified versions of the software inside them although the manufacturer can do so This is fundamentally incompatible with the aim of protec ting users freedom to change the software The systematic pattern of such abuse occurs in the area of products for individuals to use which igned this version of the GPL to prohibit the practice for those products If such problems arise substantially in other domains we stand ready to extend this provision to those domains in future versions of the GPL as needed to protect the freedom of users is precisely where it is most unacceptable Therefore we have di Finally every program is threatened constantly by software patents States should not allow patents to restrict development and use of soft ware on general purpose computers but in those that do we wish to avoid the special danger that patents applied to a free
122. te Skriptsprachen In diesem Buch geht es primar um das Erstellen von Batchdateien Skripten fiir den Micro soft Windows Kommandozeileninterpreter cmd exe fiir Windows XP Vista 7 Informa tionen zu Batchdateien unter DOS und auf DOS basierenden Windowsversionen wie z B Windows 98 werden teilweise miterl utert Unterschiede zur Verwendung der Befehle in den unterschiedlichen Windowsversionen werden unter der jeweiligen Befehlsbeschreibung erl utert Andere Betriebssysteme bieten vergleichbare und teilweise wesentlich m chtigere Funktio nen wie z B die in der Linux Welt weit verbreitete Bash oder AppleScript fiir den Mac Auch fiir Windows gibt es M glichkeiten m chtigere Skripte zu erstellen hierzu kann der Windows Script Host oder das Windows PowerShell verwendet werden 1 2 Was sind und wie funktionieren Batchprogramme Batchdateien oder Batchprogramme haufig mit Stapelverarbeitungsprogramme oder kurz Stapelprogramm bersetzt sind meist kurze Dateien die Befehle der Kommandozeile der Reihe nach abarbeiten Batchprogrammierung erf llte die grundlegenden Anforderungen an eine Programmiersprache wie z B if if not und while Da Batch sich in den Be reich Shellscripting einordnen l sst kann man von einer interpreterbasierten Skriptsprache reden Das hei t dass die im Editor erstellte Textdatei nicht mit einem Compiler ein mal in Maschinensprache bersetzt und in einer ausf hrbaren Bin rdatei im exe Format ges
123. the use of http www 7 zip org The KIEX source itself was generated by a program written by Dirk Hiinniger which is freely available under an open source license from http de wikibooks org wiki Benutzer Dirk_Huenniger wb2pdf Inhaltsverzeichnis 1 Allgemeine Information In diesem Buch behandelte und nicht behandelte Skriptsprachen Was sind und wie funktionieren Batchprogramme Nutzung von Batchprogrammen 0 000002 ee eee Wie erstelle ich eine Batchdatei 0 nn Weiterf hrende Informationen und Links 2 1 1 1 2 1 3 1 4 1 5 Wichtige DOS Kommandos 2 1 2 2 2 3 2 4 2 5 2 6 2 7 2 8 2 9 2 10 2 11 2 12 2 13 2 14 2 15 2 16 2 17 2 18 2 19 2 20 2 21 2 22 2 23 cacls 9 SS a E aa se A N comp oder TE ataa A UA A Aa BOCODY TODOCODE eri a e e A a ir dE os tee A a Sid en A A Bere de deltree dir format loadhigh tra is ge ae Ran ae Bee e dc SG ee O md PIKE Arco Ayes os Bre Gala Ge AT Gide Ao Ny Bia Gee bd path ray PO de ma Ee Whe OR le AE EO Ge Peo ren Oder TEAM oos ee 2 0 Fh are a an had hoe Tate Bh WB et ak be a A start taskkill tasklist type Batch Befehle Wichtiger Hinweis zu diesem Abschnitt 2 222 2 En nennen 3 1 3 2 3 3 3 4 3 5 3 6 3 7 a V A sr fezeichen ight dod tei bk ee ee Sade Be el a Doppelpunkt e essa o a e doppelter Doppelpunkt e is Ad een CALL PP RWW Ww
124. u received it does not specify a version number of the GNU Lesser General Public License you may choose any version of the GNU Lesser General Public License ever published by the Free Software Foundation If the Library as you received it specifies that a proxy can decide whe ther future versions of the GNU Lesser General Public License shall apply that proxy s public statement of acceptance of any version is permanent authorization for you to choose that version for the Library
125. und Systemvariablen Die Script variablen werden innerhalb von Schleifen eingesetzt beginnen mit und einem frei w hl baren Zeichen oder einer Zeichenfolge Systemvariablen m ssen von begonnen und von abgeschlossen werden Sie sind fest definiert Die Variable 0 hat stets den Namen der aktuellen Datei Die Variable ver hat immer den Namen der aktuellen Betriebs systemversion Unter Windows XP muss os statt ver verwendet werden Gibt man unter Windows Vista und 7 den Befehl echo os ein so gibt der Computer die Version des Systems aus auf dem das System basiert Unter Windows Vista und Windows 7 gibt es einen Befehl namens ver mit dem man die Version direkt angezeigt bekommt Es gibt zwar keine direkte Variable bei Vista und Windows 7 die das Betriebssystem definiert jedoch kann man das mit folgendem Trick umgehen echo off Autobefehlsanzeige ausgeschaltet ver gt TMP dat speichert die Ausgabe des Befehls in der Datei TMP dat Set p ver lt TMP dat definiert die Variable des Betriebssystems NUR TEMPOR R echo ver gibt nun die definierte Variable aus pause gt nul pause 5 1 3 Benutzereingaben in Variablen speichern Um eine Benutzereingabe in eine Variable speichern zu k nnen wird die Option p be notigt Beispiel set p EINGABE Variable Eingeben echo EINGABE 5 1 4 Zeichenketten in Variablen manipulieren Stringoperationen Niitzliche Stringoperation fiir String Variablen Tei
126. ung von Zusatz tools f r Batch Skripter e http www axel hahn de axel page_compi bat_index htm Viele weitere Infor mationen und Tools zum Thema e http www script example com themen Windows_Batch php Batch Dateien er stellen f r absolute Beginner http publibz boulder ibm com cgi bin bookmgr _0S390 BOOKS IEA2B510 CCONTENTS SHELF TEA2BK32 amp DN SA22 7598 01 amp DT 20010626133938 81 WebLinks 11 3 Tutorials Batch for Runaways Part 1 Tutorial Batch I Batch for Runaways Part II Tutorial Batch II Batch for Runaways Part III Tutorial Batch III Tutorials auf Administrator de e Die For Schleife Tutorial FOR e Variablen Tutorial Umgebungsvariablen 11 4 Bticher e Windows Command Line Administrator s Pocket Consultant 2nd Edition Amazon Link e Wikibooks eng Windows Batch Scripting 11 5 Referenzen Referenzen erlauben einen Uberblick iiber vorhandene Befehle Prim r fiir erfahrene An wender sind sie im Regelfall sehr kompakt enthalten aber oftmals ausf hrliche Erkl run gen als Verlinkung mit einem einzelnen Befehl e Microsoft Technet Windows Vista Command Line Tools Technical Reference en e Microsoft Technet Windows XP Command line reference A Z en e Microsoft Product Documentation Windows XP Professional Product Documenta tion e Microsoft Technet Windows Server 2003 Befehlszeilenreferenz de e Microsoft Technet Windows Server 2008 Command
127. usgef hrt BefehlOutput kann nun beliebig gebraucht werden Beispiel Code echo off FOR F i IN CD DO set verzeichnis i echo verzeichnis Ausgabe C Programme Batch Vorsicht ist geboten bei Befehlen welche mehrzeilige Ausgaben produzieren und bei sol chen welche in ihrer Ausgabe auch Leerzeichen enthalten k nnen Da das Standard trennzeichen ein Blank ist muss man wenn man nicht will dass die Variable nur bis zum Blank gef llt wird das Standardtrennzeichen ver ndern FOR F delims i IN CD DO set verzeichnis 4i entfernt jede Art von Trennzeichen Bei Befeh len welche mehrzeilige Ausgaben zur Folge haben bleibt jeweils die letzte Zeile in der Variablen erhalten 6 0 9 Dateien und Verzeichnisse auflisten Hier ist ein Beispiel in dem alle Dateien auf welche die Filterbedingung zutrifft aufge listet werden Au erdem werden die Dateianzahl und die Dateigr en addiert echo off set Filter set A DateiAnzah1 0 set bytes 0 for R pfad f in YFilter do set A DateiAnzahl 1 echo h hh zfBytes set A bytes bytes zf echo Ein und Ausgaben in Variablen speichern set p echo dpO Filter echo Es sind DateiAnzahl Dateien vorhanden echo Alle Dateien zusammen bytes Bytes set A kbytes bytes 1024 echo umgerechnet sind das kbytes KBytes echo pause 6 0 10 Pause Oft ist es hilfreich dass nach dem Beenden des Batch Programms das Eingabeaufforde
128. uweisen Syntax set p variablenname Angezeigter Text Beispiel echo off set var set p var Eingabe echo Sie haben var eingegeben pause Ausgabe Eingabe Test Sie haben Test eingegeben Pause Wichtig Gibt der Benutzer nichts ein so bleibt die Umgebungsvariable unver ndert Also immer initialisieren Priifung ob der Benutzer Text eingegeben hat echo off set var set p var Eingabe if not defined var echo Bitte geben Sie etwas ein set var nichts REM K nnte auch was ganz anderes sein echo Sie haben var eingegeben pause Ausgabe Eingabe leer Bitte geben Sie etwas ein Sie haben nichts eingegeben pause 5 8 2 Umgeleitete Ausgaben Eine M glichkeit der Umleitung einer Ausgabe besteht ber den set p Befehl Syntax ECHO Befehl gt Dateiname SET P Variablenname lt Dateiname Beispiel ECHO OFF ECHO date gt _ txt SET P tmp lt _ txt ECHO Das Datum heute ist tmp 45 6 Programmierungshilfen 6 0 3 Andern des Editors zum Bearbeiten von Batchdateien Wenn man im Windows Explorer mit der Rechten Maus Taste RMT auf eine bat klickt so werden einem die Befehle Offnen und Bearbeiten angeboten ffnen f hrt die Batchdatei aus Mit dem Befehl Bearbeiten wird die Batchdatei in den Texteditor notepad exe zum Bearbeiten ge ffnet Auch wenn Notpad zum Bearbeiten von Batchdateien ausreicht so m chte man h ufig doch die Batchdateien mi
129. ver gt TEMP_FILE REM Neuen Eintrag wieder hinzuf gen for F tokens 15 i in ipconfig find IP Ad do set IP i echo IP HOST_ALIAS gt gt TEMP_FILEY 71 Beispiele echo Added IP HOST_ALIAS to the hostsfile REM Temp File nach SystemRoot System32 drivers etc hosts kopieren REM Die Datei Hosts darf nicht mit move verschoben werde sondern muss kopiert werden da sonst der Hostname nicht gefunden werden kann copy y TEMP_FILE HOST_FILEY del F Q TEMP_FILE 8 0 18 Windowsversion herausfinden Mit dieser Batchdatei findet man heraus welche Windowsversion verwendet wird Das ist n tzlich wenn man mit bestimmten Pfaden arbeitet die je nach Betriebssystem ver schieden sind Quelle echo off rem diese Batch prueft das 0S VER find i Windows 95 gt NUL NOT ERRORLEVEL 1 GOTO 95 VER find i Windows 98 gt NUL F NOT ERRORLEVEL 1 GOTO 98 VER find i Windows Millennium gt NUL F NOT ERRORLEVEL 1 GOTO ME VER find XP gt nul F errorlevel EQU O GOTO XP VER find 2000 gt nul F Zerrorlevel EQU O GOTO 2000 VER find NT gt nul F Zerrorlevel EQU O GOTO NT Tj VER find Microsoft Windows Version 6 0 gt nul F Zerrorlevely EQU O GOTO Vista VER find Microsoft Windows Version 6 1 gt nul F errorlevel EQU O GOTO W7 VER find Microsoft Windows Version 6 2 gt nul F errorlevel EQU O GOTO W8 VER find Microsoft Windows Version 6 3 g
130. ves to suit the s tuation If your document contains nontrivial examples of program code we r commend releasing these examples in parallel under your choice of free software license such as the GNU General Public License to permit their use in free software 13 3 GNU Lesser General Public License GNU LESSER GENERAL PUBLIC LICENSE Version 3 29 June 2007 Copyright 2007 Free Software Foundation Inc lt http fsf org gt Everyone is permitted to copy and distribute verbatim c license document but changing it is not allowed pies of this This version of the GNU Lesser General Public License incorpora tes the terms and conditions of version 3 of the GNU General Public supplemented by the additional permissions listed below 0 Additional Definitions As used herein this License refers to version 3 of the GNU Lesser General Public License and the GNU GPL refers to version 3 of the GNU General Public License The Library refers to a covered work governed by this Lic than an Application or a Combined Work as defined below nse other An Application is any work that makes use of an interface provided by the Library but which is not otherwise based on the Library Defi ning a subclass of a class defined by the Library is deemed a mode of using an interface provided by the Library A Combined Work is a work produced by combining or linking an Application
131. vom Bediener erwarten durch die Umleitung wird diese Zeile von der Datei tmp txt gelesen die zuvor mittels Umleitung der Ausgabe siehe unten bef llt wurde 4 6 gt Umleitung der Standard Ausgabe zu einem anderen Ziel Wenn das Ziel eine Datei ist wird diese neu angelegt falls die Datei schon existiert wird sie zuvor gel scht Es kann aber auch nach NUL Die Ausgabe verschwindet oder CON Bildschirm umgeleitet werden Syntax befehl gt file oder auch mit vorrangestellter Umleitung praktisch wenn bei der Ausgabe einzelne vorkommen gt file befehl Beispiel Inhalt gt gt echo Hallo gt tmp txt type tmp txt Ausgabe Hallo Neben der Standard Ausgabe stdout gibt es noch eine Fehlerausgabe stderr Norma lerweise landen die Standard Ausgabe und die Fehler Ausgabe am Bildschirm wodurch der Unterschied nicht auff llt Wenn die Standard Ausgabe auf eine Datei umgelenkt wird landen Fehlerausgaben immer noch auf dem Bildschirm was oft erw nscht ist Falls nicht kann auch die Fehler Ausgabe in eine Datei umgeleitet werden und zwar mit 2 gt Beispiel dir gt stdout txt 2 gt stderror txt Schreibt den Output des dir Befehles in die Datei stdout tat da kein Fehler aufgetreten ist dir DieseDateiExistiertNicht txt gt stdout txt 2 gt stderror txt Schreibt die Fehlermeldung des dir Befehles in die Datei stderror txt da die Datei Die seDateiEristiertNicht trt nicht existiert uns somit ein Fehle
132. with the Library The particular version of the Library with which the Combined Work was made is also called the Linked Version The Minimal Corresponding Source for a Combined Work means the Corresponding Source for the Combined Work excluding any source code for portions of the Combined Work that considered in isolation are based on the Application and not on the Linked Version The Corresponding Application Code for a Combined Work means the object code and or source code for the Application including any data and utility programs needed for reproducing the Combined Work from the Application but excluding the System Libraries of the Com bined Work 1 Exception to Section 3 of the GNU GPL You may convey a covered work under sections 3 and 4 of this Licen se without being bound by section 3 of the GNU GPL 2 Conveying Modified Versions If you modify a copy of the Library and in your modifications a faci lity refers to a function or data to be supplied by an Application that uses the facility other than as an argument passed when the facility is invoked then you may convey a copy of the modified vers ion a under this License provided that you make a good faith effort to ensure that in the event an Application does not supply the function or data the facility still operates and performs whatever part of its purpose remains meaningful or b under the GNU GPL with none of the additional
133. ww administrator de forum test cmd parameter 76928 html e http ss64 com nt syntax args html Erkl rung Verwendung Beispiele Mit Hilfe von Parametern beim Aufrufen einer Batchdatei z B c gt batchskript cmd paramteri paramter2 Zeichenketten als eine Art Variablen bergeben werden die dann in der Batchdatei weiterverwendet werden k nnen Unter Windows NT lassen sich die Parameter im Gegensatz zu DOS folgenderma en erweitern f r 1 setze man den jeweiligen Parameter ein o AOUN A http de wikibooks org wiki Batch Programmierung __Programmierungshilfen Probleme_ mit_Variablen http ss64 com nt syntax variables html http best windows vlaurie com environment variables html http de wikipedia org wiki Umgebungsvariable http www microsoft com resources documentation windows xp all proddocs en us percent mspx mfr true 42 Stringoperationen Manipulation von Strings in Variablen 1 Anfiihrungszeichen werden entfernt 1 vollst ndige Pfadbezeichnung di Laufwerkbuchstabe pi Pfad ohne Laufwerksbuchstabe n1l Dateiname x1 Dateinamenserweiterung si Pfad nur mit kurzen Verzeichnis Dateinamen http de wikipedia org wiki 8 3 8 3 Konvention al Dateiattribute ti Datums und Uhrzeitangaben der Datei Ge ndert am zi Gr e der Datei Die Angaben k nnen auch kombiniert werden z B dpO ist Laufwerksbuchstaben Pfad der aktuellen Batchdatei 5 5 2 Parameterv
134. x if errorlevel EQU 2 echo Fehler bereinigt else echo Errorlevel errorlevel echo goto eof echo defrag 1 f defrag 1 f if errorlevel NEQ O pause exit rem pause ping localhost n 1 gt NUL goto eof check set ok nein net use find i 1 gt NUL if not errorlevel 1 echo 1 ist ein Netzlaufwerk goto eof fsutil dirty query 1 for F tokens 5 in fsutil dirty query 1 do if not f NICHT rem Laufwerk ist als fehlerhaft markiert goto eof set ok ja goto eof Als Alternative gibt es das Open Source Program JkDefrag welches auch alle Laufwerke nacheinander defragmentiert 8 0 15 Dateiinformationen anzeigen Dieses Batch Skript zeigt Informationen ber die Datei die als Parameter bergeben wird an beispielsweise per Drag amp Drop auf die Batch Datei 1 http www kessels com JkDefrag 70 NET echo off echo Attribute Wal echo Laufwerk dl echo kompletter Pfad f1 echo Dateiname 4 nt echo Ordnerpfad pl echo kompletter Pfad kurze Form s1 echo Aenderungsdatum t1 echo Dateierweiterung x1 echo Dateigroesse 4 21 pause Hinweis Falls die Attribute des eigenen Batch Skripts ausgelesen werden sollen so muss der Parameter Null verwendet werden Beispielsweise p0 Eine Kombination ist auch
135. y not propagate or modify a covered work except as expressly provided under this License Any attempt otherwise to propagate or modify it is void and will automatically terminate your rights under this License including any patent licenses granted under the third paragraph of section 11 However if you cease all violation of this License then your license from a particular copyright holder is reinstated a provisionally un less and until the copyright holder explicitly and finally terminates your license and b permanently if the copyright holder fails to no tify you of the violation by some reasonable means prior to 60 day after the cessation Moreover your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means this is the first time you have received notice of violation of this License for any work from that copyright holder and you cure the violation prior to 30 days after your receipt of the notice Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License If your rights have been terminated and not permanently reinstated you do not qualify to receive new licenses for the same ma terial under section 10 9 Acceptance Not Required for Having Copie You ar nse in order to receive or run e not required to accep
136. zeigt 2000 XP Net User lt name gt lt passwort gt add Dieser Befehl f gt einen Benutzer hinzu 2000 XP Net User lt name gt delete 60 Und dieser Befehl wiederum l scht einen Benutzer 2000 XP NET Net User lt name gt lt passwort gt Dieser Befehl ver ndert das Passwort des Benutzers Wenn anstatt des passworts ein Stern angegeben wird dann wird das neue Passwort abgefragt 2000 XP Net User lt name gt expires never Damit wird eingestellt dass dass Passwort des Benutzers lt name gt niemals ablauft 2000 XP Net User lt name gt active Yes Net User lt name gt active No Damit wird das entsprechende Benutzerkonto aktiviert oder deaktiviert 2000 XP Net User lt name gt passwordchg Yes Net User lt name gt passwordchg No Damit wird eingestellt ob der Benutzer sein eigenes Passwort ver ndern darf 2000 XP Net User lt name gt comment Herr Maier vom Verkauf Damit wird der Benutzerkommentar ver ndert 2000 XP Net User lt name gt Fullname Karl Otto Maier M ller Damit wird der komplette Benutzername ver ndert 2000 XP Net User lt name gt expires 2009 12 31 Damit wird eine Zeit vorgegeben nach der der Benutzer sein Password ndern muss 2000 XP Net User lt name gt profilepath D Maier Net User lt name gt s
137. zu Achtung Standardm ig werden Rechte ersetzt 2 4 cd chdir ber den cd oder chdir Befehl change directory kann das aktuelle Verzeichnis gewechselt werden Beachte Nach dem cd folgt ein Leerzeichen das bei nachfolgendem oder je nach Betriebssystemversion weggelassen werden darf Wird der Befehl ohne Parameter 1 http de wikibooks org wiki FreeDOS Kompendium 3A 20Befehle Wichtige DOS Kommandos ausgef hrt so wird der Pfad des aktuellen Verzeichnisses ausgegeben relative Angaben Die Eingabe von cd wechselt in das n chsth here Verzeichnis cd zwei Ebenen h her usw Die Eingabe von cd ORDNERNAME wechselt in den Unterordner ORDNERNAME absolute Angaben Die Eingabe von cd 1 wechselt in das Hauptverzeichnis auf dem derzeitig befindlichen Laufwerk Die Eingabe von cd ORDNERNAME wechselt absolut in den Ordner ORDNERNAME auf dem derzeitig befindlichen Laufwerk Die Eingabe von LAUFWERKSBUCHSTABE ohne vorangestelltes cd wechselt in das aktuelle Verzeichnis des gew hlten Laufwerks LAUFWERKSBUCHSTABE Die Eingabe von cd LAUFWERKSBUCHSTABE ORDNERNAME wechselt absolut in den Ordner ORDNERNAME auf dem gew hlten Laufwerk von LAUFWERKSBUCHSTA BE jedoch nicht von einem Laufwerk auf ein anderes Pfadangaben mit Leerschl gen Bsp C program files m ssen in Anf hrungs Schlusszeichen eingeschlossen sein Der Befehl cd D dp0 wechselt in den Ordner des Batch

Download Pdf Manuals

image

Related Search

Related Contents

PDFファイル    6655 IM Oster Blender  ISTRUZIONI PER L`INSTALLAZIONE, L`USO E LA  Package Insert - Sekisui Diagnostics  P3500 OPERATING INSTRUCTION MANUAL  Manual - sarte audio  有価証券報告書 - マースエンジニアリング  Introduction - École française de Rome  Kwikset 488DL 26 Installation Guide  

Copyright © All rights reserved.
Failed to retrieve file