Image

Image

Search This Blog

Sunday, November 03, 2013

AfterMarket Updater

That's what happen when the devs are not thinking how to update their product :D
No other comments! 
(Thou I should mention the trick that I've done in order to put the quotes in the right place )

@echo off
rem Update Logixxxx 2.0 
rem 2013/06/06 sorin@xxxxxxxx.com - rebuild the whole thing
rem 2014/03/04 sorin@xxxxxxxx.com - cleanup version detection
rem this script must be executed with administrative rights
cls

setlocal enableextensions enabledelayedexpansion

set source=\\192.168.35.214\Partage\LOGIxxxx_2_0_Mises_a_Jour
set exclude=%source%\deploy\exclude.txt
set destination32='%programfiles%\Groupe xxxxdure\Logixxxx 2.0'
set ver32="%destination32:'=%\version.txt"
set destination32="%destination32:'=%\"
set destination86='%programfiles(x86)%\Groupe xxxxdure\Logixxxx 2.0'
set ver86="%destination86:'=%\version.txt"
set destination86="%destination86:'=%\"
set /P version=<%source%\version.txt
if not defined version set version=0
set log=Logixxxx - 

if exist %destination32% (
 set log=!log! Found in Program Files.
  for /f "delims=" %%a in ('type %ver32%') do set actualversion=%%a
  if NOT "!actualversion!"=="%version%" (
  set log=!log! Update from version !actualversion! to %version%.
  xcopy %source% %destination32% /Y /S /E /H /R /I /C /EXCLUDE:%exclude%
  if exist "%allusersprofile%\Desktop" xcopy "%source%\deploy\MAJ - LOGIxxxx.lnk" "%allusersprofile%\Desktop\" /Y
  if exist "%allusersprofile%\Bureau" xcopy "%source%\deploy\MAJ - LOGIxxxx.lnk" "%allusersprofile%\Bureau\" /Y
  if exist "%public%\Desktop" xcopy "%source%\deploy\MAJ - LOGIxxxx.lnk" "%public%\Desktop\" /Y
  ) else (
  set log=!log! Same Version. No need to update.
  goto END
 )
 goto LOG
) else ( 
  set log=!log! Not found in %destination32%.
if exist %destination86% (
 set log=!log! Found in Program Files x86.
 for /f "delims=" %%i in ('type %ver86%') do set actualvers=%%i
 if NOT "!actualvers!"=="%version%" (
  set log=!log! Update from version !actualvers! to %version%.
  xcopy %source% %destination86% /Y /S /E /H /R /I /C /EXCLUDE:%exclude%
  if exist "%allusersprofile%\Desktop" xcopy "%source%\deploy\MAJ - LOGIxxxx.lnk" "%allusersprofile%\Desktop\" /Y
  if exist "%allusersprofile%\Bureau" xcopy "%source%\deploy\MAJ - LOGIxxxx.lnk" "%allusersprofile%\Bureau\" /Y
  if exist "%public%\Desktop" xcopy "%source%\deploy\MAJ - LOGIxxxx.lnk" "%public%\Desktop\" /Y
  ) else (
  set log=!log! Same Version. No need to update.
  goto END
 )
 goto LOG
) else ( 
set log=!log! Not found in %destination86%.
) )
set log=!log! Nothing to update.

:LOG
echo
echo %date% %time% - %computername%. !log! >> %source%\deploy\UpdateLogs.txt

:END
echo !log!
ping -n 2 1.1.1.1 >nul
endlocal

No comments:

Post a Comment

Blog Archive