For example:
Code:
@echo off
:GetAbrv.bat - Type "getabrv /?" (without the quotes) for instructions.
if (%1)==(?) goto Syntax
if (%1)==(/?) goto Syntax
goto Begin
:Syntax
echo.
echo Name: GetAbrv.bat
echo.
echo Purpose: Takes the first three characters of an environment variable
echo named "computername" and puts them in an environment variable
echo named "computerabrv".
echo.
echo Syntax: GetAbrv [/?]
echo.
echo Requires: 1) MS-DOS 5.00-6.22 or Windows 95/98/Me,
echo.
echo 2) an existing environment variable named "computername"
echo containing at least three characters,
echo.
echo 3) the program CHOICE.EXE (anywhere in the PATH),
echo.
echo 4) and at least 17 bytes of free space in the environment
echo to hold the new environment variable "computerabrv".
echo.
goto End
:Begin
if (%computername%)==() goto Error
echo;;|choice/c:;%computername%; "set computerabrv=">~.bat
call ~.bat
echo set computerabrv=%%2%%3%%4>~.bat
call ~ %computerabrv%
:Display
echo computername=%computername%
echo computerabrv=%computerabrv%
:Cleanup
del ~.bat
set cmdline=
goto End
:Error
echo.
echo Error: Environment variable "computername" does not exist.
goto Syntax
:End