FEEDJIT Live Traffic Feed

Do not click here plzzzzzzz....

Sudoku



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 between a time delay of 5 sec to 99 sec ?Below is an example of delay of 5 sec.

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



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.






 

0 comments

Post a Comment

Recent Posts

Archives

Recent Comments

Popular Posts