Certains logiciels nécessitent des droits d’utilisateur avec pouvoir ou administrateur pour fonctionner. En général la raison est soit de pouvoir enregistrer une dll ou un ocx soit écrire ou modifier un répertoire situé dans « c:\program files ». Dans un milieu professionnel les utilisateurs ne sont pas des « Administrateurs » mais simple « Utilisateurs ». Pour que le logiciel puisse être utilisable il faudra donc modifier le répertoire d’installation. Comme la plupart du temps on utilise des script de déploiement il faudra alors intégré la modification dans le script. La commande est « cacls »

exemple avec le logiciel statistique R pour autoriser l’ajout de bibliothèque par les étudiants pendant un cours:

@echo off
cls
set PWD=%~dp0
cd /d %PWD%
R-2.15.1-win.exe /verysilent
cacls /e /p Utilisateurs:f
::end

Pour windows 10: ICACLS Commands

  • Grant explicit full control access to this folder to all beneath subfolders, and files leaving all inherited permissions in place and continue on error
ICACLS "<FolderPath>" /INHERITANCE:e /GRANT:r <UserName>:(F) /T /C
  • Grant explicit modify access to this folder to all beneath subfolders, and files leaving all inherited permissions in place and continue on error
ICACLS "<FolderPath>" /INHERITANCE:e /GRANT:r "<UserName>":(M) /T /C
  • Change the owner of this folder and all beneath subfolders and files and continue on error
ICACLS "<FolderPath>" /SETOWNER "<UserName>" /T /C

Exemaple

rem SID: https://support.microsoft.com/fr-fr/help/243330/well-known-security-identifiers-in-windows-operating-systems
echo Droits sur l'arborescence C:\
    if not exist %SystemDrive%\temp mkdir %SystemDrive%\temp>nul 2>&1
    if not exist %SystemDrive%\Drivers mkdir %SystemDrive%\Drivers>nul 2>&1

    rem Authentifies
    REM icacls.exe c:\ /remove:g *S-1-5-11  >nul 2>&1
    REM icacls.exe %SystemDrive%\temp /grant:r *S-1-5-11:(OI)(CI)(GR,GW,GE,AD,WD,DC) /T>nul 2>&1
    REM icacls.exe %SystemDrive%\Drivers /grant:r *S-1-5-11:(OI)(CI)(GR,GW,GE,AD,WD,DC) /T>nul 2>&1
    REM icacls.exe C:\Tools /grant:r *S-1-5-11:(OI)(CI)F>nul 2>&1

    rem tout le monde
    REM icacls.exe c:\ /remove:g *S-1-1-0>nul 2>&1
    REM icacls.exe %SystemDrive%\temp /grant:r *S-1-1-0:(OI)(CI)(GR,GW,GE,AD,WD,DC) /T>nul 2>&1
    REM icacls.exe %SystemDrive%\Drivers /grant:r *S-1-1-0:(OI)(CI)(GR,GW,GE,AD,WD,DC) /T>nul 2>&1

Dernière modification : le 2021/05/04