views:

28

answers:

2

Using Visual Studio setup project. I'd like to change Everyone / Just Me choice to the same as the user selected during previous installation.

A: 

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.

0xA3
Ok.. Got it to work in Custom Action VBScript. But even if I set the ALLUSERS to "{}", it installs for all users. Why?The custom action gets executed just before "LaunchConditions". It either sets ALLUSERS to "{}" or "1".
Trainee4Life
+1  A: 

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!

Trainee4Life