Batch script is a basic scripting language that runs on any Windows or MS DOS operating system, the functions are based on the commands for the command lines in these operating systems. Also its pretty cool! Making a game with this script is not that difficult, all it takes is a little time and creativity. Please note: in order for this project to work properly, you will need Windows 2000 or higher, as this will not work in earlier versions of Windows or MS DOS, since MS DOS is not compatible with modern batch scripts.

Steps

  1. 1
    Copy the file in Notepad.
  2. Advertisement
TITLE Calculator
ECHO OFF
CLS
ECHO -by Ravi Raturi, XI B Nirmal Deepmala Pagarani Public School Shyampur, Rishikesh
:TOP
color 3f
Cls
ECHO ----------------------------------------------------
ECHO[
ECHO                    DOS CALCULATOR
ECHO[
ECHO ----------------------------------------------------
ECHO[
ECHO[
ECHO    + = Sum
ECHO[
ECHO    - = Sub
ECHO[
ECHO    / = Division
ECHO[
ECHO    * = Multiply
ECHO[
ECHO    ~ = Exit
ECHO[
ECHO[
ECHO ----------------------------------------------------
ECHO[
SET/P ch=" Enter Symbol "
IF %ch% EQU + GOTO:SUM
IF %ch% EQU - GOTO:SUB
IF %ch% EQU / GOTO:DIV
IF %ch% EQU * GOTO:MUL
IF %ch% EQU ~ GOTO:EXI
IF %ch% GTR . GOTO:Hel
:SUM
CLS
ECHO ---------------------------------------------------
ECHO[
ECHO                         SUM
ECHO[
ECHO ---------------------------------------------------
ECHO[
set /p A=" Enter First Number = "
ECHO[
set /p B=" Enter Second Number = "
SET /A C=A+B
ECHO[
ECHO ---------------------------------------------------
ECHO %A%+%B%=%C%
PAUSE
GOTO:TOP
:SUB
CLS
ECHO ---------------------------------------------------
ECHO[
ECHO                     SUBTRACTION
ECHO[
ECHO ---------------------------------------------------
ECHO[
set /p A=" Enter First Number = "
ECHO[
set /p B=" Enter Second Number = "
SET /A C=A-B
ECHO[
ECHO ---------------------------------------------------
ECHO %A%-%B%=%C%
PAUSE
GOTO:TOP
:DIV
CLS
ECHO ----------------------------------------------------
ECHO[
ECHO                      DIVISION
ECHO[
ECHO -----------------------------------------------------
ECHO[
set /p A=" Enter First Number = "
ECHO[
set /p B=" Enter Second Number = "
SET /A C=A/B
ECHO[
ECHO -----------------------------------------------------
ECHO %A%/%B%=%C%
PAUSE
GOTO:TOP
:MUL
CLS
ECHO ---------------------------------------------------
ECHO[
ECHO                    MULTIPICATION
ECHO[
ECHO ----------------------------------------------------
ECHO[
set /p A=" Enter First Number = "
ECHO[
set /p B=" Enter Second Number = "
SET /A C=A*B
ECHO[
ECHO ----------------------------------------------------
ECHO %A%*%B%=%C%
PAUSE
GOTO:TOP
:EXI
EXIT
:HEL
CLS
ECHO --------------------------------------------------
ECHO[
ECHO                         HELP
ECHO[
ECHO --------------------------------------------------
ECHO Press (+) For Sum, (-) For Sub, (/) for Division, (*) for Multiply.
PAUSE
GOTO:TOP
  1. 1
    Save the file as something like Calculator.bat. The best folder place for this file is in your My Documents(any OS besides Vista) or Documents(Windows Vista) folder.
  2. 2
    Double click on file and enjoy.
  3. Advertisement

Community Q&A

  • Question
    Can this work even if I don't have an internet connection?
    Community Answer
    Community Answer
    Yes, everything you need is self-contained within the operating system.
  • Question
    Why when I double click it, it just closes quickly?
    Eli Overholtzer
    Eli Overholtzer
    Community Answer
    This may because you did not rename the file .txt to a .bat. If it is not .bat, it will not work.
Advertisement

Warnings

  • Never put any MS DOS commands in the echo command, as they will be carried out. Remember that everything displayed by the command line is an echo!
    ⧼thumbs_response⧽
  • Never put any MS DOS commands in the text files that are typed out to the console. Text files solve some problems, such as the slashes and stars, but commands in them will still be carried out by the system.
    ⧼thumbs_response⧽
  • It is often times said that it is illegal to send batch files over the internet. By no means is this true, but be aware of the fact that you may get in trouble for sending dangerous batch files over the internet(e.g.: batch files that crash the computer, delete vital system files, etc...). They are not called viruses, but they are still harmful and you can get in serious trouble for them.
    ⧼thumbs_response⧽
Advertisement

About This Article

wikiHow is a “wiki,” similar to Wikipedia, which means that many of our articles are co-written by multiple authors. To create this article, volunteer authors worked to edit and improve it over time. This article has been viewed 54,965 times.
How helpful is this?
Co-authors: 8
Updated: May 31, 2019
Views: 54,965
Categories: Programming
Advertisement