Friday 10 November 2017

Batch Echo Binär Optionen


Hallo, ich versuche, eine Binärdatei innerhalb eines grundlegenden Batch-Skripts zu speichern, das ive geschrieben hat. Grundsätzlich möchte ich, dass das Skript in der Lage ist, diese vordefinierte Datei irgendwann auszugeben, anstatt sie von Grund auf neu zu erstellen. Wenn dies nicht möglich ist, dann müsste ich diese Datei separat mit der Batch-Datei, die dann verschieben würde es in den notwendigen Ort, aber Id eher diese Datei unsichtbar für den Benutzer, so dass es scheint, dass die Datei wird von innen generiert werden Die Charge. So ist das möglich und wenn ja, wie Vielen Dank im Voraus. Fragte am 24. Oktober um 20: 10WinSCP Free SFTP, SCP und FTP Client für Windows Wenn keine Parameter angegeben sind, werden alle Skriptoptionen und deren Werte aufgelistet. Wenn nur ein Parameter angegeben ist, wird der Wert der Option angezeigt. Wenn zwei Parameter angegeben sind, wird der Wert der Option gesetzt. Die unten aufgeführten Standardwerte sind Standardwerte für die Anwendung. Die Anfangswerte einiger Optionen können unterschiedlich sein, wenn Sie die Konfiguration mit dem grafischen Modus teilen. Werte und Beschreibung offon Schaltet das Echo des Befehls aus. Betroffene Kommandos: alle Default: off offonabortcontinue Aktiviert den Batch-Modus. Im Batch-Modus wird jede Auswahlaufforderung automatisch geantwortet und jede Eingabeaufforderung wird abgebrochen (nach kurzem Zeitintervall). Im Batch-Modus empfiehlt es sich, die Bestätigung zu deaktivieren, um Überschreibungen zu ermöglichen. Wenn der Batch-Modus auf eine beliebige Auswahl eingestellt ist, wird automatisch die Antwort aufgefordert. Es sei denn, die Eingabeaufforderung hat eine andere Standardantwort (z. B. eine Voreinstellung 8220Reconnect8221 Antwort für eine Wiederverbindungsaufforderung), in welchem ​​Fall die Standardantwort verwendet wird (nach einem kurzen Zeitintervall). Siehe auch eine Reconnecttime-Option unten. Wertabbruch ist wie auf. Darüber hinaus wird das Skript abgebrochen, wenn ein Skriptbefehl fehlschlägt oder eine beliebige Auswahlaufforderung mit 8220Abort8221 Antwort (oder ähnlich) beantwortet wird. Wenn gesetzt, um fortzufahren, wird jede Wahlaufforderung automatisch mit 8220Skip8221, 8220Ignore8221 oder einer ähnlichen Antwort beantwortet. Durch Aktivieren des Batch-Modus wird die Wiederherstellungszeit (Wiedereinschaltzeit-Option unten) auf 120 Sekunden eingestellt, falls sie noch nicht gesetzt ist. Befehle betroffen: fast alle Standard: Abbruch für Befehle, die mit Skript oder Befehl aus für Befehle angegeben werden, die bei der Eingabe angegeben sind. Offon Toggles Bestätigungen (überschreiben, etc.). Befehle betroffen: get. Put Default: off für Befehle, die mit Skript oder Befehl auf für Befehle angegeben werden, die bei der Eingabe angegeben sind. Off ltsecgt Setzt die Zeitbegrenzung in Sekunden, um die Wiederherstellung von gebrochenen Sitzungen zu versuchen. Value off entfernt eine zeitliche Begrenzung. Die Reconnect-Zeit wird implizit auf 120 Sekunden eingestellt, wenn der Batch-Modus (Batch-Option oben) aktiviert ist. Befehle betroffen: get. stellen. synchronisieren. Keepuptodate Default: off offon Schaltet aus, ob Befehle fehlschlagen, wenn ein Platzhalter, der zum Auswählen von Dateien für eine Operation verwendet wird, keine Dateien enthält. Befehle betroffen: get. stellen. Rm Mv Chmod Ls Ls Beachten Sie, dass die Option keinen Einfluss auf - filemask-Schalter von get und put-Befehle hat. Default: off Beachten Sie, dass das Zurücksetzen der gleichen Option einen vorherigen Wert überschreibt, wird es nicht angehängt. Batchdatei. ECHO-Befehl Wenn eine Batchdatei ausgeführt wird, wenn das Echo eingeschaltet ist, würde es den Befehl aktuell it8217s auf die Eingabeaufforderung ausführen. Standardmäßig ist das Echo für jede Batchdatei aktiviert. Wir können das Echo ausschalten, indem wir die folgende Zeile am Anfang der Datei einfügen. Befehl zum Einschalten des Echos: Wir können das Echo an einem beliebigen Punkt in einer Batchdatei einschalten oder ausschalten. Zum Beispiel können Sie Echo für bestimmte Befehle in der Batch-Datei sein, und dann können Sie es ausschalten, und dann wieder können Sie es einschalten. Gleichfalls. Ich habe die folgende Batch-Datei namens echoExample. bat: Jetzt, wenn ich die Batch-Datei ausführen, sehe ich die unten stehende Ausgabe. In der Batchdatei haben wir den Befehl 4816date8217 4 mal ausgeführt. Aber der Befehl wird nur zweimal in der Ausgabe wiedergegeben. Sie können feststellen, dass für das 2. und 4. Mal, wenn Echo ausgeschaltet ist, es nicht den Befehl in der Ausgabe widerhallt. So deaktiviere ich das Echo in der Eingabeaufforderung. Die obigen Arbeiten für Batch-Datei. Aber ich möchte es deaktivieren, wenn ich Kommandos in cmd ausführe. Um das Echo in der Eingabeaufforderung zu deaktivieren, verwenden Sie 8220echo.8221 (ECHO gefolgt von einer Periode). C: gtecho. Der Befehl ECHO erscheint nicht Es gibt keinen Speicherplatz nach dem Zeitraum. Windows Batch Scripting Dieses Buch behandelt 32-Bit-Windows-Befehle für moderne Versionen von Windows auf der Windows NT-Umgebung. Es handelt sich nicht um Befehle, die für DOS-Umgebungen spezifisch sind, und auf DOS-basierte Betriebssysteme wie Windows 95, Windows 98 und Windows Me, deren Microsoft-Befehlsdolmetscher tatsächlich DOS-Programme sind, nicht Win32-Programme. Sie können herausfinden, welche Version von cmd. exe Sie mit dem Befehl VER betreiben. Dieses Buch beschreibt zunächst die Verwendung des Windows NT-Befehls-Interpreters, wie es empfängt, analysiert und verarbeitet Befehle von Benutzern. Dann werden verschiedene Befehle zur Verfügung gestellt. Um eine umfangreiche Liste von Windows-Befehlen und deren kurzen Zusammenfassungen zu erhalten, öffnen Sie die Eingabeaufforderung auf jedem Windows-Computer und geben Sie die Hilfe ein. Um einen bestimmten Befehl herauszufinden, geben Sie den Namen des Befehls ein, gefolgt von. Das Thema dieses Buches ist auch als Batch-Programmierung bekannt, obwohl Batch bezieht sich nicht nur auf Batch-Dateien für MS DOS und Windows Befehlsinterpreter. Andere Themenbegriffe beinhalten die Batch-Dateiprogrammierung, das Batch-Dateiskripting, den Windows-Batch-Befehl, die Windows-Batchdatei, die Windows-Befehlszeile, die Windows-Eingabeaufforderung und das Windows-Shell-Scripting. Verwenden des Windows-Befehls-Interpreters Bearbeiten Wie eine Befehlszeile interpretiert wird Bearbeiten Das Analysieren einer Befehlszeile in eine Folge von Befehlen ist komplex und variiert subtil vom Befehlsinterpreter zum Befehlsinterpreter. Es gibt jedoch vier Hauptkomponenten: Variable Substitution Eine Befehlszeile wird nach variablen Spezifikationen gescannt, und alle gefundenen werden durch den Inhalt dieser Variablen ersetzt. Zitat Spezielle Zeichen können zitiert werden, um ihre besonderen Bedeutungen zu entfernen. Syntax Befehlszeilen werden zu einer Folge von Befehlen entsprechend einer Syntax entwickelt. Redirection Redirection-Spezifikationen werden angewendet und aus der Befehlszeile entfernt, bevor ein einzelner Befehl in einer Sequenz ausgeführt wird. Variable Substitution Bearbeiten Befehlszeilen können Variable Spezifikationen enthalten. Diese umfassen einen Charakter, gefolgt von einem Namen. Der Name wird durch ein zweites Zeichen beendet, außer in Sonderfällen wie den Batch-Datei-Parametern 1. 2 und so weiter. Variable Spezifikationen werden durch Werte ersetzt. Der Wert, der verwendet wird, um eine variable Spezifikation zu ersetzen, ist wie folgt: Für Variablenspezifikationsnamen, die den Namen von Umgebungsvariablen entsprechen, ist der Ersatz der Wert der benannten Umgebungsvariablen. Beispiel: PATH wird durch den Wert der Umgebungsvariablen PATH ersetzt. Bei variablen Spezifikationen, die Batch-Datei-Parameter benennen (d. h. die nicht-negativen Dezimalzahlen sind), ist der Ersatz der Wert des Parameters, der aus den Argumenten genommen wurde, mit denen die Batch-Datei aufgerufen wurde (vorbehaltlich etwaiger nachfolgender Änderungen durch den SHIFT-Befehl). Beispiel: 2 wird durch den Wert des zweiten Batch-Dateiparameters ersetzt. Sondernamen Bearbeiten Einige Variablennamen sind mit dem Befehl SET nicht sichtbar. Vielmehr werden sie zum Lesen mit der Notation zur Verfügung gestellt. Um sie herauszufinden, geben Sie help set ein. Spezielle Variablennamen und was sie erweitern: Ersatzwert Gebraucht Quoting und Escaping Bearbeiten Sie können verhindern, dass die Sonderzeichen, die die Befehlssyntax steuern, ihre besonderen Bedeutungen haben, mit Ausnahme des Prozentzeichens (): Sie können einen String mit einem Special umgeben Charakter durch Anführungszeichen. Sie können Caret (), ein Fluchtzeichen, unmittelbar vor den Sonderzeichen platzieren. In einem Befehl, der sich nach einer Pipe () befindet, musst du drei Pflichten () verwenden, um zu arbeiten. Die Sonderzeichen, die zitieren oder entkommen müssen, sind meist lt, gt,, amp und. Unter Umständen. Und muss evtl. entkommen sein. Ein Zeilenumbruch kann auch mit Caret entkommen. Wenn Sie die Zeichenfolge mit Anführungszeichen umgeben, werden sie Teil des Arguments, das an den aufgerufenen Befehl übergeben wird. Im Gegensatz dazu, wenn Sie Caret als Fluchtzeichen verwenden, wird das Caret nicht Teil des Arguments. Das Prozentzeichen () ist ein Sonderfall. In der Befehlszeile braucht es nicht zu zitieren oder zu entkommen, es sei denn, zwei von ihnen werden verwendet, um eine Variable wie OS anzugeben. Aber in einer Batch-Datei müssen Sie ein doppeltes Prozentzeichen () verwenden, um ein einzelnes Prozentzeichen () zu erhalten. Das Anschließen des Prozentzeichens in Anführungszeichen oder das Vorgehen mit Caret funktioniert nicht. Echo Johnson amp Sohn Echoes die komplette Zeichenfolge anstatt die Kommandozeile am Amp-Charakter zu teilen. Zitate sind auch Echo Johnson Amps Sohn Wie oben, aber mit Caret vor dem besonderen Charakter kauft. Es werden keine Zitate aufgegeben. Echo Johnson Amps Sohn verwendet keinen Escape Charakter und deshalb wird Sohn als separater Befehl interpretiert, in der Regel führt zu einer Fehlermeldung, dass Befehl Sohn nicht gefunden wird. Echo A B Echoes A B. Caret muss auch entkommen oder es wird auch als Raum entdeckt. Echo Gt NUL Echo A B Echoes A B. Wenn nach einer Pipe ein Caret, der zum Entweichen verwendet wird, verdreifacht werden muss, um das vierte Caret zu arbeiten, ist das eine, das entkommen ist. Wenn 1 equ 1 Echo Gleicher Verstärker Echo In der Tat, gleich Echoes die beiden Strings. Die Caret am Ende der Linie entkommt den Newlines, was dazu führt, dass die drei Linien so behandelt werden, als wären sie eine einzige Linie. Der Platz vor dem ersten Caret ist notwendig oder sonst wird 1 mit dem folgenden Echo verbunden, um 1echo zu ergeben. Attrib File 1.txt Zeigt keine Attribute der Datei mit dem Namen File 1.txt an, da das Entweichen des Space nicht funktioniert. Mit Zitaten, wie in Attribut Datei 1.txt, funktioniert. Echo Das Verhältnis war 47. Wenn aus einer Charge laufen, wird das Prozentzeichen ignoriert. Echo Das Verhältnis war 47. Wenn aus einer Charge laufen, wird das Prozentzeichen einmal ausgegeben. Setze ein modulo143 Wenn du aus einer Charge renst, setzt die modulo-Variable auf 2, der Rest der Division 14 um 3. Funktioniert nicht mit Single. Für i in (1,2,3) do echo i Wenn aus einem Batch laufen, gibt es 1, 2 und 3 aus. Echo temp Gibt den Inhalt der temp-Variablen aus, auch wenn sie aus einer Batchdatei ausgeführt wird. Die Verwendung des Prozentzeichens in einer Charge, um auf Umgebungsvariablen zuzugreifen und übergebene Argumente braucht kein Escaping. Echo temp Ausgänge buchstäblich, wenn sie von der Befehlszeile aus laufen. Echo temp Ausgänge buchstäblich temp, wenn sie von einem Batch laufen. Echo comment line findstr Befehl FINDSTR verwendet Backslash () für Escaping. Im Gegensatz zu Caret, ist dies intern in den Befehl und unbekannt der Kommando-Shell. Syntax Edit Befehlszeilen werden zu einer Folge von Befehlen entsprechend einer Syntax entwickelt. In dieser Syntax können einfache Befehle zu Pipelines zusammengefasst werden. Die wiederum kombiniert werden können, um zusammengesetzte Befehle zu bilden. Die schließlich in Klammern verwandelt werden können. Ein einfacher Befehl ist nur ein Befehlsname, ein Befehlsschwanz und einige Umleitungsspezifikationen. Ein Beispiel für einen einfachen Befehl ist dir. txt gt somefile. Eine Pipeline ist mehrere einfache Befehle verbunden mit dem Rohr metacharacter, auch bekannt als die vertikale bar. Die Standardausgabe des einfachen Befehls, der jedem senkrechten Balken vorausgeht, ist mit dem Standard-Eingang des einfachen Befehls verbunden, der ihm über eine Pipe folgt. Der Befehlsinterpreter führt alle einfachen Befehle in der Pipeline parallel aus. Ein Beispiel für eine Pipeline (bestehend aus zwei einfachen Befehlen) ist dir. txt mehr. Ein zusammengesetzter Befehl ist ein Satz von Pipelines, die durch Konjunktionen getrennt sind. Die Pipelines werden sequentiell nacheinander ausgeführt und die Konjunktion steuert, ob der Befehlsinterpreter die nächste Pipeline ausführt oder nicht. Ein Beispiel für einen zusammengesetzten Befehl (bestehend aus zwei Pipelines, die selbst nur einfache Befehle sind) verschieben file. txt file. bak ampamp dir gt file. txt. Amp - Eine bedingungslose Verbindung. Die nächste Pipeline wird immer nach dem Ausführen der Ausführung ausgeführt. Ampamp - Eine positive bedingte Konjunktion. Die nächste Pipeline wird ausgeführt, wenn die aktuelle eine Ausführung mit einem Null-Exit-Status abgeschlossen ist. - Eine negative bedingte Konjunktion. Die nächste Pipeline wird ausgeführt, wenn die aktuelle eine Ausführung mit einem Nicht-Null-Exit-Status abgeschlossen ist. Ein in Klammern stehender Befehl ist ein zusammengesetzter Befehl, der in Klammern eingeschlossen ist (d. h. (und)). Unter dem Gesichtspunkt der Syntax verwandelt dies einen zusammengesetzten Befehl in einen einfachen Befehl, dessen Gesamtausgabe umgeleitet werden kann. Zum Beispiel: Die Befehlszeile (pushd temp amp dir amp popd) gt somefile verursacht die Standardausgabe des gesamten zusammengesetzten Befehls (pushd temp amp dir amp popd), um zu somefile umgeleitet zu werden. Redirection Edit Redirection-Spezifikationen werden angewendet und aus der Befehlszeile entfernt, bevor ein einzelner Befehl in einer Sequenz ausgeführt wird. Redirection-Spezifikationen steuern, wo die Standard-Eingabe, Standard-Ausgabe und Standard-Fehler-Datei für einen einfachen Befehlspunkt behandelt. Sie überschreiben alle Effekte auf diese Datei Handles, die möglicherweise aus Pipelining resultiert haben. (Siehe vorhergehender Abschnitt zur Befehlssyntax). Umleitungszeichen gt und gtgt können mit 1 für die Standardausgabe vorangestellt werden (gleich wie kein Präfix) oder 2 für den Standardfehler. Die Umleitungsspezifikationen sind: lt Dateiname Redirect Standard-Eingabe zum Lesen aus der benannten Datei. Gt Dateiname Redirect Standardausgabe zum Schreiben in die benannte Datei, Überschreiben des vorherigen Inhalts. Gtgt Dateiname Redirect Standardausgabe, um an die benannte Datei zu schreiben und an das Ende des vorherigen Inhalts anzuhängen. Gtamp h Redirect zu handeln h. Wo Griff ist eine von 0 Standard-Eingang, 1 Standard-Ausgabe, 2 Standard-Fehler, und vieles mehr. Ltamp h Umleitung vom Handgriff h. Dir. txt gtlisting. log leitet die Ausgabe des Dir-Befehls in die list. log-Datei um. Dir. txt gt listing. log Wie oben der Platz vor dem Dateinamen macht keinen Unterschied. Allerdings, wenn Sie dies in das Befehlsfenster eingeben, wird die automatische Vervollständigung mit Tab nach der Eingabe von gt l tatsächlich funktioniert, während es nicht mit gtlisting. log funktioniert. Dir. txt 2gtNUL leitet Fehler des dir-Befehls zu nirgendwo um. Dir. txt gtgtlisting. log leitet die Ausgabe des dir Befehls in die listing. log-Datei um und hängt an die Datei an. Dabei wird der Inhalt der Datei, bevor der umgeleitete Befehl ausgeführt wurde, nicht verloren. Dirt. txt gtlisting. log 2gtamp1 leitet die Ausgabe des dir Befehls in listing. log-Datei zusammen mit den Fehlermeldungen um. Dir. txt gtlisting. log 2gtlisting-errors. log leitet die Ausgabe des dir-Befehls in listing. log-Datei und die Fehlermeldungen an listing-errors. log-Datei um. Gtmyfile. txt echo Hallo Die Umleitung kann dem Befehl vorangehen. Echo Hallo amp echo Welt gtmyfile. txt Nur das 2. Echo wird umgeleitet. (Echo Hallo amp echo Welt) gtmyfile. txt Die Ausgabe von beiden Echos wird umgeleitet. Type con gtmyfile. txt Redirects Konsoleneingabe (con) an die Datei. So ermöglicht die mehrzeilige Benutzereingabe, die durch den Benutzer beendet wird, der die Steuerung Z drückt. Siehe auch Benutzereingabe. (Für i in (1,2,3) do echo i) gt myfile. txt leitet die gesamte Ausgabe der Schleife in die Datei um. Für ich in (1,2,3) do echo i gt myfile. txt Startet die Umleitung neu jedes Mal, wenn der Körper der Schleife eingegeben wird, verlieren die Ausgabe von allen, aber die letzte Schleife Iteration. Wie ein Befehl ausgeführt wird Bearbeiten Batch-Nachladen Bearbeiten Der Befehlsinterpreter lädt den Inhalt eines Batches nach jeder Ausführung einer Zeile oder einer Klammergruppe neu. Wenn Sie den folgenden Batch starten und das Echo A ändern, um B in der Charge kurz nach dem Start zu hören, wird die Ausgabe B. B. Was ist auf einer einzigen Zeile ist wichtig ändernde Echo A in der folgenden Charge nach dem Laufen hat es keine Auswirkungen: Noch Haben nach dem Start Änderungen irgendwelche Auswirkungen auf Befehle eingeklammert mit (und). So hat das Ändern des Echos A nach dem Starten des folgenden Batches keine Auswirkung: Ditto für jede andere Umschließung, einschließlich dieses: Umgebungsvariablen Bearbeiten Die Umgebungsvariablen des Befehlsinterpreterprozesses werden von den Prozessen aller (externen) Befehle vererbt, die sie ausführt. Ein paar Umgebungsvariablen werden vom Befehlsinterpreter selbst verwendet. Das Ändern ändert seinen Betrieb. Umgebungsvariablen sind vom SET betroffen. PFAD. Und PROMPT-Befehle. Um eine Variable zu deaktivieren, setzen Sie sie auf leeren String, wie setzen Sie myvar. Der Befehlsinterpreter erbt seinen ursprünglichen Satz von Umgebungsvariablen aus dem Prozess, der ihn erstellt hat. Im Fall von Befehlsdolmetschern, die von Desktop-Verknüpfungen aufgerufen werden, ist dies beispielsweise Windows Explorer. Befehlsdolmetscher haben in der Regel textuelle Benutzeroberflächen, nicht grafische, und so erkennt man die Windows-Nachricht nicht, die Anwendungen informiert, dass die Umgebungsvariablenvorlage in der Registrierung geändert wurde. Das Ändern der Umgebungsvariablen in der Systemsteuerung veranlasst Windows Explorer, seine eigenen Umgebungsvariablen aus der Vorlage in der Registrierung zu aktualisieren und somit die Umgebungsvariablen zu ändern, die alle nachfolgend aufgerufenen Befehlsdolmetscher erben werden. Allerdings wird es keine Befehlsdolmetscher, die bereits ausgeführt werden, um ihre Umgebungsvariablen aus der Vorlage in der Registrierung zu aktualisieren. COMSPEC Bearbeiten Die Umgebungsvariable COMSPEC enthält den vollständigen Pfadnamen der Befehlsdolmetscher-Programmdatei. Dies wird nur aus dem übergeordneten Prozess geerbt und ist somit indirekt aus der Einstellung von COMSPEC in der Umgebungsvariablenvorlage in der Registry abgeleitet. Der Wert der Umgebungsvariablen PATH umfasst eine Liste von Verzeichnisnamen, die durch Semikolonzeichen getrennt sind. Dies ist die Liste der Verzeichnisse, die bei der Suche nach der Programmdatei eines externen Befehls durchsucht werden. PATHEXT Bearbeiten Der Wert der Umgebungsvariablen PATHEXT umfasst eine Liste von Dateinamenerweiterungen, die durch Halb-Colon-Zeichen getrennt sind. Dies ist die Liste der Dateinamenerweiterungen, die angewendet werden, bei der Lokalisierung der Programmdatei eines externen Befehls zum Ausführen. Ein Beispielinhalt von PATHEXT, gedruckt von echo PATHEXT: Durch Hinzufügen von. PL zur Variable können Sie sicherstellen, dass Perl-Programme von der Befehlszeile aus ausgeführt werden, auch wenn sie ohne die Erweiterung. pl eingegeben wurden. Also, anstatt mydiff. pl a. txt b. txt zu schreiben, kannst du mydiff a. txt b. txt eingeben. Hinzufügen von. PL zur Variable in Windows Vista und höher: setx PATHEXT PATHEXT. PL Wenn Sie den in Windows XP verfügbaren Satz verwenden, ist der Effekt vorübergehend und wirkt sich nur auf die aktuelle Konsole oder den Prozess aus. PROMPT Bearbeiten Die Umgebungsvariable PROMPT steuert den Text, der ausgesendet wird, wenn der Befehlsinterpreter die Eingabeaufforderung anzeigt. Der Befehlsinterpreter zeigt die Eingabeaufforderung an, wenn er für eine neue Befehlszeile im interaktiven Modus aufgefordert wird, oder wenn eine Batchdatei im Batch-Dateimodus ausgegeben wird. Verschiedene Sonderzeichenfolgen im Wert der PROMPT-Umgebungsvariable verursachen verschiedene Spezialeffekte, wenn die Aufforderung angezeigt wird, wie in der folgenden Tabelle: Switches Edit Die meisten Windows-Befehle bieten Switches AKA-Optionen, um ihr Verhalten zu lenken. Switches bestehen meist aus einem Ein-Buchstaben, einige Schalter bestehen aus einer Folge von mehreren Buchstaben. Switches sind mit einem Schrägstrich () vorangestellt, anstatt, wie bei einigen anderen Betriebssystemen, mit einem Minuszeichen (-). Schalter sind Groß - und Kleinschreibung, anstatt, wie bei einigen anderen Betriebssystemen, Groß - und Kleinschreibung zu unterscheiden. Wenn ein Befehl von einem anderen Betriebssystem auf Windows portiert wird (z. B. grep), behält es normalerweise die Optionskonventionen aus dem ursprünglichen Betriebssystem, einschließlich der Verwendung von Minuszeichen und Groß - / Kleinschreibung. Dir Zeigt die Hilfe an. Diese Option wird von vielen Befehlen bereitgestellt. Dir b s Listet alle Dateien und Ordner im aktuellen Ordner rekursiv auf. Es werden zwei Schalter verwendet: b und s. Dir bs funktioniert nicht funktioniert Schalter können nicht hinter einem einzigen Schrägstrich akkumuliert werden. Findstr ric: id: 0-9 File. txt Im Gegensatz zu vielen anderen Befehlen erlaubt findstr die Akkumulation von Schaltern hinter einem einzigen Schrägstrich. In der Tat sind r, i und c Single-Brief-Schalter. Dirbs arbeitet. In dir, das Entfernen von Whitespace zwischen dem Befehl und dem ersten Switch oder zwischen den Switches macht also keinen Unterschied, so ist das gleiche wie dir b s. Treefa funktioniert nicht, im Gegensatz zu Baum f a. Im Baum ist die Trennung durch Whitespace obligatorisch. Auch nicht finden Der Scheckbrief o wird durch einen einzigen Buchstaben weiter modifiziert, der angibt, dass die Bestellung nach Datum erfolgen soll. Der Buchstabe d ist kein Wechsel für sich selbst. Ähnliche Fälle sind dir ad und mehr t4. Dir B S Die Schalter sind Groß - und Kleinschreibung, anders als bei einigen anderen Betriebssystemen. Sortiere r file. txt Sortiert die Datei in umgekehrter Reihenfolge. Sort reverse file. txt sortieren erlaubt, dass der Switch-String länger als ein Single-Brief ist. Sort reve file. txt Sortiert die zulässige Switch-String als Substring des vollständigen langen Namens des Switches. So tut das gleiche wie oben Sortiere reva file. txt funktioniert nicht, da reva kein substring von rückwärts ist. Taskkill im AcroRd32.exe Taskkill benötigt einen Multiletter-Switch-Namen für Im-Verkürzung auf i funktioniert nicht. Java-version Java, das in der Umgebung einer anderen Betriebssystemfamilie entstand, verwendet die Minus-Konvention für ihre AKA-Optionen. Grep --help Wenn GNU grep installiert ist, bedarf es von mehreren Buchstabenschaltern mit zwei Bindestrichen. Fehlerstufe Bearbeiten Befehle setzen in der Regel die Fehlerstufe am Ende ihrer Ausführung. In Windows NT und später ist es eine 32-Bit-Ganzzahl in MS DOS, die früher eine Integer von 0 bis 255 war. Schlüsselwörter: Rückkehrcode, Exit-Code, Status beenden. Die konventionelle Bedeutung der Fehlerstufe: 0 - Erfolg nicht 0 - Fehler Die eingestellten Fehlerstufen sind meist positiv. Wenn der Befehl nicht unterscheidet verschiedene Arten von Ausfall, ist die Fehler-Ebene bei Ausfall in der Regel 1. Verwendungen der Fehler-Ebene: Es kann mit amampamp getestet werden und siehe auch Syntax. Es kann mit IF getestet werden. Der Wert kann aus der Variable ERRORLEVEL abgerufen werden. Dir gtNUL ampamp echo Erfolg Der Teil nach ampamp wird nur ausgeführt, wenn der Fehler auf Null gesetzt ist. Farbe 00 Echo Ausfall Der Teil danach wird nur ausgeführt, wenn der Fehlerpegel ungleich Null ist, ob positiv oder negativ. Farbe 00 (Echo Failure) Multiline Bracketing funktioniert auch. Echo ERRORLEVEL Zeigt den Fehlerpegel an, ohne ihn zu ändern. If errorlevel equ 0 echo Der Fehler ist Null, also Erfolg. If errorlevel neq 0 echo Die Fehlerstufe ist ungleich Null, dh Ausfall. Wenn errorlevel 1 echo Die Fehlerstufe ist gt 1, dh Ausfall über positiven Fehlerpegel. Deckt nicht den Fehler über den negativen Fehlerpegel ab. Beachten Sie den gt-Teil: das ist nicht dasselbe wie wenn errorlevel equ 1. exit b 1 Gibt eine Batchdatei zurück, wobei die Fehlerstufe auf 1 gesetzt wird. Cmd c exit b 10 In der Mitte einer Batchdatei oder in der Befehlszeile setzt sich ein Der Fehlerpegel auf 10. (cmd c exit b 0 ampamp Echo Success) amp (cmd c exit b -1 Echo Failure) Wie oben ist die Anzeige des Fehlerpegels tatsächlich betroffen. (Cmd c exit b 0 amp cmd c exit b 1) Echofehler Der Fehlerpegel einer durch amp erzeugten Kette ist der Fehlerpegel des letzten Befehls der Kette. Cmd c exit b -1 amp wenn nicht errorlevel 1 echo Möchtegern-Erfolg Der if not errorlevel 1 Test, der vielleicht für den Erfolg zu testen scheint, geht an negativen Zahlen weiter: Es testet auf nicht Fehler Level gt 1, das ist Fehler Level lt 0. set myerrorlevelerrorlevel Erinnert sich die Fehlerstufe für später. Set errorlevel0 Um zu vermeiden, überschattet die eingebaute errorlevel-Variable. Stellt sicher, dass nachfolgende Zugriffe über ERRORLEVEL anstelle des tatsächlichen Fehlerpegels 0 zurückgeben. Cmd c exit b 0 if 1 equ 1 (cmd c exit b 1 amp echo errorlevel) Zeigt 0 an, da fehlerlevel erweitert wird, bevor cmd c exit b 1 ausgeführt wird. String-Bearbeitung Bearbeiten Ein Teilstring einer Variablen nach Position und Länge: Bevor Sie die folgenden Beispiele ausführen, stellen Sie sicher, dass a abcd ist, indem Sie dies ausführen: color f9 Verwenden Sie weißen Hintergrund und blauen Vordergrund. Farbe Wiederherstellen der ursprünglichen Farbeinstellung. Kopiert Dateien. Siehe auch MOVE Kopiere F: File. txt Kopiert die Datei in das aktuelle Verzeichnis, vorausgesetzt, das aktuelle Verzeichnis ist nicht F :. Kopiere F: Meine Datei. txt Wie oben sind Anführungszeichen erforderlich, um eine Datei mit Leerzeichen zu umgeben. Kopiere F:.txt Kopiert die Dateien bei F: und endet in dot txt in das aktuelle Verzeichnis, vorausgesetzt, das aktuelle Verzeichnis ist nicht F :. Kopiere F:.txt. Ist das gleiche wie der obige Befehl. Copy File. txt gibt eine Fehlermeldung aus, da File. txt nicht über sich selbst kopiert werden kann. Kopiere File1.txt File2.txt Kopiert File1.txt in File2.txt, überschreibt File2.txt, wenn es vom Benutzer bestätigt oder von einem Batch-Skript ausgeführt wird. Kopiere File. txt Mein Verzeichnis kopiert File. txt in mein Verzeichnisverzeichnis, vorausgesetzt, mein Verzeichnis existiert. Kopiere Dir1 Dir2 Kopiert alle Dateien, die sich direkt im Verzeichnis Dir1 befinden, in Dir2, wobei Dir1 und Dir2 Verzeichnisse sind. Kopiert keine Dateien, die sich in verschachtelten Verzeichnissen von Dir1 befinden. Kopiere. txt. bak Für jede. txt-Datei im aktuellen Ordner wird eine Kopie mit bak anstatt txt beendet. Löscht Dateien. Verwenden Sie vorsichtig, besonders in Kombination mit Wildcards. Nur löscht Dateien, nicht Verzeichnisse, für die RD sehen. Für mehr, Typ del. Del File. txt del s. txt Löscht die Dateien rekursiv mit verschachtelten Verzeichnissen, aber hält die Verzeichnisse gnadenlos löscht alle übereinstimmenden Dateien, ohne um eine Bestätigung zu bitten. Del ps. txt Wie oben, bittet aber um Bestätigung vor jeder einzelnen Datei. Listet den Inhalt eines Verzeichnisses auf. Bietet eine Reihe von Optionen. Geben Sie dir für mehr Hilfe ein. Dir Listet die Dateien und Ordner im aktuellen Ordner auf, ausgenommen versteckte Dateien und Systemdateien verwenden eine andere Art der Auflistung, wenn die DIRCMD-Variable nicht leer ist und die Schalter für dir enthält. Dir D: dir b C: Benutzerverzeichnis l Listet den Inhalt des Verzeichnisses und alle Unterverzeichnisse rekursiv auf. Dir s b Listet den Inhalt des Verzeichnisses und alle Unterverzeichnisse rekursiv auf, eine Datei pro Zeile, die den vollständigen Pfad für jede aufgeführte Datei oder jedes Verzeichnis anzeigt. Dir. txt Listet alle Dateien mit der. txt-Erweiterung auf. Dir a Enthält versteckte Dateien und Systemdateien in der Auflistung. Dir ah Listet nur versteckte Dateien auf. Dir ad Listet nur Verzeichnisse auf. Andere Buchstaben nach A gehören S, I, R, A und L. dir ahd Listet nur versteckte Verzeichnisse auf. Dir a-d Listet nur Dateien auf und weglässt Verzeichnisse. Dir a-d-h Listet nur nicht versteckte Dateien auf und weglässt Verzeichnisse. Ob od Die Dateien und Ordner nach dem Datum der letzten Änderung. Andere Buchstaben nach O enthalten N (nach Name), E (nach Erweiterung), S (nach Größe) und G (Ordner zuerst) dir o-s Orders die Dateien um die Größe absteigend die Auswirkungen auf Ordner Reihenfolge ist unklar. Dir - c o-s a-d Listet Dateien auf, die nach Größe absteigend sortiert sind, wobei die Tausender-Trennzeichen über - C ausgeschlossen werden, ohne Ordner. Dir s b od Listet den Inhalt des Verzeichnisses und alle Unterverzeichnisse rekursiv auf und ordnet die Dateien in jedem Verzeichnis bis zum Datum der letzten Änderung an. Die Bestellung erfolgt nur pro Verzeichnis der komplette Satz von Dateien so gefunden wird nicht als Ganzes bestellt. Dir a s Listet Dateien rekursiv auf, einschließlich versteckter Dateien und Systemdateien. Kann verwendet werden, um herauszufinden, die Festplatte Nutzung (Verzeichnis Größe), indem Sie die endgültigen Zeilen der Ausgabe. Zeigt oder setzt das Datum. Die Art und Weise, wie das Datum angezeigt wird, hängt von den Ländereinstellungen ab. Datum kann auch mit echo DATE angezeigt werden. Getting date im iso-Format, wie 2000-01-28: Das ist nirgends einfach, da das Datumsformat von Ländereinstellungen abhängt. Wenn Sie das Format von Mon 01282000 übernehmen können, wird folgendes getan: set isodatedate: 7,2 Wenn du WMIC hast. Das folgende ist locale unabhängig: für f i in (wmic os erhalten LocalDateTime) tun, wenn ich lss a Wenn ich gtr 0 set localdti set isodatelocaldt: 6,2 Um das oben in einer Charge zu verwenden, schalte ich in i und entfernen von vorher wenn wenn. Wenn du Perl installiert hast: für f i in (perl - MPOSIX - le print strftime Y-m-d, localtime) setze isodatei Zeigt Nachrichten an oder schaltet den Befehl echo ein oder aus. Echo auf Echo aus Echo Hallo Echo Hallo Zeigt die Zitate auch an. Echo PATH Zeigt den Inhalt der Variablen PATH an. Echo Besitzer amp Sohn Verwendet Caret (), um es zu kämpfen und Verstärker zu entkommen, wodurch das Echo von Bekenntnissen ermöglicht wird. Echo 1ampecho 2ampecho 3 Zeigt drei Strings an, jeweils gefolgt von einem Zeilenumbruch. Echo. Gibt eine Zeilenumbrüche aus, während die Periode nicht ausgegeben wird. Ohne die Periode werden die Ausgänge abgehoben oder echo auf. Hinzufügen eines Leerzeichens vor dem Zeitraum führt zu der Periode, die ausgegeben wird. Andere Zeichen mit der gleichen Wirkung wie die Periode beinhalten: (echo randomgtgtMyRandomNumbers. txt Während es scheint, zufällige Zahlen zu MyRandomNumbers. txt auszugeben, tut es eigentlich nicht für die Zahlen 0-9, da diese, wenn sie vor gtgt platziert sind, anzeigen (Echo 2) gtgtMyRandomNumbers. txt Echos sogar eine kleine Zahl (in diesem Fall 2) und leitet das Ergebnis um. Der Echo 2gtgtMyRandomNumbers. txt Statt Echo 2, leitet den Standardfehler in die Datei um. GtgtMyRandomNumbers. txt echo 2 Ein anderer Weg, um auch nur eine kleine Zahl zu wiederholen und das Ergebnis umzuleiten. Das Anzeigen eines Strings ohne eine Zeilenumbringung erfordert einen Trick: set ltNUL pOutput eines Befehls: Zeigt die Ausgabe eines Befehls an :. Die Ausgabe des nächsten Befehls wird sein Sofort angezeigt nach:. Set ltNUL pZeitzeit: Amperezeit t Anzeigen Aktuelle Uhrzeit: gefolgt von der Ausgabe der Zeit t. (Set ltNUL pZeitzeit: Amperezeit t) gttmp. txt Wie schon früher, mit der Umleitung der Ausgabe beider Befehle auf a Datei ENDLOCAL Bearbeiten Beendet den lokalen Satz von Umgebungsvariablen, die mit SETLOCAL gestartet wurden. Kann zum Erstellen von Unterprogrammen verwendet werden: siehe Funktionen. ERASE Edit Beendet die DOS-Konsole oder mit b nur den aktuell laufenden Batch oder die aktuell ausgeführte Subroutine. Wenn es ohne b in einer Batchdatei verwendet wird, wird die DOS-Konsole aufgerufen, die Batch zu schließen. Iteriert über eine Reihe von Werten, führt einen Befehl aus. In den folgenden Beispielen soll ich von der Befehlszeile benutzt werden, während ich aus einer Charge verwendet werden soll. Für ich in (1,2,3) do echo i In einer Charge, Echos 1, 2 und 3. In einem Batch muss der Befehl ein doppeltes Prozentzeichen verwenden. Die verbleibenden Beispiele sollen direkt in eine Befehlszeile eingefügt werden, so dass sie ein einzelnes Prozentzeichen verwenden und eine wiederholte Anzeige verhindern. Für i in (1,2,3) do echo i Von einer Befehlszeile, Echos 1, 2 und 3. Der Befehl fordert, die Elemente als Dateinamen und als Muster von Dateinamen mit Wildcards zu interpretieren. Es klagt nicht, wenn die Gegenstände nicht mit vorhandenen Dateinamen übereinstimmen. Denn ich in (1,2, adcet) Echo i Es sei denn, du hast eine Datei, die mit dem dritten Muster übereinstimmt, Echos 1 und 2, Verwerfen des dritten Items. Für i in (1 2,34) Echo i Echos 1, 2, 3 und 4. Ja, eine Mischung aus Item Separatoren wird verwendet. Für i in (.txt) do echo i Echoes Dateinamen von Dateien, die sich im aktuellen Ordner befinden und die. txt-Erweiterung haben. Für ich in (C: Windowssystem32.exe) tun Echo i Echos Dateinamen, die dem Muster entsprechen. Für r i in (.txt) do echo i Echos Dateinamen mit vollständigen Pfaden, von Dateien mit der Erweiterung. txt irgendwo in den aktuellen Ordner einschließlich verschachtelten Ordner. Für d i in () do echo i Echos die Namen aller Ordner im aktuellen Ordner. Für r d i in () do echo i Echos die Namen einschließlich vollständiger Pfade aller Ordner im aktuellen Ordner, einschließlich verschachtelter Ordner. Für r i in () do if zi geq 1000000 echo zi i Für jede Datei im aktuellen Ordner und seinen Unterordnern, die die Größe größer oder gleich 1.000.000 Bytes hat, gibt die Dateigröße in Bytes und den vollständigen Pfad der Datei aus. Für die Syntax in zi siehe Percent Tilde. Für l i in (1,1,10) Echo i Echos die Zahlen von 1 bis 10. für f Token i in (list. txt) do echo i Für jede Zeile in einer Datei, Echo der Zeile. Für f-tokens i in (list1.txt list2.txt) do echo i Für jede Zeile in den Dateien, Echos der Zeile. Für f-tokens ich in (.txt) tun echo ich tut nichts. Akzeptiert keine Platzhalter, um Dateinamen anzupassen. for f tokens1-3 delims: a in (First:Second::Third) do echo c-b-a Parses a string into tokens delimited by :. The quotation marks indicate the string is not a file name. The second and third tokens are stored in b and c even though b and c are not expressly mentioned in the part of the command before do. The two consecutive colons are treated as one separator c is not but rather Third. Does some of the job of the cut command from other operating systems. for f tokens1-3 delims: a in (First:Second::Third:Fourth:Fifth) do echo c-b-a: d As above, just that the 4th and 5th items get captured in d as Fourth:Fifth, including the separator. for f tokens1-3 delims:, a in (First, Second,:Third:Fourth:Fifth) do echo c-b-a: d Multiple delimiters are possible. for f tokens1-3 a in (First Second Third, item) do echo c-b-a The default delimiters are space and tab. Thus, they differ from the separators used to separate arguments passed to a batch. for f tokens i in (cd) do echo i For each line of the result of a command, echoes the line. for f tokens i in (dir b a-d-h) do echo nxai For each non-hidden file in the current folder, displays the file attributes followed by the file name. In the string nxai, uses the syntax described at Percent tilde . for f usebackq tokens i in (dir b a-d-h) do echo nxai As above, but using the backquote character () around the command to be executed. for f tokens i in (tasklist sort amp echo End) do echo i Pipes and ampersands in the command to be executed must be escaped using caret (). (for i in (1,2,3) do echo i) gt anyoldtemp. txt To redirect the entire result of a for loop, place the entire loop inside brackets before redirecting. Otherwise, the redirection will tie to the body of the loop, so each new iteration of the body of the loop will override the results of the previous iterations. for i in (1,2,3) do echo i gt anyoldtemp. txt An example related to the one above. It shows the consequence of failing to put the loop inside brackets. Continue: To jump to the next iteration of the loop and thus emulate the continue statement known from many languages, you can use goto provided you put the loop body in a subroutine, as shown in the following: If you use goto directly inside the for loop, the use of goto breaks the loop bookkeeping. The following fails: FTYPE Edit Used for remarks in batch files, preventing the content of the remark from being executed. REM is typically placed at the beginning of a line. If placed behind a command, it does not work, unless preceded by an ampersand, as shown in the example above. An alternative to REM is double colon. RMDIR Edit This is a synonym of RD . Displays or sets environment variables. With P switch, it asks the user for input, storing the result in the variable. With A switch, it performs simple arithmetic calculations, storing the result in the variable. With string assignments, there must be no spaces before and after the equality sign thus, set name Peter does not work, while set namePeter does. set Displays a list of environment variables set HOME Displays the values of the environment variables whose names start with HOME set MYNUMBER56 set HOMEHOMEC:Program FilesMy Bin Folder set P userinputEnter an integer: set A result 4 ( 6 3 ) Sets the result variable with the result of a calculation. See also Calculation . SETLOCAL Edit When used in a batch file, makes all further changes to environment variables local to the current batch file. When used outside of a batch file, does nothing. Can be ended using ENDLOCAL. Exiting a batch file automatically calls end local. Can be used to create subprograms: see Functions . Furthermore, can be used to enable delayed expansion like this: setlocal EnableDelayedExpansion. Delayed expansion consists in the names of variables enclosed in exclamation marks being replaced with their values only after the execution reaches the location of their use rather than at an earlier point. The following is an example of using delayed expansion in a script that prints the specified number of first lines of a file, providing some of the function of the command head known from other operating systems: SHIFT Edit Shifts the batch file arguments along, but does not affect . Thus, if 1Hello 1, 2Hello 2, and 3Hello 3, then, after SHIFT, 1Hello 2, and 2Hello 3, but is Hello 1 Hello 2 Hello 3. START Edit Starts a program in new window, or opens a document. Uses an unclear algorithm to determine whether the first passed argument is a window title or a program to be executed hypothesis: it uses the presence of quotes around the first argument as a hint that it is a window title. start notepad. exe amp echo Done. Starts notepad. exe, proceeding to the next command without waiting for finishing the started one. Keywords: asynchronous. start notepad. exe Launches a new console window with notepad. exe being its title, apparently an undesired outcome. start C:Program FilesInternet Exploreriexplore. exe Starts Internet Explorer. The empty passed as the first argument is the window title of a console that actually does not get opened, or at least not visibly so. start C:Program FilesInternet Exploreriexplore. exe Launches a new console window with C:Program FilesInternet Exploreriexplore. exe being its title, apparently an undesired outcome. start wait notepad. exe amp echo Done. Starts notepad. exe, waiting for it to end before proceeding. start low notepad. exe amp echo Done. As above, but starting the program with a low priority. start MyFile. xls Opens the document in the program assigned to open it. start Starts a new console (command-line window) in the same current folder. Anfang. Opens the current folder in Windows Explorer. Anfang. Opens the parent folder in Windows Explorer. start mailto: Starts the application for writing a new email. start b TODO:example-application-where-this-is-useful Starts the application without opening a new console window, redirecting the output to the console from which the start command was called. Displays or sets the system time. TITLE Edit Sets the title displayed in the console window. External commands available to Windows command interpreter are separate executable program files, supplied with the operating system by Microsoft, or bundled as standard with the third-party command interpreters. By replacing the program files, the meanings and functions of these commands can be changed. Many, but not all, external commands support the convention, causing them to write on-line usage information to their standard output and then to exit with a status code of 0. Displays or changes items in the address resolution protocol cache, which maps IP addresses to physical addresses. Schedules a program to be run at a certain time. See also SCHTASKS . ATTRIB Edit Displays or sets file attributes. With no arguments, it displays the attributes of all files in the current directory. With no attribute modification instructions, it displays the attributes of the files and directories that match the given search wildcard specifications. Similar to chmod of other operating systems. To add an attribute, attach a in front of its letter. To remove an attribute, attach a - in front of its letter Attributes: A - Archived H - Hidden S - System R - Read-only . and possibly others. attrib Displays the attributes of all files in the current directory. attrib File. txt Displays the attributes of the file. attrib r File. txt Adds the Read-only attribute to the file. attrib - a File. txt Removes the Archived attribute from the file. attrib - a r File. txt Removes the Archived attribute and adds the Read-only attribute to the file. attrib r. txt Acts on a set of files. attrib S r. txt Acts recursively in subdirectories. For more, type attrib . BCDEDIT Edit (Not in XP). Edits Boot Configuration Data (BCD) files. For more, type bcdedit . CACLS Edit Shows or changes discretionary access control lists (DACLs). See also ICACLS. For more, type cacls . Displays or sets the active code page number. For more, type chcp . CHKDSK Edit Checks disks for disk problems, listing them and repairing them if wished. For more, type chkdsk . CHKNTFS Edit Shows or sets whether system checking should be run when the computer is started. The system checking is done using Autochk. exe. The NTFS part of the command name is misleading, since the command works not only with NTFS file system but also with FAT and FAT32 file systems. For more, type chkntfs . CHOICE Edit Lets the user choose one of multiple options by pressing a single key, and sets the error level as per the chosen option. Absent in Windows 2000 and Windows XP, it was reintroduced in Windows Vista, and has remained in Windows 7 and 8. choice m Do you agree Presents the user with a yesno question, setting the error level to 1 for yes and to 2 for no. If the user presses Control C, the error level is 0. choice c rgb m Which color do you prefer Presents the user with a question, and indicates the letters for the user. Responds to user pressing r, g or b, setting the error level to 1, 2 or 3. An alternative is set p see SET . CIPHER Edit Shows the encryption state, encrypts or decrypts folders on a NTFS volume. (Not in XP) Places the piped input to the clipboard. set clip Places the listing of environment variables to the clipboard. clip lt File1.txt Places the content of File1.txt to the clipboard. Invokes another instance of Microsofts CMD. Compares files, displaying the differences in their content in a peculiar way. fc File1.txt File2.txt gtNUL ampamp Echo Same echo Different or error Detects difference using the error level of fc. The error level of zero means the files are the same non-zero can mean the files differ but also that one of the files does not exist. Searches for a string in files or input, outputting matching lines. Unlike FINDSTR. it cannot search folders recursively, cannot search for a regular expression, requires quotation marks around the sought string, and treats space literally rather than as a logical or. find (object. txt dir S B find receipt dir S B find I V receipt Prints all non-matching lines in the output of the dir command, ignoring letter case. find C inlined. h Instead of outputting the matching lines, outputs their count. If more than one file is searched, outputs one count number per file preceded with a series of dashes followed by the file name does not output the total number of matching lines in all files. find C V lt file. txt Outputs the number of lines AKA line count in file. txt. Does the job of wc - l of other operating systems. Works by treating as a string not found on the lines. The use of redirection prevents the file name from being output before the number of lines. type file. txt find C V Like the above, with a different syntax. type. txt 2gtNUL find C V Outputs the sum of line counts of the files ending in. txt in the current folder. The 2gtNUL is a redirection of standard error that removes the names of files followed by empty lines from the output. find Schnheit. txt If run from a batch file saved in unicode UTF-8 encoding, searches for the search term Schnheit in UTF-8 encoded. txt files. For this to work, the batch file must not contain the byte order mark written by Notepad when saving in UTF-8. Notepad is an example of a program that lets you write UTF-8 encoded plain text files without byte order mark. While this works with find command, it does not work with FINDSTR . find Copyright C:Windowssystem32a. exe Works with binary files no less than text files. FINDSTR Edit Searches for regular expressions or text strings in files. Does some of the job of grep command known from other operating systems, but is much more limited in the regular expressions it supports. Treats space in a regular expression as a disjunction AKA logical or unless prevented with c option. findstr s 0-90-9.0-90-9.h. cpp Searches recursively all files whose name ends with dot h or dot cpp, printing only lines that contain two consecutive decimal digits followed by anything followed by two consecutive decimal digits. findstr a. b a. c File. txt Outputs all lines in File. txt that match any of the two regular expressions separated by the space. Thus, the effect is one of logical or on regular expressions. echo world findstr hello wo. ld Does not match. Since the 1st item before the space does not look like a regex, findstr treats the whole search term as a plain search term. echo world findstr r hello wo. ld Matches. The use of r forces regex treatment. findstr r c:ID: 0-9 File. txt Outputs all lines in File. txt that match the single regular expression containing a space. The use of c prevents the space from being treated as a logical or. The use of r switches the regular expression treatment on, which was disabled by default by the use of c. To test this, try the following: echo ID: 12findstr r c:ID: 0-9 Matches. echo ID: 12findstr c:ID: 0-9 Does not match, as the search string is not interpreted as a regular expression. echo ID: abcfindstr ID: 0-9 Matches despite the output of echo failing to match the complete regular expression: the search is interpreted as one for lines matching ID: or 0-9. findstr ric:id: 0-9 File. txt Does the same as the previous example, but in a case-insensitive manner. While findstr enables this sort of accumulation of switches behind a single , this is not possible with any command. For instance, dir bs does not work, while dir b s does. To test this, try the following: echo ID: 12findstr ric:id: 0-9 echo ID: abfindstr ric:id: 0-9 findstr msric:id: 0-9.txt Like above, but recursively for all files per s, displaying only matching files rather than matching lines per m. echo hel lo findstr c:hel lo c:world c switch can be used multiple times to create logical or. echo hello findstr hello Does not match. Backslash before quotation marks and multiple other characters acts as an escape thus, matches . echo hello findstr hello Matches. Double backslash passed to findstr stands for a single backslash. echo hello findstr hello Matches. None of the single backslashes passed to findstr is followed by a character on which the backslash acts as an escape. echo hey findstr hey more To search for a quote (quotation mark), you need to escape it two times: once for the shell using caret (), and once for findstr using backslash (). echo hey findstr hey there more To search for a quote and have the search term enclosed in quotes as well, the enclosing quotes need to be escaped for the shell using caret (). echo comment line findstr If forward slash () is the 1st character in the search term, it needs to be escaped with a backslash (). The escaping is needed even if the search term is enclosed in quotes. findstr f:FileList. txt def.(): Search in the files stated in FileList. txt, one file per line. File names in FileList. txt can contain spaces and do not need to be surrounded with quotation marks for this to work. findstr g:SearchTermsFile. txt. txt Search for the search terms found in SearchTermsFile. txt, one search term per line. A space does not serve to separate two search terms rather, each line is a complete search term. A line is matched if at least one of the search terms matches. If the first search term looks like a regex, the search will be a regex one, but if it looks like a plain search term, the whole search will be a plain one even if 2nd or later search terms look like regex. findstr xlg:File1.txt File2.txt Outputs set intersection: lines present in both files. findstr xlvg:File2.txt File1.txt Outputs set difference: File1.txt - File2.txt. findstr m Microsoft C:Windowssystem32 Works with binary files no less than text files. Limitations of the regular expressions of findstr, as compared to grep: No support of groups -- (, ). No support of greedy iterators -- . No support of zero or one of the previous -- . And more. echo bbfindstr bb baaaa Does not find anything in multiple Windows versions, but it should. Also consider typing findstr . FORFILES Edit Finds files by their modification date and file name pattern, and executes a command for each found file. Is very limited, especially compared to the find command of other operating systems. Available since Windows Vista. For more, type forfiles . forfiles s d 06102015 c cmd c echo fdate path For each file in the current folder and its subfolders modified on 10 June 2015 or later, outputs the file modification date and full file path. The date format after d is locale specific. Thus, allows to find most recently modified files. Keywords: most recently changed files. forfiles m. txt s d 06102015 c cmd c echo fdate path As above, but only for files ending in. txt. FORMAT Edit Formats a disk to use Windows-supported file system such as FAT, FAT32 or NTFS, thereby overwriting the previous content of the disk. To be used with great caution. FSUTIL Edit A powerful tool performing actions related to FAT and NTFS file systems, to be ideally only used by powerusers with an extensive knowledge of the operating systems. GPRESULT Edit Displays group policy settings and more for a user or a computer. GRAFTABL Edit Enables the display of an extended character set in graphics mode. Fore more, type graftabl . Shows command help. help Shows the list of Windows-supplied commands. help copy Shows the help for COPY command, also available by typing copy . ICACLS Edit (Not in XP) Shows or changes discretionary access control lists (DACLs) of files or folders. See also CACLS. Fore more, type icacls . IPCONFIG Edit Displays Windows IP Configuration. Shows configuration by connection and the name of that connection (i. e. Ethernet adapter Local Area Connection) Below that the specific info pertaining to that connection is displayed such as DNS suffix and ip address and subnet mask. LABEL Edit Adds, sets or removes a disk label. MAKECAB Edit Places files into compressed. cab cabinet file. See also EXPAND . A multi-purpose command to display device status, configure ports and devices, and more. mode Outputs status and configuration of all devices, such as com3 and con. mode con Outputs status and configuration of con device, the console in which the command interpreter is running. mode con cols120 lines20 Sets the number of columns and lines for the current console, resulting in window resizing, and clears the screen. The setting does not affect new console instances. Keywords: wide screen, wide window, screen size, window size, resize screen, resize window. mode 120, 20 As above: Sets the number of columns (120) and lines (20), resulting in window resizing, and clears the screen. mode con cols120 Sets the number of columns for the current console, resulting in window resizing, and clears the screen. It seems to change the number of visible lines as well, but the total lines count of the console buffer seems unchanged. mode 120 As above: Sets the number of columns. mode con cp Outputs the current code page of the console. mode con cp select850 Sets the current code page of the console. For a list of code pages, see the linked Microsoft documentation below. mode con rate31 delay1 Sets the rate and delay for repeated entry of a character while a key is held pressed, of the console. The lower the rate, the fewer repetitions per second. Displays the contents of a file or files, one screen at a time. When redirected to a file, performs some conversions, also depending on the used switches. more Test. txt more. txt grep - i sought. string Source. txt more p gtOut. txt Taking the output of a non-Windows grep command that produces line breaks consisting solely of LF character without CR character, converts LF line breaks to CR-LF line breaks. CR-LF newlines are also known as DOS line breaks, Windows line breaks, DOS newlines, Windows newlines, and CRLF line endings, as opposed to LF line breaks used by some other operating systems. In some setups, seems to output gibberish if the input contains LF line breaks and tab characters at the same time. In some setups, for the conversion, p may be unneeded. Thus, more would convert the line breaks even without p. more t4 Source. txt gtTarget. txt Converts tab characters to 4 spaces. In some setups, tab conversion takes place automatically, even without the t switch. If so, it is per default to 8 spaces. The online documentation for more in Windows XP and Windows Vista does not mention the switch. The switch e is mentioned in more at least in Windows XP and Windows Vista. Per more , the switch is supposed to enable extended features listed at the end of more help such as showing the current row on pressing . However, in Windows XP and Windows Vista, that seems to be enabled by default even without e. Hypothesis: In Windows XP and Windows Vista, e does not do anything it is present for compatibility reasons. Provides various network services, depending on the command used. Available variants per command: net accounts net computer net config net continue net file net group net help net helpmsg net localgroup net name net pause net print net send net session net share net start net statistics net stop net time net use net user net view OPENFILES Edit Performs actions pertaining to open files, especially those opened by other users over the network. The actions involve querying, displaying, and disconnecting. For more, type openfiles . Send ICMPIP echo packets over the network to the designated address (or the first IP address that the designated hostname maps to via name lookup) and print all responses received. RECOVER Edit Recovers as much information as it can from damaged files on a defective disk. Queries or modifies Windows registry. The first argument is one of the following commands: query, add, delete, copy, save, load, unload, restore, compare, export, import, and flags. To learn more about a command, follow it by . like reg query . REPLACE Edit Replaces files in the destination folder with same-named files in the source folder. ROBOCOPY Edit (Not in XP) Copies files and folders. See also XCOPY and COPY . RUNDLL32 Edit Runs a function available from a DLL. The available DLLs and their functions differ among Windows versions. rundll32 sysdm. cpl, EditEnvironmentVariables In some Windows versions, opens the dialog for editing environment variables. SCHTASKS Edit Schedules a program to be run at a certain time, more powerful than AT . Like SET. but affecting the whole machine rather than the current console or process. Not available in Windows XP available in Windows Vista and later. SHUTDOWN Edit Shuts down a computer, or logs off the current user. Sorts alphabetically, from A to Z or Z to A. Cannot sort numerically: if the input contains one integer per line, 12 comes before 9. sort File. txt Outputs the sorted content of File. txt. sort r File. txt Sorts in reverse order, Z to A. dir b sort SUBST Edit Assigns a drive letter to a local folder, displays current assignments, or removes an assignment. subst p. Assigns p: to the current folder. subst Shows all assignments previously made using subst. subst d p: Removes p: assignment. SYSTEMINFO Edit Shows configuration of a computer and its operating system. TASKKILL Edit Ends one or more tasks. taskkill im AcroRd32.exe Ends all process with the name AcroRd32.exe thus, ends all open instances of Acrobat Reader. The name can be found using tasklist . taskkill f im AcroRd32.exe As above, but forced . Succeeds in ending some processes that do not get ended without f. tasklist find notepadtaskkill PID 5792 Ends the process AKA task with process ID (PID) of 5792 the assumption is you have found the PID using tasklist. TASKLIST Edit Lists tasks, including task name and process id (PID). tasklist sort tasklist find AcroRd tasklist find C chrome. exe Displays the number of tasks named chrome. exe, belonging to Google Chrome browser. TIMEOUT Edit Waits a specified number of seconds, displaying the number of remaining seconds as time passes, allowing the user to interrupt the waiting by pressing a key. Also known as delay or sleep. Available in Windows Vista and later. timeout t 5 Waits for five seconds, allowing the user to cancel the waiting by pressing a key. timeout t 5 nobreak Waits for five seconds, ignoring user input other than Control C. timeout t 5 nobreak gtnul As above, but with no output. Workaround in Windows XP: ping - n 6 127.0.0.1 gtnul Waits for five seconds the number after - n is the number of seconds to wait plus 1. Perl-based workaround in Windows XP, requiring Perl installed: Displays a tree of all subdirectories of the current directory to any level of recursion or depth. If used with F switch, displays not only subdirectories but also files. tree tree f Includes files in the listing, in addition to directories. tree f a As above, but uses 7-bit ASCII characters including , - and to draw the tree. A snippet of a tree using 8-bit ASCII characters: A snippet of a tree using 7-bit ASCII characters: WHERE Edit Outputs one or more locations of a file or a file name pattern, where the file or pattern does not need to state the extension if it listed in PATHEXT. such as. exe. Searches in the current directory and in the PATH by default. Does some of the job of which command of some other operating systems, but is more flexible. Available on Windows 2003, Windows Vista, Windows 7, and later not available on Windows XP. An alternative to be used with Windows XP is in the examples below. Does not find internal commands, as there are no dot exe files for them to match. where find Outputs the location of the find command, possibly C:WindowsSystem32find. exe. The. exe extension does not need to be specified as long as it is listed in PATHEXT. which it is by default. If there are more find commands in the path, outputs paths to both. In some situations, it can output the following: C:WindowsSystem32find. exe C:Program FilesGnuWin32binfind. exe PATH:i Outputs the location of find. exe on Windows XP. The name has to include. exe, unlike with the where command. where r. Tasks Searches for files whose name matches Task recursively from the current folder. Similar to dir b s Tasks. The r switch disables search in the folders in PATH. where. bat Outputs all. bat files in the current directory and in the directories that are in PATH. Thus, outputs all. bat files that you can run without entering their full path. where ls. bat As above, constraining also the beginning of the name of the. bat files. where ls As above, but with no constraint on the extension. Finds lsdisks. bat, lsmice. pl, and lsmnts. py if in the current directory or in the path. where. exe more Displays countless. exe and files in the path and in the current folder, including those in C:WindowsSystem32. where path:.bat Outputs. bat files in the path but not those in the current folder unless the current folder is in PATH. Instead of path, another environment variable containing a list of directories can be used. where windir:.exe Outputs. exe files found in the folder stated in WINDIR environment variable. where path:.bat windir:.exe A combination is possible. Outputs all files matching either of the two queries. where q. bat ampamp echo Found Suppresses both standard and error output, but sets the error level, enabling testing on it. The error level is set either way, with or without q. Starts Windows Management Instrumentation Command-line (WMIC), or with arguments given, passes the arguments as commands to WMIC. Not in Windows XP Home. For more, type wmic . wmic logicaldisk get caption, description Lists drives (disks) accessible under a drive letter, whether local hard drives, CD-ROM drives, removable flash drives, network drives or drives created using SUBST . wmic Control C Enters wmic and then interrupts it. A side effect is that the console buffer becomes very wide, and the screen becomes horizontally resizable with the mouse as a consequence. This is the result of wmic setting a high number of columns of the console, which you can verify using mode con . You can achieve a similar result by typing mode 1500 . See also MODE . XCOPY Edit Copies files and directories in a more advanced way than COPY. deprecated in Windows Vista and later. Type xcopy to learn more, including countless options. xcopy C:Windowssystem Copies all files, but not files in nested folders, from the source folder (C:Windowssystem) to the current folder. xcopy s i C:Windowssystem C:Windows-2system Copies all files and folders to any nesting depth (via s) from the source folder (C:Windowssystem) to C:Windows-2system, creating Windows-2system if it does not exist (via i). xcopy s i d:09-01-2014 C:Windowssystem C:Windows-2system As above, but copies only files changed on 1 September 2014 or later. Notice the use of the month-first convention even if you are on a non-US locale of Windows. xcopy L s i d:09-01-2014 C:Windowssystem C:Windows-2system As above, but in a test mode via L (list-only, output-only, display-only). Thus, does not do any actual copying, merely lists what would be copied. Windows XP - Command-line reference A-Z at microsoft Windows CMD Commands at ss64 -- licensed under Creative Commons Attribution-Non-Commercial-Share Alike 2.0 UK: England amp Wales1. and thus incompatible with CC-BY-SA used by Wikibooks The FreeDOS HTML Help at fdos. org -- a hypertext help system for FreeDOS commands, written in 20032004, available under the GNU Free Documentation License

No comments:

Post a Comment