Showing posts with label Batch file tutorials. Show all posts
Showing posts with label Batch file tutorials. Show all posts

Tuesday, November 29, 2011

Batch Files:simple games

This is a nice video showing the application (advanced application) of batch files.....
It also gives you a better understanding of how batch files are written and how they work....
.......Enjoy......







Wednesday, November 23, 2011

Batch Files: getting started part IV

This is the part four of the series " Batch Files " , i though it will be nice to post a video on the application of batch files (just an example). The text about batch files i have posted before is quite boring (believe me, i know especially when you don't have a video to watch and do...) so it about time we saw some action.....check out this video i got from youtube, i decided to share it here for whoever is interested...
Enough text, lets watch....

Sunday, November 20, 2011

Batch Files:more on batch files

Hi everyone,
This are some commands you might find yourself using in a batch file....
the list is just to make you familiar with some commands...

For those of us who already know a little of MS-DOS commands, we will know that they are not case sensitive and just like all MS-DOS commands, all batch file commands are not case sensitive as well However, all commands listed below are in caps to help you identify what is a command and what is not.
@Does not echo back the text after the at symbol. This is most commonly used as @ECHO OFF to prevent any of the commands in the batch file from being displayed, just the information needed.
%1The percent followed by a numeric value, beginning with one, allows users to add variables within a batch file. The below line is an example of what can be used in a batch file. ECHO Hello %1
When the above one-line batch file is created, add your name after the batch file. For example, typing myname (being the name of the bat file) and then your name:
myname bob
would output:
Hello bob
Note: This can be extended to %2, %3, and so on.
::One of two ways of adding remarks into the batch file without displaying or executing that line when the batch file is run.

Friday, November 18, 2011

Batch Files: getting started part III

Now lets try to modify the first example a bit...i.e. make it more cooler, so this modified batch file example is going to list all the files in a folder and put the list in a new text file . We will use the directory command "dir" that you are already familiar with.
Open Notepad and enter the line "@echo off" (without quotes).
Next enter another line dir "C:\Program Files" > C:\list_of_program_files.txt(I'm assuming that your Program Files folder is on the C: drive). This will give us the two-line file @echo offdir "C:\Program Files" > C:\list_of_program_files.txt
 Now save this two-line file as "listprograms.bat" (without quotes) to some convenient location. Be sure that Notepad is saving as "All files" and not as a text file

  • Note that complete paths are used for files including the drive letter, even the files' extension is specified. 
  • Also note the quotes

Wednesday, November 16, 2011

Batch Files: getting started part 2


The first line in a batch file often consists of this command
   @echo off
By default, a batch file will display its commands as it runs. The purpose of writing this first command is to make sure the display is turned off. The command "echo off" turns off the display for the whole script, except for the "echo off" command itself. If you wish to make the turn off command apply to the echo command as well then you type the "at" sign "@" in front of the echo command
i.e. @echo off
It doesn't really affect the batch file whether you use "@echo off" or just "echo off" . The scripts we will discuss are very brief and omitting this line won't make any great difference. However, as a matter of good practice, it will be wise to enter it in our scripts, especially if the script is going to be a long one.
If you are familiar with  the commands used in CMD, one of them that we mostly use (or i use a lot) is the "dir" command, without the quotes...It lists all the files and folder in the present directory you are on...try it now
open command prompt,  to run command prompt >>
on windows XP click start...click run...and type cmd....OR go to accessories and click on cmd
on windows 7 just search for cmd and run it,
you will see the prompt below as your present directory if you installed to drive C: or something similar depending on your machine and where you installed your windows

C:\"your work-group e.g Users"\"your home folder">

now type in the dir command and a list of all the files and folders present there will be displayed...
the ones that have a <DIR> in front of them are folders while the rest with extensions e.g .txt .exe .bat are files...

The first batch file example i want to introduce will just

Sunday, November 13, 2011

Batch Files: getting started


Hi, today i wanna start a new series of topics on writing of a batch file to run on a windows machine....A lot of people run windows, so i felt this is a good way to get more from your window's machine.
Batch files allow MS-DOS and Microsoft Windows users to create a lists of commands to run one after the other once the batch file has been execute. Think of them as a to-do list of all what you want your computer to do.
For example, you could write a batch file to run frequently run commands, deleting a series of files, moving files, etc, you get the idea...just basic understanding of MS-DOS commands
is needed to write a batch file.
A good example of a batch file for someone who is more familiar with Windows or the MacOS is to think of a batch file as a shortcut in Windows or an icon on the MacOS. Much like a shortcut, batch files could be used to run one or more commands or programs through the command line.
Another example of a very well known batch file is the autoexec.bat, which is a simple boot file loaded each time the computer is loaded on MS-DOS and early Windows computers. This batch file contained all the necessary commands and programs used to run MS-DOS and Windows each time the computer booted.
As you can see the extension of a batch file is .bat or .cmd, files of this type are recognized and executed through an interface (sometimes called a shell) provided by a system file called the command interpreter. In Windows XP/ Vista the command interpreter is the file cmd.exe. The large assortment of versatile commands available in Windows XP/Vista/7 makes batch files a powerful tool.
Constructing a batch file consists of nothing more than opening any text editor like the accessory Notepad, entering some lines containing commands, and saving the file with an extension BAT or CMD. (The CMD extension is limited to newer Windows systems and is not recognized in Windows 9x/Me systems. In Windows XP, Vista, and 7 there is little practical difference between the two extensions.)

  * Don't use Wordpad or Word unless you are very careful to save all files in pure text format. The commands themselves are often quite simple and there is no need to learn a programming language. Those who wish can explore the intricacies that are available with branching and looping, just follow the links. I will be discussing straightforward application of batch files to everyday tasks. The focus will be on saving time and effort for some routine stuff like system housekeeping and simple file management.
....so stay tuned....