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

cd %mySrc%\msworks
if NOT exist works8.msi (
   set myError=Works8.msi is missing
   goto error
)

::Try a reinstall first, if error try a full install
msiexec /femsu %mySrc%\MSWORKS\WORKS8.MSI /QN /Le %block%\works.log ALLUSERS=1 DISABLEROLLBACK=1 NO_IE=1 MEDIAPACKAGEPATH=MSWORKS

if errorlevel 1 msiexec /I %mySrc%\MSWORKS\WORKS8.MSI /QN /Le %block%\works.log ALLUSERS=1 DISABLEROLLBACK=1 NO_IE=1 MEDIAPACKAGEPATH=MSWORKS

cd %block%
if NOT exist works.log (
   set myError=Log file not found
   goto error
)
type works.log | find /i "error"
if NOT errorlevel 1 (
   set myError=Log file contains an error
   goto error
)

if "%PlaceOnDesktop%"=="1" (
   xcopy /y "%common programs%"\"%myTaskLauncher%" c:\hp\dtshortcuts\
   if errorlevel 1 (
      set myError=Failed to xcopy /y "%common programs%"\"%myTaskLauncher%" c:\hp\dtshortcuts\
      goto error
   )
)

reg add HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\%worksProductCode% /t REG_DWORD /v "NoModify" /d "1" /f
if errorlevel 1 (
   set myError=Failed to suppress 'modify'
   goto error
)

reg add HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\%worksProductCode% /t REG_DWORD /v "NoRepair" /d "1" /f
if errorlevel 1 (
   set myError=Failed to suppress 'repair'
   goto error
)

::Remove the language Bar
regedit /s %mySrc%\msworks\LanguageBarOff.reg
if errorlevel 1 (
   set myError=Failed to suppress Language Bar.
   goto error
)

goto :EOF

:error
if exist c:\blocks\allblocks (
   echo %blockName%: %myError%. >> c:\blocks\error.txt
   if exist c:\hp\tmp\works.log type c:\hp\tmp\works.log >> c:\blocks\error.txt
)
