views:

253

answers:

1

Hi,

I have a setup project for my .NET application, and both install/uninstall are working just fine, if they are left alone while they work.

However, if someone cancels the uninstall while it is processing, the rollback doesn't seem to be handled correctly, and upon trying to uninstall again at a later time, the user is greeted with a null reference exception.

I would like to just simplify the situation; I would like to remove the user's ability to cancel an uninstall in progress. Can this be done?

Thanks, -Ben

+1  A: 

Yes, it is possible to do so. MSDN lists several options; however, it might be simpler to just patch the MSI file created by Visual Studio. This can be done using Orca (You will find an installer for this tool in the Windows SDK folder typically under C:\Program Files\Microsoft SDKs\Windows\v6.0A\Bin\orca.msi).

Orca allows you to edit the MSI database tables. To hide the cancel button you would have to add a record to the ControlCondition table (from here):

Dialog        | Control      | Action   | Condition
------------------------------------------------------
ProgressForm  | CancelButton | Hide     | 1

This manual task of adding a record using Orca is probably better done with a short VBScript like that:

Set oMsi = CreateObject("WindowsInstaller.Installer")

' get path to msi from command line
strMsiFullPath = Wscript.Arguments(0)
' open transacted
Set oDB = oMsi.OpenDatabase(strMsiFullPath , 1)

' insert a record into the [ControlCondition][3] table
Set oView = oDB.OpenView("INSERT INTO `ControlCondition` " & _
    "(`ControlCondition`.`Dialog_`, `ControlCondition`.`Control_`," & _
     "`ControlCondition`.`Action`, `ControlCondition`.`Condition`) " & _
     "VALUES ('ProgressForm', 'CancelButton', 'Hide', '1')")

' clean up
oView.Execute: oView.Close: oDB.Commit
Set oMsi = Nothing

This script can be added as a post-build step to your setup project (Note that there is a typo in the Visual Studio variable for the output path):

cscript $(ProjectDir)patch.vbs $(BuiltOuputPath)
0xA3
Good answer. You definitely pointed me in the right direction. Unfortunately, 'ProgressForm' is not the dialog that shows progress during Uninstall. In fact, I went through all the dialogs in the dialog table and added numbers to the titles so I could track down this dialog, with no luck at all. My guess is that the uninstall progress dialog is not editable using the ControlCondition table. Still, I appreciate the answer as it opened up a lot of possibilities for customization for me. Thanks :)
Ben