WSWAP

Version 1.01
November 1994
Shareware


INTRODUCTION

Do you find yourself altering your windows configuration files/settings depending upon how you've booted your PC?  Although Microsoft with DOS 6 has given us a menuing facility for Config.sys, there is nothing to help manage possible variations in System.ini and Win.ini.  This utility addresses that particular need, as well as others.


HOW IT WORKS

This program works for any text file that supports comments.  This includes .INI files (which use a semicolon ";") batch files (which use the reserved word "REM") and others.  In these cases, optional lines are surrounded by comments which look as such:
	<COMMENT-KEY> SWAP KEYWORD OPTION(s)
		[optional line(s)]
	<COMMENT-KEY> SWAP KEYWORD END

	NB - all tokens are case-sensitive, and SWAP and END must be in uppercase.

When WSWAP is executed on such files, a keyword is supplied on the command line which if not matched results in the optional line(s) being commented out.  If there is a match, then the optional lines are uncommented if they are commented, or left unaltered if no comment prefix is found.  Where multiple options are possible for the same keyword, they can be specified one after the other with the END line being the last line.  Such an example from System.ini follows:
	;
	[boot]
	; SWAP NET NetWare
	; network.drv=NETWARE.DRV
	; SWAP NET Vines VinesAsync
	; network.drv=VINES.DRV
	; SWAP NET END

In this case the keyword is NET, and depending upon which option we select (NetWare, Vines or VinesAsync) we will end up with the appropriate network.drv driver loaded.  We might have our Config.sys file present us with a menu to load either Novell or Banyan network protocol drivers, and then depending upon which is selected our Windows environment will be set correctly to load the corresponding windows drivers (by using the %CONFIG% variable that DOS supplies us).


SOME MORE EXAMPLES

Variable Protocol.ini or Net.cfg

You can setup your NIC card configuration files with settings for different card combinations.  Altering your NIC card can then be made as simple as running a batch file to select the new card.

PROTOCOL.INI file
;
[PROTOCOL MANAGER]
	DRIVERNAME = PROTMAN$

[VINES_XIF]
	DRIVERNAME = NDISBAN$
; SWAP NIC XIRCOMP1 XIRCOMP2 XIRCOMP3 XIRCOMCE XIRCOMCE_IBM
	BINDINGS   = XIRCOMNET
; SWAP NIC ETHPOCK
;	BINDINGS   = ETHPOCK
; SWAP NIC END

[XIRCOMNET]
	DRIVERNAME = XIRCOM$
; SWAP NIC XIRCOMCE
;  	IOADDRESS = 0x300
;  	INT = 5
;  	MEM = 0xD000
;  	IOWORDSIZE = 16
;  	SOCKET = 1
; SWAP NIC XIRCOMCE_IBM
 	IOADDRESS = 0x300
 	INT = 5
 	MEM = 0xD400
 	IOWORDSIZE = 16
 	SOCKET = 2
; SWAP NIC XIRCOMP1
; 	INTERRUPT=7
; 	PRINTERPORT=LPT1
; SWAP NIC XIRCOMP2 XIRCOMP3
; 	INTERRUPT=7
; SWAP NIC END


NIC.BAT
@echo off
cls
echo Changing NIC card settings to %1
pause
wswap NIC %1 \config.sys \autoexec.bat \ndis\protocol.ini \net.cfg


Batch files

You may want to vary the type of mouse driver used by the system.

MOUSE.BAT
REM
@echo off
REM SWAP MOUSE MSMOUSE
REM set mouse=C:\msmouse
REM C:\msmouse\mouse.exe
REM WSWAP MOUSE MS %Windows%\system.ini
REM SWAP MOUSE BALLPT
REM SET MOUSE=C:\BALLPT
REM C:\BALLPT\MOUSE
REM WSWAP MOUSE BALLPT %Windows%\system.ini
REM SWAP MOUSE DOS
SET MOUSE=C:\DOS
C:\DOS\MOUSE
WSWAP MOUSE DOS %Windows%\system.ini
REM SWAP MOUSE END

Then to select a different mouse driver, you'd type something like:
wswap MOUSE MS mouse.bat

Now whenever you run MOUSE.BAT, you'll get the right mouse driver for both DOS and Windows.


Smart CONFIG.SYS

Now your CONFIG.SYS files can remember the setting chosen during the last boot and make it the default for the next boot.  For example, in the office I want my network driver loaded (the default) but when at home I select a Standalone configuration and from that point on I want the default during reboots to be Standalone (until I return to the office).  This config file demonstrates this usage:

CONFIG.SYS

REM
[Menu]
MenuItem=Standalone
MenuItem=Vines
SubMenu FullMenu,--> Full Menu Selection
REM SWAP NET Vines
REM MenuDefault=Vines,5
REM SWAP NET Standalone
MenuDefault=Standalone,5
REM SWAP NET DEFAULT
REM MenuDefault=FullMenu
REM SWAP NET END

Now in my Autoexec.bat I place the line:
wswap NET %CONFIG% \config.sys

Note that the %CONFIG% variable is automatically set for you by DOS.


USAGE

	WSWAP KEYWORD SELECTION file_list

file_list is any number of file names seperated by spaces.  Each file can be prefixed by either the "+", "-" or "*" symbols which cause special processing to take place.  "+" will activate lines that match, but will not touch lines that do not, so that if other options are already active they will remain so (useful to add driver lines in .ini files).  For example, you may load a Vines driver in System.ini and then wish to activate a FTP TCP/IP driver in addition to the Vines driver.  Typing:
wswap NET Vines system.ini
wswap NET FTP's +system.ini

results in
; SWAP NET Vines VinesAsync
network.drv=VINES.DRV
; SWAP NET ENS
;      network.drv=ENSNETW.DRV
; SWAP NET FTP's
network.drv=PCTCPNET.DRV
; SWAP NET SunNFS
;      network.drv=PCNFS.DRV
; SWAP NET NONE DEFAULT
;      network.drv=
; SWAP NET END

Without using the "+" in front of system.ini on the second line, the Vines driver would be deactivated.

The "-" symbol does the reverse of "+" where it comments out the match and leaves the other choices unaltered.  Lastly, the "*" symbol will include the lines that match and DELETE the lines that do not match.  "*" is useful for "cleaning" the file (NB - if necessary make a copy of the original before doing this).

The word DEFAULT is a reserved selection option that will be chosen if none of the other options match.  It should be the last option listed, and can be combined with other valid options as shown in the above example (NONE and DEFAULT).  Typing "wswap NET NONE system.ini" and "wswap NET DOS system.ini" (i.e. DOS is not a valid match) will result in the "network.drv=" line being selected.


INPUT FILE FORMAT

The first line of any input files must contain the token id used for comments.  It will usually either be ";" or "REM" (without the quotes).  So the first line of your System.ini and Win.ini files should contain a single semi-colon and nothing else if its going to be used with WSWAP.

The comment token must be followed by either a space or tab character.  On identifier lines (where the SWAP KEYWORD is specified) the comment token should be followed by a space and then the word SWAP (in uppercase).


CREDITS

The initial idea for this program came from need and an earlier program, called WINSWAP, I found somewhere on a bulletin board.  It went part way to solving the particular problem I had - I just added some more bells and whistles.  I'm sorry that I can't personally give the author of that program credit for his idea - I've since lost the program.


MODIFICATION HISTORY

1.0	August 94 - Initial release to the public domain
1.01	November 94 - Minor changes to accompanying documentation


SUGGESTED CONTRIBUTIONS

Only joking - I don't want any money!  Instead this represents a small contribution to what is a huge library of public domain (& shareware) software, much of which I use.  So my hope is that I may have returned a favour to one of those many authors.

If you want to offer suggestions for possible improvements, send an email to:
	Skarra@Banyan.COM

Enjoy.
Steve Karra.