During the installation of certain software, the end user will need permissions on the folder.
However, in a context where the user is not an administrator, this poses a problem.
The solution I use is as follows:
- a package that installs a PowerShell module (which is therefore made a dependency of the software)
- a script to change the permissions.
Rights are given on 1 specific folder, for authenticated users (can be changed by any other group).
The PowerShell module is NTFSSecurity, available here: https://gallery.technet.microsoft.com/s ... dbb2b84e85
The package used to install it contains this code:
Code: Select all
# -*- coding: utf-8 -*-
from setuphelpers import *
uninstallkey = []
targetPWSH = makepath(programfiles,'WindowsPowerShell\Modules\NTFSSecurity')
folderPWSH = 'NTFSSecurity'
def install():
#copie du module Powershell
if (isdir(targetPWSH) != True) :
mkdirs(targetPWSH)
copytree2(folderPWSH,targetPWSH)Code: Select all
#Autorisation d'accès au dossier pour les utilisateurs loggés
Install-Module NTFSSecurity
$Path = "CHEMIN DU DOSSIER POUR LES DROITS"
#Désactivation de l'héritage
Get-Item $Path | Disable-NTFSAccessInheritance
Add-NTFSAccess –Path $Path -Account "Utilisateurs authentifiés" -AccessRights FullControl- To make your NTFSSecurity installation package a dependency,
- Place a .ps1 file with the PowerShell code at the top,
- Run the script in your def install() function with the command:
Code: Select all
run('powershell.exe -NoProfile -NonInteractive -executionpolicy bypass -File FICHIER.ps1')