The magazine of the Melbourne PC User Group

Batch files and call waiting
Michael Marquart
micm@melbpc.org.au

If you're not running *.BAT files almost as often as you run *.EXE or *.COM files then you aren't making batch files work for you!

What is a batch file?

A batch file is simply a number of lines that are read by the operating system, one at a time, and that perform a function. It is, in effect, an interpreted program!

Batch Files are created with a text editor or a word processor that can save in ASCII (or "DOS") format.

Wait... don't let that scare you off to the next article!. A batch file can be as simple as

:: CALL ME X.BAT
@C:\XTGOLD\XTGOLD


which executes my favourite file manager.

Without having all of XTreeGold in your PATH, which slows down the response of your PC a tad, all you need is the batch file in a directory that is included in your PATH statement. This could be C:\DOS - mine lives in C:\BAT - then all you do to use it is to type X and press Enter.

Supposing that XTGOLD is in the C:\XTGOLD subdirectory, this batch file will log the current drive that you are working on, and will also start up with the cursor on the current directory.

Despite the limited vocabulary available to batch files, it is surprising what is possible with a little lateral thinking.

Where does this lead?

Hands up those who have call waiting installed, and use a modem? Oh, a lot of you! Did you know that you could be in trouble if you receive a call while you have call waiting enabled and are using your modem? You will most likely lose the connection, due to your modem becoming "overwhelmed" by the tones that indicate another call.

Well do I have a batch file for you!

It disables call waiting, executes your communications program and reenables call waiting after you exit from your comms program.

:: CALLWAIT.BAT
::
:: Disables call waiting, runs
:: comms program and reenables
:: call waiting. Tested with
:: MS-DOS 6.22, but should
:: work from V3.3 onward.
::
:: Place in your communications
:: program subdirectory
:: (Folder)
::
:: The line "SET PORT=2" tells
:: the batch file which serial
:: port to use, and must be
:: set to the COM port that you
:: are using for your modem: :: i.e. com1=1 or com2=2 or
:: com3=3 or com4=4
::
:: If you use an external
:: Modem, then it must be
:: switched on before executing
:: this batch file!
::
@ECHO OFF
SET PORT=2
MODE COM%PORT%:2400,N,8,1>NUL
ECHO ATDT#43#,;H>COM%PORT%
::
:: Your COMM PROGRAM'S
:: EXECUTABLE FILENAME goes on
:: the next line (eg TM for
:: Telemate, TELIX for Telix)

MODE COM%PORT%:2400,N,8,1>NUL
ECHO ATDT*43#,;H>COM%PORT%
SET PORT=


A little explanation for those who wish it...

Every line that commences with "::" is ignored by the operating system and is not necessary to the operation of the batch file.

The command @ECHO OFF is in two parts; when the character @ precedes a command, it informs DOS not to display that command on the monitor before it is executed - ECHO OFF is similar, except it works for the rest of the batch file (or until an "echo on" command is processed).

So all @ECHO OFF means is "don't print this command or any command that comes after it" - simple?

The command SET PORT=2 makes an environment variable called PORT and gives it the string value "2".

Environment variables are kept in a small portion of memory. They are used to pass information between programs. In this case when the word PORT is used again, is enclosed within two percent signs (%PORT%), the value "2" is used in its place. The following command

MODE COM%PORT%:2400,N,8,1>NUL

becomes

MODE COM2:2400,N,8,1>NUL

when the batch file is run.

It uses MODE.COM that comes with DOS, and passes the options COM2:2400,N,8,1 to it, setting the serial port to a certain configuration, so that your modem will understand the command passed to it. Provided your modem supports 2400 bps this will work. The output from the MODE command would normally be seen on the screen, so we redirect it to the NUL device (a bottomless pit inside your PC) with NUL.

ECHO ATDT#43#,;H>COM%PORT%

This command sends (ECHOs) the modem command string ATDT#43#,;H to your modem. This tells the modem to pick up the phone, dial #43# using tones, then wait for a while before hanging up the phone - disabling call waiting.

:: Your COMM PROGRAM'S
:: EXECUTABLE FILENAME goes on
:: the next line (eg TM for
:: Telemate, TELIX for Telix)

Here is your chance to become a programmer! You have to ascertain the name of your communications program and enter it on the blank line, below the four lines above, in the batch file. (You know that it's not necessary to include the .EXE or .COM, don't you?)

Aside for Win95 users

I tried to create a shortcut in Win95 to this batch file, but Win95 simply started Hyperterminal and passed control back to the batch file, which re-enabled call waiting, all in one go!

For all Windows users

A partial solution to that is to include #43# in the prefix after your dialing string (i.e. after the ATDT in the setup for your comms program, which normally supports a prefix for the phone number) which would at least disable call waiting automatically.

You may wish to place the @ECHO OFF and SET PORT=?, and the commands following them, in a batch file that you can then execute to reenable call waiting via a Windows PIF file or shortcut.

MODE COM%PORT%:2400,N,8,1>NUL

This command is a replication of the same command as before, and serves the same purpose.

ECHO ATDT*43#,;H>COM%PORT%

As is this, with the exception that it dials *43# which turns call waiting back on again.

SET PORT=

This releases the memory used by the original SET PORT=2, and restores at least 5 bytes to the environment area, but it's neat and tidy, and necessary if you are low on environment space.

Well, that's it! As it stands, it defaults to COM2, and in use you should hear the tones dialed by your modem prior to, and after, your comms program. Happy Modeming, and see you in chat on the BBS!

Reprinted from the September 1996 issue of PC Update, the magazine of Melbourne PC User Group, Australia

[About Melbourne PC User Group]