Nov 22, 2009
Pages: 1, 2, 3, 4

Batch Files - Tutorial

free web hosting
Open Discussion & Free Web Hosting > Computers & Tech > How-To's and Tutorials > Programming > MISC (not applicable to above Programming Categories)

Batch Files - Tutorial

warbird
Very nice tutorial, I tried it and I've a lot of use from it. I now use it for some routines that always annoyed me to do manually. Anyway just very nice. wink.gif
-=jeroen=-

Comment/Reply (w/o sign-up)

xboxrulz
nice tutorial, I really needed it for launching Java applications on Windows (tongue.gif). However, I prefer the BASH Shell Scripts.

For example, I can do system service startup and shutdowns with shell scripts without typing the long command lines over and over again.

CODE

echo "Please enter the root password to restart the network"
su -c "/etc/init.d/network restart"
echo "Done!"


*This code only works on SuSE Linux.

xboxrulz

Comment/Reply (w/o sign-up)

souradipm
Wow! Another programming language! biggrin.gif Really, batch files could act as a DOS programming language. Good simple tutorial as well. I might write my own batch file. I think I know how it works now. But what does the command 'rem' do?

~souradipm

Comment/Reply (w/o sign-up)

HellFire121
I remember making a batch file to start a service and a few programs when windows started because one program would only run when the other was started and it made it easier, it's also a great way to learn windows shell commands and practise windows scripting.
In my experiences the dos prompt will actually hold more power than the simple explorer.exe which makes it a very handy tool if you know how to use it

-HellFire

Comment/Reply (w/o sign-up)

masterio
I like batch since it can save my time for start/shutdown my server like Apache, MySQL and hMailServer. I use this batch because I have limited RAM so if all of these service run when Windows start-up it can slow down the start-up time.

Here's the batch that I've user, I name it myserver.bat

CODE
@echo off

set me=myserver.bat - (c) copyright 2006 - Rio Astamal

if "%1"=="start" goto start
if "%1"=="stop" goto stop
if "%1"=="" goto usage

:start
echo Starting server application server...
net start apache2
net start mysql
net start hmailserver
goto quit

:stop
echo sutting down server application...

net stop apache2
net stop hmailserver
net stop mysql
goto quit

:usage
echo usage:
echo   myserver start/stop
echo -------------------------
echo note: start to activate the server and stop to shutdown the server.
echo .
echo .
echo %me%
goto quit

:quit
if "%2"=="yes" (
  exit
)


myserver.bat have 2 argument, the first one is for start/stop the server and the second argument (optional) wheter user want to quit the command prompt or not.

 

 

 


Comment/Reply (w/o sign-up)

Quatrux
I wouldn't call batch files a programming language, but just command files working in console.. why not a programming language? because of mathematics it is able to do, it only recognizes simple numbers like 1,2,3,4.. [-9999999999;+999999999]; And the tools which can compile your bat file to exe is quite ridiculous, usually the compiled version takes 10 times more space than source biggrin.gif but thats kind of quite normal.

Say REXX is a more advanced command file scripting, which is capable of much more.. so I could call it (REXX) a scripting language..

Comment/Reply (w/o sign-up)

toby
I love this, I often need to end about 5 processes, delete one or two folders, and start three programs.

1. In one folder I want to delete, one of the files is now obsolete, but Windows still loves it. Can I avoid it or delete it through batch files?

2. How do I end a process in these?

Comment/Reply (w/o sign-up)

Kardus
Batch files were great. I remember when I was younger I used to try and teach myself how they worked by editing them/making my own. Typically they are now used for installers, etc. Most virus scanners DO however pick up non-system batch files, as they can be programmed for malicious purposes.

I remember my friend didn't want his younger brother on his computer, so he made a batch file that shut down the computer when executed. Lets just say he put it in his brother's startup folder and his brother was pretty pissed.

They can, however, be used to complete simple everyday tasks without extensive programming knowledge.

Comment/Reply (w/o sign-up)

.WonderGuy6
Ha good one smile.gif

Comment/Reply (w/o sign-up)

FeedBacker
Problem
Batch Files

Trying to add this into a batch file I am working on, but it is not really working for me, it just closes out the second it comes in..Any help?

@echo off
Echo test
Pause >nul
Echo

===============================================================================
Echo � �============================================�
� � /\ /\ �
Echo � � | | | | �
� � | | | | �
Echo � � | | | | �
� � | | | | �
Echo � � / \ �
� � | O O | �
Echo � � | | �
� � | <__> | �
Echo � � | | �
� � \_______/________________ �
Echo � � | \ �
� � \ \ �
Echo � � \________ \ �
� � / | �
Echo � � / ________|******* �
� � ___ __/ / |******** �
Echo � � | / |********* �
� � | / |******** �
Echo � � |______________/___________|******* �
�
Echo � �=========================================�


============================================================================�

Pause >nul



-Scott

Comment/Reply (w/o sign-up)


Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

This textarea will convert to Rich-Text automatically (IE, Firefox, Chrome)

Pages: 1, 2, 3, 4

See Also,

*SIMILAR VIDEOS*
Searching Video's for batch, files, tutorial
advertisement



Batch Files - Tutorial

Affordable Web Hosting, Low cost Web Hosting - ComputingHost.com