Hi Jairo,
Here is how I've done it:
1. Create a .NET DLL with a class that inherits from the System.Configuration.Install.Installer class;
2. Override the methods "Install, Uninstall, Rollback, Commit" methods.
3. In the Install method, add/call the following code: (I've made in C# but you can easily translate that to any .net lang u want, as long as it is managed);
Code: Select all
static public string AddFullPermissionsOnFolderForUser(string p_strPath, string p_strAccountGroupName)
{
try
{
DirectoryInfo FolderInfo = new DirectoryInfo(p_strPath);
System.Security.AccessControl.DirectorySecurity FolderCurrentAccessControl = FolderInfo.GetAccessControl();
FolderCurrentAccessControl.AddAccessRule(new System.Security.AccessControl.FileSystemAccessRule(p_strAccountGroupName, System.Security.AccessControl.FileSystemRights.FullControl, System.Security.AccessControl.InheritanceFlags.ContainerInherit, System.Security.AccessControl.PropagationFlags.None, System.Security.AccessControl.AccessControlType.Allow));
FolderCurrentAccessControl.AddAccessRule(new System.Security.AccessControl.FileSystemAccessRule(p_strAccountGroupName, System.Security.AccessControl.FileSystemRights.FullControl, System.Security.AccessControl.InheritanceFlags.ObjectInherit, System.Security.AccessControl.PropagationFlags.None, System.Security.AccessControl.AccessControlType.Allow));
FolderInfo.SetAccessControl(FolderCurrentAccessControl);
return string.Format("Successfully added full permissions to '{0}' on '{1}'.", p_strAccountGroupName, p_strPath));
}
catch (System.Security.Principal.IdentityNotMappedException)
{
return string.Format("'{0}' is not a valid User/Group to set permissions on '{1}'", p_strAccountGroupName, p_strPath));
}
catch (Exception ex)
{
return string.Format("An unhandled exception was thrown while attempting to set full permissions to '{0}' on '{1}', The message returned was: {2}", p_strAccountGroupName, p_strPath, ex.Message));
}
}
4. Add your .NET dll to the installation on AI.
5. On the Custom Actions Tab (in advanced installer), add a new InstallExecuteSequence "InstallFinalize";
6. Add a new ".net Installer Class Action" and point to your .NET dll.
As you can see in the code you can easily change it to set specific permissions instead of full control.
Hope that helps,
Marcelo