@echo off
cls
cd /d %~dp0

:: Déterminer la variable
set driver=%windir%\System32\drivers\spring.sys

:: Installer les drivers Hasp
echo Installe les drivers Hasp...
.\outils\haspdinst.exe -r -kp -nomsg
.\outils\haspdinst.exe -fremove -nomsg
.\outils\haspdinst.exe -i -nomsg

:: Installer les dumps
echo Installe les dumps...
regedit /s .\outils\dumps > nul 2>&1

:: Installer l'émulateur
echo Installe l'emulateur...
.\x64\devcon.exe install .\x64\spring.inf root\spring > nul 2>&1

:: Erreur d'installation
if not %errorlevel%==0 (
  echo Erreur : Veuillez activer le mode test 
  goto :fin
)

:: Bloquer le driver
echo Bloque le driver...
.\x64\setacl.exe -on %driver% -ot file -actn setowner -ownr "n:S-1-5-32-544" -ignoreerr -silent         
.\x64\setacl.exe -on %driver% -ot file -actn setprot -op "dacl:p_nc;sacl:p_nc" -ignoreerr -silent
.\x64\setacl.exe -on %driver% -ot file -actn trustee -trst "n1:S-1-5-32-545;ta:remtrst;w:dacl,sacl" -ignoreerr -silent
.\x64\setacl.exe -on %driver% -ot file -actn trustee -trst "n1:S-1-5-32-544;ta:remtrst;w:dacl,sacl" -ignoreerr -silent

echo Ok!
echo.
pause

:: Redémarrer le PC
echo.
echo Redemarre...
shutdown /r /t 05 /c WX23PACK /f
goto :eof

:fin
echo.
pause