document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. REM Script pour mettre à jour un logiciel
  2. REM Test si OS 32/64 puis test la présence de fichier, si oui alors on lance le processus de desinstallation puis installation de la nouvelle version
  3. REM Enregistrement des DLL du logiciel
  4. REM Wackou
  5. REM contact@wackou.com
  6. REM www.wackou.com
  7. @echo off
  8. cls
  9. REM Initilisation variables
  10. REM Obtention de la date, indépendamment de la langue du poste
  11. FOR /f %%a in (\'WMIC OS GET LocalDateTime ^| find "."\') DO set DTS=%%a
  12. set DATE=%DTS:~0,4%-%DTS:~4,2%-%DTS:~6,2%_%DTS:~8,2%-%DTS:~10,2%
  13. REM Chemin où se trouve les fichiers
  14. set FOLDER=\\\\dc1.domain.local\\software
  15. REM Fichier de log, format COMPUTER_DOMAIN_USERNAME_20160119_15-31-14.log
  16. set LOG_FILE=%COMPUTERNAME%_%USERDOMAIN%_%USERNAME%_%DATE%.log
  17. REM Dossier où les logs seront enregistrés
  18. set LOG_FOLDER=%FOLDER%\\Logs
  19. REM Kit installation 32 Bits et 64 Bits
  20. set INSTALL64=%FOLDER%\\Setup\\install64
  21. set INSTALL32=%FOLDER%\\Setup\\install32
  22. REM Chemin de .DLL
  23. set DLL=%FOLDER%\\Setup\\DLL.dll
  24. REM Dossier contenant des fichiers de traduction
  25. set FILES=%FOLDER%\\Setup\\Files
  26. REM ID package MSI de l\'ancienne et la nouvelle version
  27. set ID_OLD_V={436F3D0A-3994-4883-B5C8-761B9071B7CA}
  28. set ID_NEW_V={451A01D7-7124-4F03-9E8D-B3B387D39F7F}
  29. REM Dossiers installation OS 64 Bits
  30. set DIR64=%ProgramFiles%\\software\\folder
  31. set DIR32=%ProgramFiles(x86)%\\software\\folder
  32. REM Dossier installation OS 32 Bits
  33. set DIR=%DIR64%
  34.  
  35. REM Debut du programme
  36. echo Script starting at %time:~0,2%-%time:~3,2%-%time:~6,2% >> "%LOG_FOLDER%\\%LOG_FILE%"
  37. REM Verification si 32 Bits ou 64 Bits
  38. if "%PROCESSOR_ARCHITECTURE%" == "x86" (
  39.     echo System is 32 bits >> "%LOG_FOLDER%\\%LOG_FILE%"
  40. goto CHK32
  41. ) else (
  42.     echo System is 64 bits >> "%LOG_FOLDER%\\%LOG_FILE%"
  43. goto CHK64
  44. )
  45. REM Verification version installée
  46. :CHK64
  47. if exist "%DIR32%\\file1.tlb" (
  48.     if exist "%DIR32%\\file2.tlb" (
  49.         if exist "%DIR64%\\file1.tlb" (
  50.             if exist "%DIR64%\\file2.tlb" (
  51.             REM Si tous les tests sont OK, alors c\'est la version 64 bits qui est présente
  52.             echo "File1 (32/64 Bits) and File2 (32/64 Bits) found" >> "%LOG_FOLDER%\\%LOG_FILE%"
  53.             goto INST64
  54.             )
  55.         )
  56.     )
  57. )
  58. goto NTD
  59. :CHK32
  60. if exist "%DIR%\\file1.tlb" (
  61.     if exist "%DIR%\\file2.tlb" (
  62.             REM Si tous les tests sont OK, alors c\'est la version 32 bits qui est présente
  63.             echo "File1 (32 Bits) and File2 (32 Bits) found" >> "%LOG_FOLDER%\\%LOG_FILE%"
  64.             goto INST32
  65.     )
  66. )
  67. goto NTD
  68. REM Installation 64 Bits
  69. :INST64
  70. echo Starting to uninstall old version (64 Bits) >> "%LOG_FOLDER%\\%LOG_FILE%"
  71. %windir%\\System32\\msiexec.exe /x %ID_OLD_V% /quiet
  72. echo Cleaning folder 32 Bits and 64 Bits >> "%LOG_FOLDER%\\%LOG_FILE%"
  73. DEL "%DIR32%\\*.*" /F /Q
  74. DEL "%DIR64%\\*.*" /F /Q
  75. echo Starting to install new version (64 Bits) >> "%LOG_FOLDER%\\%LOG_FILE%"
  76. %windir%\\System32\\msiexec.exe /i "%INSTALL64%\\Setup_Client.msi" /quiet
  77. if not exist "%ProgramFiles%\\software" mkdir "%ProgramFiles%\\software" >> "%LOG_FOLDER%\\%LOG_FILE%"
  78. if not exist "%ProgramFiles%\\software\\folder" mkdir "%ProgramFiles%\\software\\folder" >> "%LOG_FOLDER%\\%LOG_FILE%"
  79. echo Copy %DLL% to %DIR32% >> "%LOG_FOLDER%\\%LOG_FILE%"
  80. %windir%\\System32\\xcopy.exe "%DLL%" "%DIR32%" /h /c /k /q >> "%LOG_FOLDER%\\%LOG_FILE%"
  81. echo Copy %FILES% to %DIR32% >> "%LOG_FOLDER%\\%LOG_FILE%"
  82. %windir%\\System32\\xcopy.exe "%FILES%" "%DIR32%" /h /c /k /q /y /s >> "%LOG_FOLDER%\\%LOG_FILE%"
  83. echo Copy %DIR32% to %DIR64% >> "%LOG_FOLDER%\\%LOG_FILE%"
  84. %windir%\\System32\\xcopy.exe "%DIR32%" "%DIR64%" /h /e /c /k /q >> "%LOG_FOLDER%\\%LOG_FILE%"
  85. "%SystemRoot%\\Microsoft.NET\\Framework\\v2.0.50727\\regasm.exe" "%DIR64%\\DLL.dll" /codebase /silent >> "%LOG_FOLDER%\\%LOG_FILE%"
  86. "%SystemRoot%\\Microsoft.NET\\Framework\\v2.0.50727\\regasm.exe" "%DIR32%\\DLL.dll" /codebase /silent >> "%LOG_FOLDER%\\%LOG_FILE%"
  87. "%SystemRoot%\\Microsoft.NET\\Framework64\\v2.0.50727\\regasm.exe" "%DIR64%\\DLL2.dll" /codebase /silent >> "%LOG_FOLDER%\\%LOG_FILE%"
  88. "%SystemRoot%\\Microsoft.NET\\Framework64\\v2.0.50727\\regasm.exe" "%DIR32%\\DLL2.dll" /codebase /silent >> "%LOG_FOLDER%\\%LOG_FILE%"
  89. "%SystemRoot%\\Microsoft.NET\\Framework\\v2.0.50727\\regasm.exe" "%DIR64%\\DLL3.dll" /codebase /silent >> "%LOG_FOLDER%\\%LOG_FILE%"
  90. "%SystemRoot%\\Microsoft.NET\\Framework\\v2.0.50727\\regasm.exe" "%DIR32%\\DLL3.dll" /codebase /silent >> "%LOG_FOLDER%\\%LOG_FILE%"
  91. REM Creation du fichier d\'information pour les utilisateurs
  92. echo New version has been installed >> "%DIR32%\\000.txt"
  93. echo New version has been installed >> "%DIR64%\\000.txt"
  94. goto END
  95. REM Installation 32 Bits
  96. :INST32
  97. echo Starting to uninstall old version (32 Bits) >> "%LOG_FOLDER%\\%LOG_FILE%"
  98. %windir%\\System32\\msiexec.exe /x %ID_OLD_V% /quiet
  99. echo Cleaning folder 32 Bits >> "%LOG_FOLDER%\\%LOG_FILE%"
  100. REM Provoque une erreur en interactif car le dossier est déjà supprimé par la desinstallation
  101. REM DEL "%DIR%\\*.*" /F /Q
  102. echo Starting to install new version (32 Bits) >> "%LOG_FOLDER%\\%LOG_FILE%"
  103. %windir%\\System32\\msiexec.exe /i "%INSTALL32%\\Setup_Client.msi" /quiet
  104. echo Copy %DLL% to %DIR% >> "%LOG_FOLDER%\\%LOG_FILE%"
  105. %windir%\\System32\\xcopy.exe "%DLL%" "%DIR%" /h /c /k /q >> "%LOG_FOLDER%\\%LOG_FILE%"
  106. echo Copy %FILES% to %DIR% >> "%LOG_FOLDER%\\%LOG_FILE%"
  107. %windir%\\System32\\xcopy.exe "%FILES%" "%DIR%" /h /c /k /q /y /s >> "%LOG_FOLDER%\\%LOG_FILE%"
  108. "%SystemRoot%\\Microsoft.NET\\Framework\\v2.0.50727\\regasm.exe" "%DIR%\\DLL.dll" /codebase /silent >> "%LOG_FOLDER%\\%LOG_FILE%"
  109. "%SystemRoot%\\Microsoft.NET\\Framework\\v2.0.50727\\regasm.exe" "%DIR%\\DLL2.dll" /codebase /silent >> "%LOG_FOLDER%\\%LOG_FILE%"
  110. REM Creation du fichier d\'information pour les utilisateurs
  111. echo New version has been installed >> "%DIR%\\000.txt"
  112. goto END
  113. :NTD
  114. echo Nothing to do >> "%LOG_FOLDER%\\%LOG_FILE%"
  115. REM Test si nouvelle version installée
  116. for /f "tokens=2*" %%a in (\'REG QUERY "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\%ID_NEW_V%" /v displayversion 2^>nul\') do echo Version is %%b (New) >> "%LOG_FOLDER%\\%LOG_FILE%"
  117. REM Test si ancienne version installée
  118. for /f "tokens=2*" %%a in (\'REG QUERY "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\%ID_OLD_V%" /v displayversion 2^>nul\') do echo Version is %%b (Old) >> "%LOG_FOLDER%\\%LOG_FILE%"
  119. goto END
  120. :END
  121. echo Script ending at %time:~0,2%-%time:~3,2%-%time:~6,2% >> "%LOG_FOLDER%\\%LOG_FILE%"
');