@echo off rem *** MASSPROC.CMD: Process a lab or labs of computers. Called from *** rem *** within other files. *** rem rem INPUT VARIABLES: rem rem target rem computer, lab, or group of labs to process. rem rem conftext rem text specifying action to be taken, to go in confirmation rem dialog. rem rem OUTPUT VARIABLES: rem rem unc rem UNC path of next computer to be processed. rem rem exit rem if defined, no computers remain for processing. External rem batch program should end. rem rem INTERNAL VARIABLES: rem rem comp rem Next computer to be processed. rem rem lab rem The lab currently being processed. rem rem labproc rem If defined, a lab is in the middle of processing. rem rem confirm rem Determines whether to proceed with processing. (Asked rem once if user is processing many computers.) rem rem num rem Current computer number, in labs with sequentially numbered rem computers. rem rem Requires $length.cmd. rem *** MAIN PROCEDURE *** rem rem Call target's subroutine to get next value of output & rem internal variables. Note that "2> nul" catches the error output rem if target is blank or has no subroutine. call :%target% 2> nul rem If target is blank ( = use current computer) or if there is no rem subroutine for target ( = target is an individual computer), rem the call command returns an error. Thus, if there is an error, rem call the indie subroutine. if errorlevel 1 call :indie rem If the user hasn't yet confirmed the mass processing, ask. if not defined confirm call :ask-confirm rem Prefix external file output with current computer name (if rem defined; if not, no need for output). Also, set UNC variable. echo. if defined comp ( set unc=\\%comp% echo %comp%: ) rem If a lab has finished processing, and the only target was one rem lab, then end processing on next return. if not defined labproc ( if /i %target% EQU %lab% set target=exit ) goto :EOF rem *** MAIN PROCEDURE END *** rem ************************************************************************** rem *** META-LAB SUBROUTINES: Place subroutines for targets of more than *** rem *** one lab below this line. Follow the scripting pattern that the ALL *** rem *** subroutine lays out. *** rem ************************************************************************** rem *** ALL SUBROUTINE *** rem Moves through each lab one by one .... :all rem If a lab is not currently processing, set a new one to process. if defined labproc goto allcont if not defined lab set lab=undefined rem LAB NAME INSERTION POINT rem If you define a new lab, make sure to add it here by: rem 1. Changing the first line below to rem if lab==[new lab name] goto exit rem 2. Adding a new line just below: rem if lab==[previous lab name] set lab=[new lab name] rem rem Advanced N.B.: Notice how labs are listed in the reverse order of rem the order in which they're processed (i.e. Floor goes first, rem then 110, then Webster ...). if %lab%==econ goto exit if %lab%==lane set lab=econ if %lab%==media set lab=lane if %lab%==projection set lab=media if %lab%==webster set lab=projection if %lab%==110 set lab=webster if %lab%==floor set lab=110 if %lab%==undefined set lab=floor call :labprint :allcont rem Go to lab subroutine for processing, then pass back to main process. call :%lab% goto :EOF rem *** ALL END *** rem ************************************************************************** rem *** LAB SUBROUTINES: Below this line goes subroutines for when the *** rem *** target is one lab only. If you add a lab, make sure to add it to *** rem *** ALL and any meta-lab subroutines that should include it. Use FLOOR *** rem *** as a template for numerically named computers; use PROJECTION as a *** rem *** template for computer names without a numerical connection. *** rem ************************************************************************** rem *** FLOOR SUBROUTINE *** :floor rem If first time processing, define labproc & reset num. if not defined labproc ( set labproc=Y set lab=floor set num=0 ) set /a num=%num% + 1 if %num% lss 10 ( set comp=floor-pc-0%num% ) else ( set comp=floor-pc-%num% ) rem If last computer, undefine labproc. if %comp% EQU floor-pc-21 set labproc= goto :EOF rem *** END FLOOR *** rem *** 110 SUBROUTINE *** :110 if not defined labproc ( set labproc=Y set lab=110 set num=0 ) set /a num=%num% + 1 set comp=110-pc-%num% if %comp%==110-pc-9 set labproc= goto :EOF rem *** END 110 *** rem *** WEBSTER SUBROUTINE *** :webster if not defined labproc ( set labproc=Y set lab=webster set num=0 ) set /a num=%num% + 1 if %num% lss 10 ( set comp=webster-0%num% ) else ( set comp=webster-%num% ) if %comp%==webster-21 set labproc= goto :EOF rem *** END WEBSTER *** rem *** PROJECTION SUBROUTINE *** :Projection if not defined labproc ( set labproc=Y set lab=projection set comp=undefined ) if %comp%==converse-207 set comp=converse-209 if %comp%==webster-101 set comp=converse-207 if %comp%==webster-217 set comp=webster-101 if %comp%==webster-220 set comp=webster-217 if %comp%==barrett-4 set comp=webster-220 if %comp%==barrett-6 set comp=barrett-4 if %comp%==chapin-203 set comp=barrett-6 if %comp%==merrill-2 set comp=chapin-203 if %comp%==merrill-3 set comp=merrill-2 if %comp%==merrill-4 set comp=merrill-3 if %comp%==merrill-131 set comp=merrill-4 if %comp%==stirn set comp=merrill-131 if /i %comp%==undefined set comp=stirn if %comp%==converse-209 set labproc= goto :EOF rem *** END PROJECTION *** rem *** MEDIA SUBROUTINE *** :media if not defined labproc ( set labproc=Y set lab=media set comp=undefined ) if %comp%==media-45 set comp=media-46 if %comp%==media-44 set comp=media-45 if %comp%==media-39 set comp=media-44 if %comp%==media-38 set comp=media-39 if %comp%==media-37 set comp=media-38 if %comp%==media-32 set comp=media-37 if %comp%==media-31 set comp=media-32 if %comp%==media-30 set comp=media-31 if %comp%==media-26 set comp=media-30 if %comp%==media25 set comp=media-26 if %comp%==media24 set comp=media25 if %comp%==media19 set comp=media24 if %comp%==media-18 set comp=media19 if %comp%==media17 set comp=media-18 if %comp%==undefined set comp=media17 if %comp%==media-46 set labproc= goto :EOF rem *** END MEDIA *** rem *** LANE SUBROUTINE *** :lane if not defined labproc ( set labproc=Y set lab=lane set num=0 ) set /a num=%num% + 1 if %num% lss 10 ( set comp=lane0%num% ) else ( set comp=lane%num% ) if %comp%==lane09 set labproc= goto :EOF rem *** END LANE *** rem *** ECON SUBROUTINE *** :Econ if not defined labproc ( set labproc=Y set lab=econ set num=0 ) set /a num=%num% + 1 set comp=econ-%num% if %comp%==econ-4 set labproc= goto :EOF rem *** END ECON *** rem *** INDIE SUBROUTINE *** rem For individual computers (specified by target, or target blank). :indie rem Confirms action for user (since it's only one computer). set confirm=Y set comp=%target% rem Sets target as EXIT for the next time through. set target=exit goto :EOF rem *** END INDIE *** rem ************************************************************************** rem *** OTHER SUBROUTINES: All lab and meta-lab subroutines above this *** rem *** point, please. *** rem ************************************************************************** rem *** CONFIRM SUBROUTINE *** rem If user is processing several computers, asks if she's sure. rem If not, exits immediately. :ask-confirm if /i %target% EQU all ( choice.exe /c:YN Are you sure you wish to %conftext% every public computer ) else ( choice.exe /c:YN Are you sure you wish to %conftext% all %target% computers ) if %errorlevel%==1 ( set confirm=Y ) else goto exit goto :EOF rem *** CONFIRM END *** rem *** LABPRINT SUBROUTINE *** rem Print name of lab as it begins processing. Fancy-schmancy dashes rem around lab name courtesy of JSI Inc. batch files. :labprint call $length.cmd %lab% set i=0 set dash= :loop if %i% LSS %$len% ( set dash=%dash%- set /a i=%i% + 1 goto loop ) echo. echo %dash% echo %lab% echo %dash% goto :EOF rem *** LABPRINT END *** rem *** EXIT ROUTINE: Exits out of subroutine & sets exit variable for external batch file. *** :exit set exit=Y set comp= set errorlevel=0 goto :EOF rem *** EXIT END ***