Using Visual Studio setup project. I'd like to change Everyone / Just Me 开发者_Go百科choice to the same as the user selected during previous installation.
Finally figured it out. Used a VBScript Custom Action.
Dim myUpgradeCode
myUpgradeCode = "{6EFB1553-7F4F-4E26-A32B-E2F0F8E11CA9}"
Dim justMe
justMe = False
'AssignmentType
' Equals 0 if product is advertised or installed per-user.
' Equals 1 if product is advertised or installed per-machine for all users.
Set products = Session.Installer.RelatedProducts( myUpgradeCode )
For Each product In products
astp = CLng(Session.Installer.ProductInfo(product, "AssignmentType"))
If astp = 0 Then
justMe = True
End If
Next
If JustMe Then
Session.Property("ALLUSERS") = ""
Else
Session.Property("ALLUSERS") = "1"
End If
And executed it before AppSearch.
Done!
You can save the value of the ALLUSERS
MSI property to a well-defined location in the Registry during installation. You can then query that value when you upgrade and act accordingly.
You can also use the MSI api to check whether your product is installed for in a per-machine or per-user context. To do so you would call the MsiEnumProductsEx
function and see whether your product appears in either installation context.
精彩评论