@echo off setlocal set "ROOT=\\DS-918\chatgpt\ChatGPT-Gouvernance-Projets\_registry" set "INBOX=%ROOT%\updates\inbox\kb" set "PS=%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" if not exist "%INBOX%" mkdir "%INBOX%" set "STAMP=%DATE:~6,4%%DATE:~3,2%%DATE:~0,2%_%TIME:~0,2%%TIME:~3,2%%TIME:~6,2%" set STAMP=%STAMP: =0% set "ERR=%INBOX%\%~n0_%STAMP%.err.txt" set "OUT=%INBOX%\%~n0_%STAMP%.out.txt" "%PS%" -NoProfile -ExecutionPolicy Bypass -File "%~dpn0.ps1" %* 1>"%OUT%" 2>"%ERR%" set "EC=%ERRORLEVEL%" if %EC% NEQ 0 ( "%PS%" -NoProfile -ExecutionPolicy Bypass -File "%ROOT%\scripts\kb_autodraft_from_err_v1.0.ps1" -ErrFile "%ERR%" -ScriptPath "%~dpn0.ps1" for /f "delims=" %%F in ('dir /b /a:-d /o:-d "%INBOX%\AUTO_%~n0_*.txt"') do ( set "LAST=%%~fF" goto :have ) :have if defined LAST ( "%PS%" -NoProfile -ExecutionPolicy Bypass -File "%ROOT%\scripts\kb_quicklog_and_sync_v1.1.ps1" -FromFile "%LAST%" -Execute ) ) exit /b %EC%