|
Infralution Support Support groups for Infralution products
|
View previous topic :: View next topic |
Author |
Message |
handa29
Joined: 08 Oct 2007 Posts: 3
|
Posted: Tue Oct 16, 2007 12:24 am Post subject: Insufficient Privileges to Install the License |
|
|
Hi --
When users attempt to enter their license key into the licensing dialog, it often causes this error:
Quote: | "An error occurred while installing the license. Ensure you have sufficient privileges to install the license." |
What I don't understand is that we save the license file in the Common Applications area on the hard drive -- not the installed executable folder in Program Files or the Local User Data areas.
Any idea what's going on here? This is beginning to become quite a painful user support issue for us.
By the way, ours is a small commercial software program that users install themselves. This issue appears to occur mostly with computers in managed IT environments, like schools and enterprises -- but numerous individual users (and now Vista) are also complaining about this.
Thanks,
Anthony |
|
Back to top |
|
|
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Tue Oct 16, 2007 6:29 am Post subject: |
|
|
The problem is that, by default, non-power users under XP and standard users under Vista do not have permissions to write into the Common App Data directory. This is a major pain in the neck - because it means that for these users there is no common directory (or even registry entry) where you are allow to write by default. Since you really don't want to install license keys in a users profile area this makes life a bit difficult.
One solution is to have your installer create a directory under the Common App directory which does have permissions for anyone to write to.
Unfortunately Visual Studio setup projects do not support setting directory permssions directly. But you can still achieve it by some post processing of the MSI using a VB script.
The first step is to add the Common Application Data directory in your Setup project. You do this by right clicking on the "File System on Target Machine" entry in the File System view and selecting "Add Special Folder". Unfortunately Microsoft, in their wisdom, did not put a short cut here for the "Common Application Data" directory - so you have to use the "Add Special Folder->Custom Folder" option. Change the name to "Common Application Data". Change the default location to "[CommonAppDataFolder]" Change the property to "COMMONAPPDATAFOLDER".
Next add a subdirectory for your company (this is good practice) and a sub-sub-directory (if you want) for your product/license files.
Now your installer will create the folder where your license files will be stored - but it will still have the default permissions. Since Visual Studio doesn't support setting permissions on setup folders we will have to post-process the MSI file to do this.
The first step to doing this is to download and install the Microsoft installer tool (Orca) - this is included as part of the microsoft platform SDK. Once you have installed Orca you should be able to right click on MSI files and open them for editing.
Select the Directory table of the MSI file and locate the entry corresponding to the Common App Data sub-directory you created. Note the Directory ID.
Select the Component table of the MSI - find the first component with the Directory set to TARGETDIR. Note the Component Name (should start with "C__").
Next modify the script below to insert the Directory and Component IDs that you found above in the appropriate places (replacing the existing IDs - _BB68B486E4BF43CFA85C8FD7861ED3A5 and C__BF0BC627559B46439555D94FAC5F6151)
Code: | ' Windows Installer utility to post process MSI file to set permissions on the
' common data directory
' Copyright (c) Infralution 2007. All rights reserved.
'
Option Explicit
Const msiOpenDatabaseModeTransact = 1
const msiViewModifyInsert = 1
Const msiViewModifyUpdate = 2
Const msiViewModifyReplace = 4
Dim argNum, argCount:argCount = Wscript.Arguments.Count
If (argCount < 1) Then
Wscript.Echo "The MSI file to fix must be specified as an argument"
Wscript.Quit 1
End If
On Error Resume Next
Dim installer, databasePath, database, query, view, record
' Connect to Windows installer object
'
Set installer = Nothing
Set installer = Wscript.CreateObject("WindowsInstaller.Installer") : CheckError
' Open database
'
databasePath = Wscript.Arguments(0)
Set database = installer.OpenDatabase(databasePath, msiOpenDatabaseModeTransact) : CheckError
' Set the permissions on the Common App Data sub-directory to everyone
'
query = "INSERT INTO `CreateFolder` (`Directory_` , `Component_`) VALUES ('_BB68B486E4BF43CFA85C8FD7861ED3A5', 'C__BF0BC627559B46439555D94FAC5F6151')"
Set view = database.OpenView(query) : CheckError
view.Execute : CheckError
query = "INSERT INTO `LockPermissions` (`LockObject`, `Table` , `User`, `Permission`) VALUES ('_BB68B486E4BF43CFA85C8FD7861ED3A5', 'CreateFolder', 'Everyone', 268435456)"
Set view = database.OpenView(query) : CheckError
view.Execute : CheckError
' commit the changes
'
database.Commit
Wscript.Echo "MSI Updated"
Wscript.Quit 0
Sub CheckError
Dim message, errRec
If Err = 0 Then Exit Sub
message = Err.Source & " " & Hex(Err) & ": " & Err.Description
If Not installer Is Nothing Then
Set errRec = installer.LastErrorRecord
If Not errRec Is Nothing Then message = message & vbLf & errRec.FormatText
End If
Fail message
End Sub
Sub Fail(message)
Wscript.Echo message
Wscript.Quit 2
End Sub |
Run this script on your MSI file and it will modify the MSI file so that it sets the permissions on the common app sub-directory to allow everyone to write to it. You can then add this script as a post build action on your setup project.
If you are using InstallShield (or other installer product) then generally they will provide the ability to set permissions on folders without all the above mucking around. _________________ Infralution Support |
|
Back to top |
|
|
SwissKnife
Joined: 25 May 2011 Posts: 1 Location: Schweiz
|
Posted: Wed May 25, 2011 9:55 am Post subject: |
|
|
Many thanks for your script. Your solution is great, but I have used an other component identifier.
The solution takes the following component:
Select the Component table of the MSI - find the first component with the Directory set to TARGETDIR. Note the Component Name (should start with "C__").
I use this component:
Select the Component table of the MSI - find the first component with the Directory set to the Directory ID noted above. Note the Component Name (should start with "C__").
Good luck
Christian |
|
Back to top |
|
|
CynoxDev
Joined: 15 Feb 2013 Posts: 8
|
Posted: Mon Feb 18, 2013 11:04 am Post subject: |
|
|
EDIT:
I found the problem. The AlwaysCreate property for the target folder was set to true. Thus the entry in the CreateFolder table already existed and caused the script failed when trying to insert a row with the same primary key.
-----
Hi.
When i execute the script, i get the following error:
>cscript script.vbs installer.msi
Msi API Error 80004005: Execute,Params
1: 2259 2: installer.msi 3: 4:
I don't have any experience with vb-Script and MSI, so maybe you can give me some pointers what could be going wrong.
Thank you,
Marcus |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|