开发者

How do I select Everyone / Just Me based on the previous installed version?

开发者 https://www.devze.com 2023-01-10 03:22 出处:网络
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 Cust

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消