for %%f in (*.block) do set blockName=%%~nf
if "%BlockName%"=="" set BlockName=[Block name not found]

if not defined log set log=c:\hp\bin\logs
if not exist %log%\PicMov md %log%\PicMov
if not defined BlockLog goto COMMANDS
set CurrentLog=%BlockLog%


@echo	Copyright (c) Hewlett-Packard Development Company L.P., 2001-2007 			> %CurrentLog%
@echo	****************************************************************
@echo		Summer '07  									>> %CurrentLog%
@echo		install.cmd 									>> %CurrentLog%
@echo		PictureMover 1.7.0.10								>> %CurrentLog%
@echo		Drop date:  29Jan2007								>> %CurrentLog%
@echo		Langs: 										>> %CurrentLog%
@echo		Default Lang: ENGLISH   							>> %CurrentLog%
@echo		
@echo		
@echo		  
@echo	Block Creation Date:			 						>> %CurrentLog%
@echo	***********************************************************				>> %CurrentLog%
REM	Notes:
REM
@echo	*********************************************************** 				>> %CurrentLog%
@echo	The current Environment:								>> %CurrentLog%
Set 												>> %CurrentLog%
@echo ************************************************************************** 		>> %CurrentLog%
REM
REM	Revisions:
REM		23 Jan:  Initial block and build, v.1.7.13
REM		24 Jan:  build v.1.7.07: fixes card slot issue		
REM		29 Jan:  build v.1.7.10: final version for testing
REM		15 Feb:  build v.1.7.13: US, + En in Canada		
REM		
REM		

REM	********************************************************************************* 
REM		PIPE THE BLOCK NAME TO THE LOG FILE....
REM	********************************************************************************* 
@echo	"BLOCK INSTALLATION ":  installing  %BlockName% 					>> "%CurrentLog%" 


REM	********************************************************************************* 
REM		SINCE WE ARE DATE/TIME STAMPING, NOTE WHEN ACTUAL INSTALLATION ACTIVITY BEGINS...
REM	********************************************************************************* 

@echo 	%date% %time% "DETERMINE INSTALL MODE ": Is this an App Recovery mode? 			>> %CurrentLog%
@echo	%date% %time% "DETERMINE INSTALL MODE ": AppRecovery install is no different for %BlockName% >> %CurrentLog%
@echo	%date% %time% "ERROR LEVEL ": error level = %ERRORLEVEL% 				>> %CurrentLog%

@echo	%date% %time% "BEGIN PACKAGE INSTALLATION ": Launching silent install.		 	>> %CurrentLog%
if "%execfile%"=="" goto EXLINE
start /w %execfile%
@echo	%date% %time% "ERROR LEVEL ": error level = %ERRORLEVEL% 				>> %CurrentLog%
if %ERRORLEVEL% GEQ 1 goto BLOCKFAIL								>> %CurrentLog%


goto END


:APPRECOV
set CurrentLog=%BlockREinstall%
@echo	%date% %time% "APP RECOVERY MODE ": Beginning Application Recovery for %BlockName%	>> %CurrentLog%
@echo	**************************************************************************** 		>> %CurrentLog%
if "%execfile%"=="" goto EXLINE
start /w %execfile%
@echo	%date% %time% "ERROR LEVEL ": error level = %ERRORLEVEL% 				>> %CurrentLog%
if %ERRORLEVEL% GEQ 1 goto BLOCKFAIL								>> %CurrentLog%


:END

@echo	%date% %time% "END PROCESS ": the %BlockName% block has installed successfully. 	>> %CurrentLog%
@echo		*********************************************************************** 	>> %CurrentLog%
EXIT /b

REM	*************************************************************************
REM	*			ERROR TRAPS					*
REM	*************************************************************************

:COMMANDS
@echo Commands not running. If no other errors, type INSTALL at next prompt.
call c:\hp\bin\commands /LW:lg.ini
if %ERRORLEVEL% GEQ 1 goto FATALERROR
exit


:EXLINE
@echo ************************************************************************** 		>> %CurrentLog%
@echo %date% %time% "BLOCKFAIL ERROR ":  EXECFILE variable empty. Installation not successful. >> %CurrentLog%
@echo ************************************************************************** 		>> %CurrentLog%
exit 

:BLOCKFAIL
@echo ************************************************************************** 		>> %CurrentLog%
@echo %date% %time% "ERROR LEVEL ": error level = %ERRORLEVEL% >> %CurrentLog%
@echo %date% %time% "BLOCKFAIL ERROR ":  Block installation terminated prematurely. Installation not successful. >> %CurrentLog%
@echo ************************************************************************** 		>> %CurrentLog%
exit 

:FILECOPYFAIL
@echo %date% %time% "FILE COPY ERROR ": file copy failed in %BlockName%. Notify component owner. >> %CurrentLog%
exit /b

:MSIINSTALLERROR
@echo %date% %time% "MSI INSTALL ERROR ": Error Lever = %ErrorLevel% 				>> %CurrentLog%
@echo %date% %time% "MSI INSTALL ERROR ": notify %BlockName% component owner 			>> %CurrentLog%
@echo %date% %time% "MSI INSTALL ERROR ":  Block installation terminated prematurely. Installation not successful. >> %CurrentLog%
@echo ************************************************************************** 		>> %CurrentLog%
exit 

:FATALERROR
@echo %date% %time% "FATAL ERROR ": Error Lever = %ErrorLevel% 
@echo %date% %time% "FATAL ERROR ":  Commands not running.
@echo %date% %time% "FATAL ERROR ":  either Commands or HPBI or both are missing. 
@echo %date% %time% "FATAL ERROR ":  copy these files to the hp\bin folder before continuing.
@echo %date% %time% "FATAL ERROR ":  If launching manually, run commands first.
@echo **************************************************************************
pause 
exit
