The magazine of the Melbourne PC User Group

Using SET To Sort Out a Configuration Nightmare
Stephen Davey

As a system supervisor, one of the areas I am responsible for, has 7 PC's used for wordprocessing, graphics and pageakeup. Normally it would be a simple task to have each machine set up exactly the same with identical directory structures etc. Unfortunately, computing may have meant to be that simple but it seldom is. As our company has slowly but steadily grown, so too has our "fleet" of PC's - and as a result of trying to purchase the best value/performance units available at the time, we now have an interesting range of machines ranging from the most humble and aging XT (640kB, 4MHz, 360kB floppy) to powerful 37MHz units with 4MB ram and 300MB discs. No two machines are exactly the same, which makes keeping track of each unit's proper configuration a minor nightmare. 

However, with the help of the DOS command SET I now have a menu and file structure that is identical on each machine yet allows each to run different software or different configurations.

SET and the ENVIRONMENT 

DOS maintains a small area in RAM called the Environment. The SET command can be used to store information in this area that can be used later by programs or batch files. 

Using SET commands in batch files can be useful for those running anything from 2 to 20 or so machines and works basically like this: 

All machines have a minimum standard directory structure of say:

c:\DOS (DOS program files of any version) 
c:\MENU (to hold all menu text and batch files) 
c:\UTILITY (useful utilities)

Each machine then has its own unique name (eg in the example that follows, 7 machines called m1, m2, m3 etc - or Fred, Mabel and Nelly if you choose!). Each has its own unique CONFIG.SYS file. 

(Note - throughout this article the actual .start of a batch file is indicated by its name in bold. Any comments about a line follow straight after the line, or group of lines, in italic and in brackets and ire of course not part of the file itself. DOS commands are in capitals.) 

All machines use an AUTOEXEC.BAT file that is identical with the exception of one line which is used to SET the "machine" name. eg?

AUTOEXEC.BAT

@ECHO OFF

(Turns off the screen display so that only the required items are actually displayed on the .screen. Some early versions of DOS do not accept the @ so just use ECHO OFF)

REM Only one of the followinq 
REM should NOT have a colon 
REM in front of the line 
:SET machine == m1
:SET machine == m2 
SET machine == m3 
:SET machine == m4 
:SET machine == m5
:SET machine == m6
:SET machine == m7
Start 

(Here we have one line for each machine, however all but the line referring to this particular machine have been disabled by the use of the : in front of the line. In this case we want to call this machine "m3" . Note that the word "machine" is not important - you could use "unit", "PC" etc and you could also use any names other that: ml, m2, etc. The last line runs the Start.Bat file)

Now all the machines use identical START.BAT, MENU.BAT and application batch files. Each of these files knows which machine it is running on (and therefore what particular configuration to use) by getting the machine name from the SET environment. For example the START.BAT file is used as an additional autoexec.bat file to set up those "once a day" type things like mouse and print spoolers -eg

START.BAT

@ECHO OFF 
PATHl=C:\DOS;C:\MENU;C:\UiILITY 
IF %machine% == m1 c:\mouse\qmouse /2/2 
IF %machine% == m3 c:\mouse\qmouse /3/1 
IF %machine% == m4 c:\mouse\qmouse /2/2

(Most of our machines use the Microsoft MOUSE.SYS in the CONFIG.SYS file but machines m1 & m4 use a "Quick Mouse" confgured as a Microsoft mouse on com port 2 while machine m3 uses the Quick Mouse as a Mouse Systems mouse on com port 1. Having set the "machine" name in the AUTOEXEC.BAT file this START.BAT file looks to see if "machine" equals "m1 " and if it does then carries out the instruction, if not it checks the next line for "machine" equals "m3", etc.)

IF %machine% == m1 PATH=%PATH%;C:\windows
IF %machine% == m2 PATH=%PATH%;C:\windows
IF %machine% == m7 PATH=%PATH%;C:\win386

(The 3 machines m1, m2 & m7 are the only ones that use Windows and their PATH command is amended accordingly. eg machine m7 path is changed from "c:\dos; c:\menu; c:\utility", set at the start of the file, to "c:\dos; c:\menu; c:\utility; c:\win386.")

IF %machine% == m1 c:\utility\loadfont

(This line is ignored unless running on the machine called ml where it runs the LOADFONT.BAT file which downloads fonts to the laser printer)

IF %machine% == m5 GOTO end
IF %machine% == m6 GOTO end

(Because the two machines m5 and m6 are NOT connected to the printer the GOTO ,statement takes them to the end of the file and avoids the next lines.)

c:\utility\ltorg
menu

(The first line starts the LTORQ print spooler program for all machines except m5 & m, and the second rins the MENU.BAT file.)

MENU.BAT

@ECHO OFF 
ECHO Machine %machine%

(This line prints "Machine m3", "Machine m4" etc at the top of the screen depending on what the value of "machine" is SET at.)

TYPE C:\menu\menu.txt

(This line displays your menu "screen display" on the screen and as this is the end of the menu.bat file, the DOS prompt will then be displayed ready for the next DOS command of batch file name. The MENU.TXT file can be a simple ASCII file of perhaps just 3 or 4 lines, eg

V - Ventura 
W - Word Processing 
C - Corel Draw

or it could be a complex colour ANSI file. For each menu choice you would either need to make a batch file of the corresponding letter, in this case V.BAT, W.BAT and C.BAT, or combine them into one with the use of some utility that will allow you to make a choice such as ASK, BE, YORN, INPUT etc.)

Each individual batch file could look something like this -

V.BAT

C:
CD c:\ventura
COPY ideal.inf vp.inf COPY
COPY idealx.inf vpprof.inf

(These two lines replaces the last used configuration parameters for Ventura and Ventura Professional Extension with our default setup.)

IF %machine% == m1 drvrmrgr vpprof %1 /s=sd_vvga2.vga/m=32/x=d:/x=e: 
IF %machine% == m2 drvrmrgr vp %1 /s=sd_herc5.ega/m=32/x=d: 
IF %machine% == m3 drvrmrgr vpprof %1 /s=sd _vga2.vga/m=32/x=d:/x=e:/x=f:/x=g: 
IF %machine% == m4 drvrmrgr vpprof %1 /s=sd_vvga2.vga/m=22/x=d:/x=e:/x=f:/X=g: IF %machine% == m5 drvrmrgr vp %1 /s=sd_herc5.ega/m=32/x=D:/x=e:/x=f:/x=g: 
IF %machine% == m6 drvrmrgr vp %1 /s=sd_herc5.ega/m=32/X=D: 
IF %machine% == m7 drvrmrgr vpprof %1 /s=sd vvga2.vga/m=32/x=d:/x=e:/x=f:
            /x=h:7x=i: /x=j:/x=k:/x=1:
menu

(Each line here is checked with the "machine" name stored with the SET command and if it matches then invokes the Ventura "drvrmrgr" program with the correct parameters such as screen driver, mouse and disk drives available, and then returns to the menu.bat file when the Ventura program finishes.)

S.BAT

IF %machine% == m7 GOTO startscan

(If the machine IS m7 then the batch file jumps to the "startscan" label.)

ECHO *****************************
ECHO Sorry, but this option is not 
ECHO available on this machine 
ECHO *****************************
PAUSE 
menu

(Because m7 is the only machine with the scanner, all other ma-chines will display this "not available" message then return to the menu.)

:startscan 
d: 
CD\scan 
win386 :D:\scan\esplus 
menu

(These lines change to the correct disc and directory and run the scan program on the m7 machine, and then returns to the menu, and is the end of the S.BAT file.)

W.Bat

IF %machine% == ml G0T0 m1wstar 
IF %machine% == m2 GOTO m1wstar
IF %machine% == m3 GOTO m3wstar 
IF %machine% == m4 GOTO m4msword 
IF %machine% == m5 GOTO m1wstar 
IF %machine% == m6 GOTO m1wstar 
IF %machine% == m7 GOTO m7msword

(As we use both Wordstar and Microsoft Word, these lines direct each machine to the required program label)

:mlwsstar 
c: 
cd\ws4 
wf
ws 
GOTO end 
:m3wsstar 
d: 
cd\ws4 
wf
ws
GOTO end 
:m4msword 
c: 
cd c:\word\work
c:\word\word
GOTO end 
:m7msword 
d: 
cd d:\word\work
d:\word\word
GOTO end

(Each of the above options changes to the correct disc and directory for the work files, runs the correct program, and then goes to the "end" label where the batch file returns to the menu.bat file.)

:end
cd\ 
menu 
(End of W.Bat file)

While your particular machines will, of course, use different programs, configurations and directories, this system allows you to use menu and configuration files that are identical on all machines. This means that less backups and easier damage control should the vital files on one machine be destroyed or damaged.

Reprinted from the August 1990 issue of PC Update, the magazine of Melbourne PC User Group, Australia

[About Melbourne PC User Group]