To create the CALC.BAT batch file, follow the instructions below:
- Open the Notepad, by typing "NOTEPAD.EXE" and press the Enter key in the Run... command.
- Select the text below and Copy it (Ctrl-C) from your browser window, then switch to the Notepad application and paste (Ctrl-V) the text into it.
- Save the file (Ctrl-S) as 'C:\WINDOWS\CALC.BAT'. (This allows you to run the command from anywhere).
- Then close the Notepad application.
:: Name: MS-DOS Calculator
:: Description: Perform quick calculations from the MS-DOS prompt.
:: Author: Jason Savitt
:: Version: 1.01
:: Web Site: http://windowstipoftheday.blogspot.com/ also visit
:: Notes: - Requires Windows XP, 2003 or higher, although it may run
:: on Windows NT 4.0 and 2000 (not tested).
:: - Place the file in the %WinDir% (i.e.: C:\Windows)
:: to make it available from any where on your system.
rem Creates the equation from the passed parameter from the command line.
if "%1" == "" goto DispHelp
if "%1" == "" goto DispEqu
rem If the equation is empty, then it displays help
rem Performs the equation and displays the results
set /a Results=%Equation%
echo %Equation% = %Results%
rem Display help screen
echo The command line calculator supports the following operators, in
echo decreasing order of precedence:
echo ^(^) - grouping
echo ^! ^~ ^- - unary operators
echo ^* ^/ %% - arithmetic operators
echo ^+ ^- - arithmetic operators
echo , - expression separator
echo For example:
echo - calc 5+5
echo - calc (5-5)*10
echo - calc 20/5
To use the calculator, open the MS-DOS prompt then type "calc 5 * 5" (or whatever else you want) and press the Enter key. To get calculator Help, just type "calc" and press key Enter key.
The command line calculator supports the following operators, in
decreasing order of precedence:
() - grouping
! ~ - - unary operators
* / % - arithmetic operators
+ - - arithmetic operators
, - expression separator
- calc 5 + 5
- calc (5 - 5) * 10
- calc 20/5
Note: This batch has only been tested on Windows XP, although it should work on Windows NT4 or 2000. It will not work on Windows 95/98/ME, the MS-DOS prompt doesn't support the necessary functions need in order for it to work.