@echo off chcp 65001 >nul 2>&1 setlocal EnableDelayedExpansion title Copydev Imposition Tool — Installation :: Si le script plante ou sort anormalement, la fenetre reste ouverte if "%~1" neq "__started__" ( cmd /k "%~f0" __started__ %* exit /b ) set "APP_NAME=Copydev Imposition Tool" set "INSTALL_DIR=%LOCALAPPDATA%\CopydevImposingAcrobat" set "REPO_DIR=%INSTALL_DIR%\repo" set "GITEA_REPO=https://git.copydev.fr/jules/copydev-imposing-tool.git" set "GIT_URL=https://github.com/git-for-windows/git/releases/download/v2.47.1.windows.2/MinGit-2.47.1.2-64-bit.zip" :: ============================================================ :MENU cls echo ============================================================ echo %APP_NAME% echo ============================================================ echo. echo 1. Installer echo 2. Mettre a jour echo 3. Verifier l'installation echo 4. Lancer Acrobat echo 5. Desinstaller echo 6. Quitter echo. set "CHOIX=" set /p "CHOIX=Votre choix [1-6] : " if "%CHOIX%"=="1" goto INSTALL if "%CHOIX%"=="2" goto UPDATE if "%CHOIX%"=="3" goto VERIFIER if "%CHOIX%"=="4" goto LAUNCH if "%CHOIX%"=="5" goto UNINSTALL if "%CHOIX%"=="6" goto FIN echo Choix invalide. timeout /t 2 >nul goto MENU :: ============================================================ :: GIT (portable si absent du systeme) :: ============================================================ :TROUVER_GIT set "GIT_CMD=" where git >nul 2>&1 if %ERRORLEVEL%==0 ( set "GIT_CMD=git" exit /b 0 ) if exist "%INSTALL_DIR%\git\cmd\git.exe" ( set "GIT_CMD=%INSTALL_DIR%\git\cmd\git.exe" exit /b 0 ) echo Telechargement de Git portable... if not exist "%INSTALL_DIR%\temp" mkdir "%INSTALL_DIR%\temp" if not exist "%INSTALL_DIR%\git" mkdir "%INSTALL_DIR%\git" powershell -Command "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; Invoke-WebRequest -Uri '%GIT_URL%' -OutFile '%INSTALL_DIR%\temp\git.zip' -UseBasicParsing" if not exist "%INSTALL_DIR%\temp\git.zip" ( echo [ERREUR] Echec telechargement Git exit /b 1 ) powershell -Command "Expand-Archive -Force '%INSTALL_DIR%\temp\git.zip' '%INSTALL_DIR%\git'" del "%INSTALL_DIR%\temp\git.zip" 2>nul if not exist "%INSTALL_DIR%\git\cmd\git.exe" ( echo [ERREUR] git.exe introuvable apres extraction exit /b 1 ) set "GIT_CMD=%INSTALL_DIR%\git\cmd\git.exe" exit /b 0 :: ============================================================ :: Detection des dossiers JavaScripts d'Acrobat (un par version :: installee, ex: DC, 2020, 2024...). Cree le dossier si absent :: (ne necessite pas de droits admin : c'est sous %APPDATA%). :: ============================================================ :TROUVER_DOSSIERS_ACROBAT set "NB_DOSSIERS=0" if not exist "%APPDATA%\Adobe\Acrobat" ( exit /b 1 ) for /d %%D in ("%APPDATA%\Adobe\Acrobat\*") do ( if not exist "%%D\JavaScripts" mkdir "%%D\JavaScripts" set /a NB_DOSSIERS+=1 set "DOSSIER_JS_!NB_DOSSIERS!=%%D\JavaScripts" ) if "%NB_DOSSIERS%"=="0" exit /b 1 exit /b 0 :: ============================================================ :: INSTALLATION / MISE A JOUR (meme logique : on clone si absent, :: on pull sinon, puis on recopie les fichiers a jour) :: ============================================================ :INSTALL cls echo ============================================================ echo INSTALLATION de %APP_NAME% echo ============================================================ goto DEPLOIEMENT :UPDATE cls echo ============================================================ echo MISE A JOUR de %APP_NAME% echo ============================================================ goto DEPLOIEMENT :DEPLOIEMENT echo. if not exist "%INSTALL_DIR%" mkdir "%INSTALL_DIR%" echo [1/4] Git... call :TROUVER_GIT if %ERRORLEVEL% neq 0 ( pause goto MENU ) echo [OK] echo. echo [2/4] Telechargement du code (acrobat-plugin/)... if exist "%REPO_DIR%\.git" ( pushd "%REPO_DIR%" "%GIT_CMD%" fetch origin "%GIT_CMD%" pull origin master popd ) else ( if exist "%REPO_DIR%" rmdir /s /q "%REPO_DIR%" "%GIT_CMD%" clone "%GITEA_REPO%" "%REPO_DIR%" ) if not exist "%REPO_DIR%\acrobat-plugin\src\Imposition-00-Core.js" ( echo [ERREUR] Code source introuvable apres clonage/mise a jour pause goto MENU ) echo [OK] echo. echo [3/4] Detection d'Acrobat et copie des scripts... call :TROUVER_DOSSIERS_ACROBAT if %ERRORLEVEL% neq 0 ( echo [ERREUR] Aucune installation d'Acrobat trouvee sous %APPDATA%\Adobe\Acrobat echo Verifiez qu'Acrobat Pro ^(pas seulement Reader^) est installe. pause goto MENU ) for /l %%i in (1,1,%NB_DOSSIERS%) do ( echo -^> !DOSSIER_JS_%%i! copy /y "%REPO_DIR%\acrobat-plugin\src\*.js" "!DOSSIER_JS_%%i!\" >nul ) echo [OK] Scripts copies dans %NB_DOSSIERS% dossier^(s^) Acrobat echo. echo [4/4] Plugin natif (verification de licence)... if exist "%REPO_DIR%\acrobat-plugin\native\dist\ImposingLicence.api" ( set "PLUGIN_DEST=%APPDATA%\Adobe\Acrobat" for /d %%D in ("%APPDATA%\Adobe\Acrobat\*") do ( if not exist "%%D\Plug_ins3" mkdir "%%D\Plug_ins3" copy /y "%REPO_DIR%\acrobat-plugin\native\dist\ImposingLicence.api" "%%D\Plug_ins3\" >nul echo -^> %%D\Plug_ins3\ImposingLicence.api ) echo [OK] Plugin natif copie echo [!] Dossier "Plug_ins3" a verifier : c'est l'emplacement usuel des echo plugins utilisateur sans droits admin, mais a confirmer selon echo votre version d'Acrobat. ) else ( echo [INFO] Aucun .api precompile trouve dans native\dist\ echo Le plugin natif est optionnel : la suite fonctionne en JS seul, echo avec une verification de licence plus simple ^(voir documentation^). echo Pour l'activer, compilez native\PluginMain.cpp ^(SDK Acrobat + VS^) echo et placez le .api resultant dans native\dist\ImposingLicence.api echo avant de relancer cet installeur. ) echo. echo ============================================================ echo VERIFICATION POST-INSTALLATION echo ============================================================ echo. set "POST_ERREURS=0" :: Verifie que les scripts sont bien copies dans au moins un dossier Acrobat call :TROUVER_DOSSIERS_ACROBAT if %ERRORLEVEL% neq 0 ( echo [ERREUR] Aucun dossier Acrobat detecte set /a POST_ERREURS+=1 ) else ( for /l %%i in (1,1,%NB_DOSSIERS%) do ( if exist "!DOSSIER_JS_%%i!\Imposition-00-Core.js" ( echo [OK] Scripts presents dans !DOSSIER_JS_%%i! ) else ( echo [ERREUR] Scripts absents de !DOSSIER_JS_%%i! set /a POST_ERREURS+=1 ) ) ) echo. if !POST_ERREURS! gtr 0 ( echo ============================================================ echo TERMINE AVEC ERREURS echo ============================================================ echo. echo L'installation a rencontre des problemes. echo Utilisez "Verifier l'installation" ^(choix 3^) pour un echo diagnostic complet avec export de logs. ) else ( echo ============================================================ echo TERMINE — INSTALLATION OK echo ============================================================ echo. echo Redemarrez Acrobat Pro pour charger les scripts. echo Menu attendu : Edition ^> Imposition Pro echo. echo Si le menu n'apparait pas, utilisez "Verifier echo l'installation" ^(choix 3^) pour diagnostiquer. ) echo. set /p "LAUNCH=Lancer Acrobat maintenant ? [O/N] : " if /i "!LAUNCH!"=="O" call :LANCER_ACROBAT pause goto MENU :: ============================================================ :: VERIFICATION DE L'INSTALLATION :: ============================================================ :VERIFIER cls set "LOG_FILE=%INSTALL_DIR%\diagnostic.log" echo ============================================================> "%LOG_FILE%" echo DIAGNOSTIC — %APP_NAME%>> "%LOG_FILE%" echo Date : %DATE% %TIME%>> "%LOG_FILE%" echo ============================================================>> "%LOG_FILE%" echo.>> "%LOG_FILE%" echo ============================================================ echo VERIFICATION DE L'INSTALLATION echo ============================================================ echo. set "NB_OK=0" set "NB_ERREURS=0" :: --- 1. Depot local --- echo [1/5] Depot local... if exist "%REPO_DIR%\.git" ( echo [OK] Depot present : %REPO_DIR% echo [OK] Depot local : %REPO_DIR%>> "%LOG_FILE%" set /a NB_OK+=1 ) else ( echo [ERREUR] Depot absent. Lancez d'abord l'installation ^(choix 1^). echo [ERREUR] Depot local absent>> "%LOG_FILE%" set /a NB_ERREURS+=1 ) :: --- 2. Fichiers source --- echo. echo [2/5] Fichiers source... set "FICHIERS_ATTENDUS=Imposition-00-Core.js Imposition-00b-Licence.js Imposition-01-UI.js Imposition-02-Livret.js Imposition-03-NUp.js Imposition-04-Decoupe.js Imposition-05-Marges.js Imposition-06-Reperes.js Imposition-07-Auto.js Imposition-08-MiseAJour.js" set "NB_SRC_OK=0" set "NB_SRC_MANQ=0" for %%F in (%FICHIERS_ATTENDUS%) do ( if exist "%REPO_DIR%\acrobat-plugin\src\%%F" ( set /a NB_SRC_OK+=1 ) else ( echo [MANQUANT] %%F echo [MANQUANT] Source %%F>> "%LOG_FILE%" set /a NB_SRC_MANQ+=1 ) ) if !NB_SRC_MANQ!==0 ( echo [OK] 10/10 fichiers source presents echo [OK] 10/10 fichiers source presents>> "%LOG_FILE%" set /a NB_OK+=1 ) else ( echo [ERREUR] !NB_SRC_MANQ! fichier^(s^) manquant^(s^) echo [ERREUR] !NB_SRC_MANQ! fichier^(s^) source manquant^(s^)>> "%LOG_FILE%" set /a NB_ERREURS+=1 ) :: --- 3. Dossiers Acrobat detectes --- echo. echo [3/5] Dossiers Acrobat... call :TROUVER_DOSSIERS_ACROBAT if %ERRORLEVEL% neq 0 ( echo [ERREUR] Aucune installation d'Acrobat trouvee sous %APPDATA%\Adobe\Acrobat echo [ERREUR] Aucun dossier Acrobat detecte>> "%LOG_FILE%" set /a NB_ERREURS+=1 ) else ( echo [OK] %NB_DOSSIERS% dossier^(s^) Acrobat detecte^(s^) echo [OK] %NB_DOSSIERS% dossier^(s^) Acrobat>> "%LOG_FILE%" set /a NB_OK+=1 for /l %%i in (1,1,%NB_DOSSIERS%) do ( echo !DOSSIER_JS_%%i! echo Dossier : !DOSSIER_JS_%%i!>> "%LOG_FILE%" ) ) :: --- 4. Scripts copies dans Acrobat --- echo. echo [4/5] Scripts dans les dossiers Acrobat... set "DEPLOY_OK=1" for /l %%i in (1,1,%NB_DOSSIERS%) do ( set "DIR_JS=!DOSSIER_JS_%%i!" set "NB_JS_OK=0" set "NB_JS_MANQ=0" for %%F in (%FICHIERS_ATTENDUS%) do ( if exist "!DIR_JS!\%%F" ( set /a NB_JS_OK+=1 ) else ( echo [MANQUANT] %%F dans !DIR_JS! echo [MANQUANT] %%F dans !DIR_JS!>> "%LOG_FILE%" set /a NB_JS_MANQ+=1 set "DEPLOY_OK=0" ) ) if !NB_JS_MANQ!==0 ( echo [OK] !DIR_JS! — 10/10 scripts presents echo [OK] !DIR_JS! — 10/10 scripts>> "%LOG_FILE%" ) ) if "!DEPLOY_OK!"=="1" ( set /a NB_OK+=1 ) else ( echo [ERREUR] Un ou plusieurs scripts manquent dans Acrobat echo [ERREUR] Scripts manquants dans dossier^(s^) Acrobat>> "%LOG_FILE%" set /a NB_ERREURS+=1 ) :: --- 5. Plugin natif (optionnel) --- echo. echo [5/5] Plugin natif ^(optionnel^)... set "PLUGIN_TROUVE=0" for /l %%i in (1,1,%NB_DOSSIERS%) do ( set "DIR_JS=!DOSSIER_JS_%%i!" set "DIR_PLUG=!DIR_JS:\JavaScripts=\Plug_ins3!" if exist "!DIR_PLUG!\ImposingLicence.api" ( echo [OK] Plugin natif present dans !DIR_PLUG! echo [OK] Plugin natif : !DIR_PLUG!\ImposingLicence.api>> "%LOG_FILE%" set "PLUGIN_TROUVE=1" ) ) if "!PLUGIN_TROUVE!"=="0" ( echo [INFO] Plugin natif non installe ^(optionnel — licence JS seule^) echo [INFO] Plugin natif non installe ^(optionnel^)>> "%LOG_FILE%" ) :: --- Bilan --- echo. echo ============================================================ echo BILAN : !NB_OK! OK / !NB_ERREURS! erreur^(s^) echo ============================================================ echo BILAN : !NB_OK! OK / !NB_ERREURS! erreur^(s^)>> "%LOG_FILE%" echo.>> "%LOG_FILE%" if !NB_ERREURS! gtr 0 ( echo. echo Des problemes ont ete detectes. Suggestions : echo - Relancez l'installation ^(choix 1^) echo - Verifiez qu'Acrobat Pro est installe echo - Verifiez votre connexion reseau echo. echo Des problemes detectes, voir suggestions ci-dessus>> "%LOG_FILE%" ) else ( echo. echo Tout est en ordre. Redemarrez Acrobat Pro pour echo voir le menu Edition ^> Imposition Pro. echo. echo Installation validee>> "%LOG_FILE%" ) echo Rapport enregistre dans : echo %LOG_FILE% echo. set /p "OPEN_LOG=Ouvrir le fichier de log ? [O/N] : " if /i "!OPEN_LOG!"=="O" start notepad "%LOG_FILE%" echo. pause goto MENU :: ============================================================ :: LANCER ACROBAT :: ============================================================ :LAUNCH cls echo ============================================================ echo LANCEMENT D'ACROBAT echo ============================================================ echo. call :LANCER_ACROBAT timeout /t 2 >nul goto MENU :LANCER_ACROBAT where acrobat >nul 2>&1 if %ERRORLEVEL%==0 ( start "" acrobat exit /b 0 ) if exist "%ProgramFiles(x86)%\Adobe\Acrobat DC\Acrobat\Acrobat.exe" ( start "" "%ProgramFiles(x86)%\Adobe\Acrobat DC\Acrobat\Acrobat.exe" exit /b 0 ) if exist "%ProgramFiles%\Adobe\Acrobat DC\Acrobat\Acrobat.exe" ( start "" "%ProgramFiles%\Adobe\Acrobat DC\Acrobat\Acrobat.exe" exit /b 0 ) echo [!] Executable Acrobat introuvable automatiquement. Lancez-le manuellement. exit /b 1 :: ============================================================ :: DESINSTALLATION :: ============================================================ :UNINSTALL cls echo ============================================================ echo DESINSTALLATION de %APP_NAME% echo ============================================================ echo. echo Seront supprimes : echo - Les scripts CDImp dans chaque dossier Acrobat\^\JavaScripts echo - Le plugin natif ImposingLicence.api ^(s'il a ete installe^) echo - %INSTALL_DIR% ^(code source local, cle de licence en registre conservee^) echo. set /p "CONFIRM=Confirmer ? [O/N] : " if /i "%CONFIRM%" neq "O" goto MENU echo. if exist "%APPDATA%\Adobe\Acrobat" ( for /d %%D in ("%APPDATA%\Adobe\Acrobat\*") do ( del /q "%%D\JavaScripts\Imposition-*.js" 2>nul del /q "%%D\Plug_ins3\ImposingLicence.api" 2>nul ) ) echo [OK] Scripts et plugin supprimes rmdir /s /q "%INSTALL_DIR%" 2>nul echo [OK] %INSTALL_DIR% supprime echo. echo Pour retirer aussi la cle de licence enregistree : echo supprimez la cle de registre HKCU\Software\Copydev\ImposingAcrobat echo. echo ============================================================ echo DESINSTALLATION TERMINEE echo ============================================================ echo. pause goto MENU :: ============================================================ :FIN echo. echo Au revoir ! echo. pause exit /b 0