Win NT ".BAT" CODE


o The following is a simple BAT file that when run will show
  some good examples of BATCH options for WIN95 and NT DOS (NOT REGULAR DOS)
=======================================================
@ECHO OFF
GOTO bypassem
#d# Author: Randy Risher     Date: 06/30/1998
#d#
#d# This represents a "self documenting" feature. You can extract
#d# JUST the lines with "#d#" when at the dos prompt via
#d#       FIND/I "#D#" THISFILE.BAT    (dos WIN)
#d#       FINDSTR/I "#D#" THISFILE.BAT (NT)
#d# (Other REM will NOT appear)
#d#
#d# FOR THE ACTUAL CODE FOLLOWING:
#d# o The CLS clears the screen
#d# o The TITLE sets the window title
#d# o The E C H O. displays a blank line
#d# o The "echo (small circle character)" causes a BEEP. It was
#d#   inserted via WordPerfect using the "ctrl-G" combination, then
#d#   "Ctrl-F5" to save as a DOS file.
#d# o Use can use EDIT with ctrl/p then ctrl/g also
#d# o The first 2 IF statements enable a HELP. The check on variable
#d#   number 0 is if the command and the switch were together
#d#   (NO SPACE)
#d# o The 1st check on variable 1 is for if there was a space between
#d#   the command and the switch
#d# o The 2nd variable 1 check is if NO variable was given
#d# o The 3rd variable 1 check controls what to do if the file is NOT
#d#   found
#d# o The PAUSE causes a prompt to appear
#d# o Paragraph names are CaSe SeNsItIvE, so if the GOTO name
#d#   is UPPERCASE, so MUST the :NAME entry.
#d# o Paragraph names max is 8 digits with truncation at 8 digits
#d# ----------------------------------------------------------------------------------------------------
:bypassem
CLS
TITLE Running %0
ECHO         o This is an EXAMPLE batch file
ECHO.
ECHO         o To get self documentation, enter
ECHO                FIND/I "#d#" %0     (if DOS or WIN)
ECHO                FINDSTR/I "#d#" %0  (if NT)
ECHO.
ECHO         o To exit at any time press "Ctrl" and "C" together
ECHO.
ECHO         o The NEXT two lines enable a doslike HELP switch
ECHO         o The line AFTER senses if a parameter was passed
PAUSE
IF "%1"=="/?" GOTO helpem
IF %1.==. GOTO novar
IF NOT EXIST %1 GOTO nofile
GOTO doem

:novar
ECHO.
ECHO.
ECHO o
ECHO                   ERROR: you GOTTA supply a file
ECHO            o Sample message for running without a variable
ECHO            o Try re-running with THIS files name (%0)
ECHO                THEN AGAIN with a filename that does NOT exist
PAUSE
GOTO endem

:nofile
ECHO.
ECHO.
ECHO o
ECHO            ERROR: file %1 was NOT found
ECHO            (sample error message)
ECHO . . . this allows a tailored PAUSE message
PAUSE>NUL:
GOTO endem

:helpem
ECHO.
ECHO.
ECHO                   THIS IS THE   H E L P    AREA
ECHO                   GOT FROM THE /? PARAMETER
PAUSE
GOTO endem

:doem
ECHO.
ECHO.
ECHO                 THESE LINES WOULD BE THE ACTUAL
ECHO                 FUNCTION THIS BATCH FILE WAS TO 
ECHO                 PERFORM
ECHO.
PAUSE

:endem
GOTO bypend
#d# Setting screen colors does NOT use same as regular DOS
#d# Rather you can ONLY set the color ONCE 
#d# For Screen Background (S) and Text (T) via
#d# COLOR ST where
#d#    0 black        1 blue        2 green 
#d#    3 aqua         4 red         5 purple
#d#    6 yellow       7 white       8 gray
#d#    9 lt.blue      A lt.green    B lt.aqua
#d#    C lt.red       D lt.purple   e lt.yellow
#d#    F Bright White
#d# -------------------------------------------------------------------------------------------------
:bypend
ECHO             S E T T I N G   S C R E E N   C O L O R S
ECHO.
ECHO COLOR ST where
ECHO    0 black        1 blue        2 green 
ECHO    3 aqua         4 red         5 purple
ECHO    6 yellow       7 white       8 gray
ECHO    9 lt.blue      A lt.green    B lt.aqua
ECHO    C lt.red       D lt.purple   e lt.yellow
ECHO    F Bright White
color DE 

Return to Randys HOME PAGE
Created Jun 30, 1998 ~ Updated Jul 22, 2003
© 1998 R.D.RISHER