Visual Studio Setup and Deployment Project, Unattended installation and Custom Properties

When execute an installer made with Visual Studio in the following way:

msiexec /i ProgramInstaller.msi /q TARGETDIR=C:\Program CUSTOMPROPERTY1=”SomeValue”

The custom property CUSTOMPROPERTY1 didnt’t take the value “SomeValue”. After look at the log of the installation (generated with msiexe /log) I saw that Visual Studio always generates a custom action for each property to assign the default value. These custom actions (that have the name CustomTextA_SetProperty_EDITx) are excecute after Windows Installer assigns the properties with the values of the parameters. The solution was eliminated those custom actions, first using Orca and then with this script:

Option Explicit

Dim WI, DB, DelCustom, DelCustom2
Dim Path_MSI_File
Const msiOpenDatabaseModeDirect = 2

Set WI = CreateObject(“WindowsInstaller.Installer”): CheckError
Path_MSI_File = ” “

Path_MSI_File = Wscript.Arguments(0)
Set DB = WI.OpenDatabase(Path_MSI_File,msiOpenDatabaseModeDirect):CheckError

‘Remove VS Custom Actions
Set DelCustom = DB.OpenView(“Delete From CustomAction WHERE `Action`=’CustomTextA_SetProperty_EDIT1′”):CheckError
DelCustom.Execute : CheckError

Set DelCustom2 = DB.OpenView(“Delete From InstallUISequence WHERE `Action`=’CustomTextA_SetProperty_EDIT1′”):CheckError
DelCustom2.Execute : CheckError

Set WI = Nothing
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

One thought on “Visual Studio Setup and Deployment Project, Unattended installation and Custom Properties”

  1. Wow, fantastic blog structure! How long have you ever been blogging for?
    you make running a blog glance easy. The whole look of your site is excellent, as well as the content!

Leave a Reply