diff --git a/scripts/install.bat b/scripts/install.bat index 6713a97..8c0577f 100644 --- a/scripts/install.bat +++ b/scripts/install.bat @@ -46,9 +46,12 @@ if exist "bootstrap\cache\blade-icons.php" del /F /Q "bootstrap\cache\blade-ico if exist "bootstrap\cache\filament" rmdir /S /Q "bootstrap\cache\filament" >nul 2>&1 REM Clear compiled Blade views (storage/framework/views/*.php) for %%f in ("storage\framework\views\*.php") do del /F /Q "%%f" >nul 2>&1 -REM Clear OPcache file cache from disk (opcache.file_cache=C:/tmp/php-opcache in php.ini) +REM Detect drive letter from SCRIPTS path (works on any drive: C:, D:, E:, ...) +for %%D in ("!SCRIPTS!") do set "SCRIPTS_DRIVE=%%~dD" +set "OPCACHE_DIR=!SCRIPTS_DRIVE!\tmp\php-opcache" +REM Clear OPcache file cache from disk REM Without this, php-cgi reads stale bytecode after restart since validate_timestamps=0 -if exist "C:\tmp\php-opcache" rmdir /S /Q "C:\tmp\php-opcache" >nul 2>&1 +if exist "!OPCACHE_DIR!" rmdir /S /Q "!OPCACHE_DIR!" >nul 2>&1 echo [OK] Done. echo. @@ -68,7 +71,12 @@ echo. REM --- [4/7] Configure OPcache --- echo [4/7] Configuring OPcache... -if not exist "C:\tmp\php-opcache" mkdir "C:\tmp\php-opcache" +if not exist "!OPCACHE_DIR!" mkdir "!OPCACHE_DIR!" +REM Patch php.ini with the correct opcache path for this system's drive +set "OPCACHE_DIR_FWD=!OPCACHE_DIR:\=/!" +powershell -NoProfile -Command ^ + "(Get-Content '!SCRIPTS!\php\php.ini') -replace '^opcache\.file_cache=.*', 'opcache.file_cache=!OPCACHE_DIR_FWD!' | Set-Content '!SCRIPTS!\php\php.ini'" +echo OPcache dir: !OPCACHE_DIR! set "SCRIPTS_BAK=!SCRIPTS!" powershell -NoProfile -Command ^ "$s='!SCRIPTS_BAK!'; $action=New-ScheduledTaskAction -Execute 'cmd.exe' -Argument ('/c \"\"' + $s + '\warmup.bat\"\"'); $trigger=New-ScheduledTaskTrigger -AtStartup; $settings=New-ScheduledTaskSettingsSet -ExecutionTimeLimit (New-TimeSpan -Minutes 5) -MultipleInstances IgnoreNew; Unregister-ScheduledTask -TaskName 'MatabWarmup' -Confirm:$false -ErrorAction SilentlyContinue; Register-ScheduledTask -TaskName 'MatabWarmup' -Action $action -Trigger $trigger -Settings $settings -RunLevel Highest -User 'SYSTEM' -Force | Out-Null; Write-Host ' Warmup task registered.'"