Using VbScript Custom Action:
I had a situation in which Windows default Users group was required Full Permissions upon a folder which was creating by my installers. This is not a big problem. Actual problem which I was facing is that on German Windows, default Users group is not Users group. Its “Benutzer” there actually. So I had to use a vbscript while hardcoding group name and applying Windows built-in command cacls.exe (now its icacls.exe):
VbScript Custom Action:
- 'Reading the Locale Value to detect which Regional Language this Windows (NT) have
- nLocale=WshShell.RegRead("HKEY_USERS\.DEFAULT\Control Panel\International\\Locale")
- if (nLocale="") or IsEmpty(nLocale) or IsNull(nLocale) then
- nLocale=00000409
- sUserGroup="Users"
- end if
- if nLocale=00000409 then 'Its English
- sUserGroup="Users"
- elseif nLocale=00000407 then 'Its German
- sUserGroup="Benutzer"
- end if
- 'Applying permissions
- if fso.FolderExists(sLocalRoot) then
- 'StrCommand = "cmd /c cacls.exe " & """" & sLocalRoot & """" & " /G EveryOne:F /E"
- StrCommand = "/c cacls.exe " & """" & sLocalRoot & """" & " /G " & sUserGroup & ":F /E /T"
- 'Get the Windows Major Version from the Registry
- sOSversion=WshShell.RegRead("HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\CurrentVersion")
- If CInt(sOSversion) >= 6 then
- objShell.ShellExecute "cmd.exe ", StrCommand, "", "runas", 1
- Else
- WshShell.Run "Cmd.exe " & " " & StrCommand
- End If
- End if
Using Wix Util Extension:
Now using Wix Util extension, this has been shorten to:
1 <!--Referencing property defined by Util Extension-->
2 <PropertyRef Id="WIX_ACCOUNT_USERS"/>
3
4 <!-- +++++++++++++++++++++++++++++++ -Directory Structure +++++++++++++++++++++++++++++++ -->
5 <Directory Id="TARGETDIR" Name="SourceDir">
6 <Directory Id="DATASET" Name="MyDataSet">
7 <Component Id="DoPermissions" DiskId="1" Guid="{2E90BD04-2E1B-4CAE-994B-090D937F3E5A}">
8 <CreateFolder>
9 <util:PermissionEx ChangePermission="yes" GenericAll="yes" User="[WIX_ACCOUNT_USERS]" Traverse="yes" />
10 </CreateFolder>
11 </Component>
12 </Directory>
Property WIX_ACCOUNT_USERS would detect the default Users group and PermissionEx command would apply permissions using its value for a specific folder.
No comments:
Post a Comment