You could also assign command line parameters to the variables:
@echo off
set name=%1 set address=%2 set city=%3
echo %name% echo %address% echo %city%
|
The command line usually sees the space as a parameter delimiter, use double quotes " to make it ingore the spaces: test.bat "Joe Smith" "1 Main Street" "Helltown".
Something important to remember about SET, it actaully creates a variable name in the file So if you enter SET NAME=Joe on the command line or in a batch file and then go to the command line and enter ECHO %NAME% the response will be Joe. Entering SET with no parameters will also show the whole list of SET variables. These will be erased when you reboot.
The power of command line switches
Most GUI programs have some kind of command line support which means you may automate their operation through batch files. For example, DOS does not have a built-in email sending function like
UNIX. However, using an installed email program like Outlook, you may "force feed" the program on the command line. Outlook examples:
outlook /c ipm.note will open a blank email,
outlook /c ipm.note /m msmith@yahoo.com will open a blank email with the indicated address,
outlook /c ipm.note /a myfile.doc attaches a file.
More outlook switches,
outlook programming.
An example using command line with
winzip.
The Windows Installation Catch-22
You have a new computer with a unformated hard drive, or a drive with only DOS loaded. You want to load Windows from a CD, but you can"t see the CD ROM from the DOS prompt. This is messy and can be screwed-up easily, luckily mistakes on this don"t cause permanent damage. If you"re lucky the CD ROM you have came with an installation disk(on floppy, of course). Putting this disk in and running the INSTALL.EXE or SETUP.EXE will install the drivers for you and alter the system files so you can load Windows from the CD ROM(Linux, by the way, has no problem with this!). If there is no INSTALL.EXE on the disk, you will have to edit lines in two files on your Windows 95 Boot/Install floppy disk. These files are: CONFIG.SYS and AUTOEXEC.BAT. Open these files for editing are look for lines that look like these:
REM DEVICE=CDROM.SYS /D:OEMCD001 |
And
REM C:\DOS\MSCDEX.EXE /D:OEMCD001 |
They may or may not be REMed out. You will need to change the "/D:OEMCD001" part of these lines to reflect the CD ROM that you have. For example if you have a Memorex it might be "/D:MSCD001". But be sure, check any manuals you might have lying around. If not, go to the manufacturer"s website and down load the installation files. You will also need to figure out which drive letter it will be. If you only have on hard disk, it will be "D:" as in "/D:MSCD001," if you have two hard drives, or your drive is in several partitions, it might be "E:" or "F:". So then the line would be "/E:MSCD001" or "/F:MSCD001"
The Final line in CONFIG.SYS might be like this:
DEVICE=C:\WINDOWS\SBIDE.SYS /D:MSCD001 /V /P:170,15 |