user377419
user377419

Reputation: 4989

Help with Batch Files?

What are batch files useful for? They just seem to be used to make viruses and other things...but it seems like shell scripting to me.

Whats the uses for batch files?

Upvotes: 1

Views: 260

Answers (6)

ender_scythe
ender_scythe

Reputation: 508

The entire purpose of a Batch script is to execute several DOS commands in sequence:

echo Hello!
set var=7
echo I just made var=%var%!
pause

It was invented in MS-DOS for user simplicity to execute things they did all the time, the most notable thing being "AUTOEXEC.BAT" which started once the command interpreter started, people would add things like:

echo Welcome to my computer!

or

cd C:\Games\

To make it quicker to access their games or whatever they needed.

Upvotes: 0

Ankur pandey
Ankur pandey

Reputation: 61

Batch file is "a computer file containing a list of instructions to be carried out in turn." We have been studying since childhood that computer is a dummy machine and this is a method of instructing a dummy machine.

For example :-

If you want to instruct the system to create a folder with random name then type ,

@echo off
md %random%

Creating Batch files enables you to execute several line of CMD commands in a single file.

For example :-

@echo off
md %random%
tasklist
Pause

Upvotes: 0

cmd
cmd

Reputation: 583

Batch Files are extremely useful. They are super easy to learn as well. you can make them do things on startup like say that a program wants to open itself and wont close even from taskman.exe you can force it to shutoff without warning.

or you could make games and ineractive things like i like to do.

i have a Messenger that i made with fully customizable colors and accounts with account management and servers.

But you probably dont trust me enough for you to download it.

But yea they are pretty useful.

Upvotes: 0

Leniel Maccaferri
Leniel Maccaferri

Reputation: 102368

From Batch file article at Wikipedia:

Batch files are useful for running a sequence of executables automatically and are often used by system administrators to automate tedious processes. Unix-like operating systems (such as Linux) have a similar type of file called a shell script.

A simple example:

for /f "tokens=* delims=" %%i in ('dir /s /b /a:d *svn') do (  rd /s /q "%%i")

If you save the above line in a file called ClearSVNFolders.bat and after that execute a double click you'll delete every folder named svn that resides inside a root path...

You automated the whole process. You could easily spend hours doing the above task if you had a deep root directory, that is, one containing thousands of folders. :)

Upvotes: 2

Marcelo Cantos
Marcelo Cantos

Reputation: 185852

You could use them for shell scripting. :-P

Of course, they kind of suck at that, compared to bash (or perl/python/tcl). But if you're on Windows, it's a one-horse race unless you want to install cygwin or msys and battle with Unix/Windows incompatibilities.

Upvotes: 0

geofflane
geofflane

Reputation: 2691

Batch files are the Windows equivalent of a Unix shell script. So you can use them to automate things.

Upvotes: 0

Related Questions