::ллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллл ::ллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллл ::ллл ллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллл ::ллл START OF SCRIPT ллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллл ::ллл ллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллл ::ллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллл ::ллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллл ::л ::л !!! SCRIPT BEST VIEWED USING THE "TERMINAL" FONT !!! ::л ::л Script Name: mifMaker.cmd ::л Author: John W. Nelson ::л ::л Inputs: Parameter Max Size Description ::л -------------------------------------------------------------------------------- ::л param1 = FILENAME NONE Unique name for the MIF file. Must end in .MIF ::л param2 = COMPANY 64 bytes Manufacturer or publisher, such as Microsoft. ::л param3 = PRODUCT 64 bytes Product or program name, such as Office 2000. ::л param4 = VERSION 64 bytes Version of the product, such as 8.0a. ::л param5 = SERIALNO 64 bytes Serial number of the product. ::л param6 = MESSAGE 128 bytes Descriptive message about the status of the installation which is added to the programs status message. ::л param7 = STATUS N/A (BOOLEAN) Install status. Set to TRUE for success; otherwise FALSE. ::л ::л (FOLLOWING NOT IMPLEMENTED) ::л param8 = REBOOT N/A (BOOLEAN) Informs SMS that the program it launched has finished and executed a reboot. TRUE or FALSE. ::л Outputs: status mif in temp directory ::л Dependencies: SMS Client should be installed ::л ::л Description: Makes an installation status mif and puts it in ::л the temp directory ::л ::ллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллл ::ллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллл ::л INITIALIZATION л л ::лллллллллллллллллл л :: if variable ECHO is set, then use its value for the echo statement :: this is for debugging purposes. To show each line, just set ECHO to ON :: otherwise set ECHO to nothing and it will run normally @if not [%ECHO%]==[] (@echo %echo%) else (@echo off) :: make sure any variables we set in the script are local only to this script :: and don't persist after the script is done. setlocal :: clear screen and put up a banner telling what we're doing. cls echo. echo ---------------------------------------- echo mifMaker: Installation Status Mif Maker echo ---------------------------------------- echo. echo * INITIALIZING :: set generic variables set thisDir=%~dp0 set thisFile=%0 set thisFileBase=%~n0 set thisFileExt=%~x0 set mifDir=%temp% set mifLocale=00000409 set indent= :: make sure there are 7 parameters echo * CHECKING PARAMETERS... if [%7]==[] ( call :syntaxError "Parameter(s) missing. There must be exactly 7 parameters." goto :end ) :: get parameters into variables set mif=%mifDir%\%~1 set mifCompany=%~2 set mifProduct=%~3 set mifVersion=%~4 set mifSerial=%~5 set mifMessage=%~6 :: convert mifStatus parameter from TRUE/FALSE/1/0/SUCCESS/FAILED to "Success" or "Failed" :: also, make sure it's one of those values otherwise throw syntax error. if /I [%~7]==[TRUE] ( set mifStatus=Success ) else ( if /I [%~7]==[1] ( set mifStatus=Success ) else ( if /I [%~7]==[SUCCESS] ( set mifStatus=Success ) else ( if /I [%~7]==[FALSE] ( set mifStatus=Failed ) else ( if /I [%~7]==[0] ( set mifStatus=Failed ) else ( if /I [%~7]==[FAILED] ( set mifStatus=Failed ) else ( call :syntaxError "Install Status needs to be TRUE/FALSE/1/0/SUCCESS/FAILED" goto :end ) ) ) ) ) ) echo %indent%PARAMETERS SEEM TO BE OK echo %indent%DONE INITIALIZING echo. goto :main ::лллллллллллллллллллллл л ::л END INITIALIZATION л л ::ллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллл ::ллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллл ::л MAIN л л ::лллллллл л :main echo * RUNNING MAIN SCRIPT :: write the install status mif header (start of the mif and componentID group) to mif. echo * WRITING MIF HEADER... call :mifHeader "%mif%" echo %indent%DONE. :: increment the attribute IDs each time and write attributes to componentID group of MIF echo * WRITING COMPONENTID ATTRIBUTES... call :mifAttribute "%mif%" "Manufacturer" 1 "STRING(64)" "%mifCompany%" call :mifAttribute "%mif%" "Product" 2 "STRING(64)" "%mifProduct%" call :mifAttribute "%mif%" "Version" 3 "STRING(64)" "%mifVersion%" call :mifAttribute "%mif%" "Locale" 4 "STRING(16)" "00000409" call :mifAttribute "%mif%" "Serial Number" 5 "STRING(64)" "%mifSerial%" call :mifAttribute "%mif%" "Installation" 6 "STRING(64)" "DateTime" echo %indent%DONE. :: write the middle (end of the componentID group and the header of the InstallStatus group) of the MIF echo * WRITING COMPONENTID FOOTER AND INSTALLSTATUS GROUP HEADER... call :mifMiddle "%mif%" echo %indent%DONE. :: reset attribute ID and write the InstallStatus attributes to the MIF echo * WRITING INSTALLSTATUS ATTRIBUTES... call :mifAttribute "%mif%" "Status" 1 "STRING(32)" "%mifStatus%" call :mifAttribute "%mif%" "Description" 2 "STRING(128)" "%mifMessage%" echo %indent%DONE. :: write the install status mif footer (end of installstatus group and end of whole mif) to the MIF. echo * WRITING MIF FOOTER... call :mifFooter "%mif%" echo %indent%DONE. echo %indent%MAIN SCRIPT DONE. echo. echo MIF "%mif%" HAS BEEN CREATED. :: sleep for a few seconds so you can read the messages. ::call :waitasec 10 goto :end ::лллллллллллл л ::л END MAIN л л ::ллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллл ::ллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллл ::л SYNTAXERROR л л ::ллллллллллллллл л :: :: INPUTS: Error Message (string passed in describing the error) :: :: Description: Writes syntax message to screen including what we think went :: wrong and some possible steps to fix it. :: :syntaxError echo. echo SYNTAX ERROR: %~1 echo. echo SYNTAX: echo %indent%mifMaker (mif) (company) (product) (version) (serial) (message) (status) echo. echo Some Notes: echo %indent%1) Count the parameters to make sure there's exactly 7. echo %indent%2) Check their values to make sure they're what you want. echo %indent%3) Try surrounding your parameters in double-quotes. echo %indent%4) Instead of omitting a param you don't want, use "". echo. echo Parameter Max Size Description echo ------------------------------------------------------------------------------ echo MIF N/A Unique name for the MIF file. Must end in .MIF echo COMPANY 64 bytes Manufacturer or publisher, such as Microsoft. echo PRODUCT 64 bytes Product or program name, such as Office 2000. echo VERSION 64 bytes Version of the product, such as 8.0a. echo SERIAL 64 bytes Serial number of the product. echo MESSAGE 128 bytes Description of the install progress/status. echo STATUS N/A TRUE, 1 or SUCCESS if install succeeded echo FALSE, 0 or FAILED if install failed. echo. goto :EOF ::ллллллллллллллллллл л ::л END SYNTAXERROR л л ::ллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллл ::ллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллл ::л MIFHEADER л л ::ллллллллллллл л :: :: INPUTS: MIF Path (full mif file name with path) :: :: Description: Writes the beginning status MIF header info to the passed- :: in MIF filename. :: :mifHeader if [%1]==[] ( echo MIFHEADER WARNING: The MIF filename was not passed in! Cannot write header. goto :end ) echo START COMPONENT>"%~1" echo NAME = "WORKSTATION">>"%~1" echo %indent%START GROUP>>"%~1" echo %indent%%indent%NAME = "ComponentID">>"%~1" echo %indent%%indent%ID = 1 >>"%~1" echo %indent%%indent%CLASS = "DMTF|ComponentID|1.0">>"%~1" goto :EOF ::ллллллллллллллллл л ::л END MIFHEADER л л ::ллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллл ::ллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллл ::л MIFATTRIBUTE л л ::лллллллллллллллл л :: :: INPUTS: MIFPath (full mif file name with path) :: NAME (name of the attribute) :: ID (integer ID number of the attribute, all attr in group must be unique) :: TYPE (type of data we're entering) :: VALUE (data value given to this attribute name) :: :: Description: Writes the beginning status MIF header info to the passed- :: in MIF filename. :: :mifAttribute echo %indent% START ATTRIBUTE>>"%~1" echo %indent% NAME = "%~2">>"%~1" echo %indent% ID = %~3 >>"%~1" echo %indent% ACCESS = READ-ONLY>>"%~1" echo %indent% STORAGE = SPECIFIC>>"%~1" echo %indent% TYPE = %~4>>"%~1" echo %indent% VALUE = "%~5">>"%~1" echo %indent% END ATTRIBUTE>>"%~1" goto :EOF ::лллллллллллллллллллл л ::л END MIFATTRIBUTE л л ::ллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллл ::ллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллл ::л MIFMIDDLE л л ::ллллллллллллл л :: :: INPUTS: MIF Path (full mif file name with path) :: :: Description: Writes the middle status MIF text info to the passed-in MIF :: :mifMiddle echo %indent%END GROUP>>"%~1" echo %indent%START GROUP>>"%~1" echo %indent%%indent%NAME = "InstallStatus">>"%~1" echo %indent%%indent%ID = 2 >>"%~1" echo %indent%%indent%CLASS = "MICROSOFT|JOBSTATUS|1.0">>"%~1" goto :EOF ::ллллллллллллллллл л ::л END MIFMIDDLE л л ::ллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллл ::ллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллл ::л MIFFOOTER л л ::ллллллллллллл л :: :: INPUTS: MIF Path (full mif file name with path) :: :: Description: Writes the beginning status MIF header info to the passed- :: in MIF filename. :: :mifFooter echo %indent%END GROUP>>"%~1" echo END COMPONENT>>"%~1" goto :EOF ::ллллллллллллллллл л ::л END MIFFOOTER л л ::ллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллл ::ллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллл ::л WAITASEC л л ::лллллллллллл л :: :: INPUTS: SECONDS (number of seconds to wait) :: :: Description: Waits a specified number of seconds. Just like a sleep. :: :waitASec for /L %%W IN (1,1,%~1) DO ( ping -n 2 -l 1 127.0.0.1>nul ) goto :EOF ::лллллллллллллллл л ::л END WAITASEC л л ::ллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллл :end ::ллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллл ::ллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллл ::ллл ллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллл ::ллл END OF SCRIPT ллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллл ::ллл ллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллл ::ллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллл ::ллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллл