2012-04-23 27 views
4

我有一個MSI,我正在使用安裝正常的WiX腳本動態構建。但是,UninstallString始終對msiexec.exe具有/ I(「斜槓」)參數,我希望它是/ X。我讀了關於UninstallString here,它說這個註冊表項是由Windows安裝程序設置的。我會通過WiX或安裝命令將問題傳遞給Windows Installer,這會導致UninstallString始終具有/ I(「斜槓」)參數?UninstallString被設置爲/ I not/X參數

+1

你在哪裏看到這個UninstallString?您是否看到它由添加/刪除程序生成? (程序和功能?)FWIW msiexec/i foo.msi REMOVE = ALL和msiexec/x foo.msi大多是平等的。您是否遇到與此相關的問題? – 2012-04-23 13:49:48

+0

我在註冊表的卸載鍵中看到了此MSI產品代碼的UninstallString。我遇到了與此相關的問題。當我們去除MSI時,它將自行重新安裝,因此永遠不會從程序和功能列表中消失。 – joebalt 2012-04-23 14:06:04

+0

我懷疑你的問題在別處,因爲添加/刪除程序實際上並未使用Uninstall \ {ProductCode}項中列出的UninstallString。它使用MSI ProductCode屬性代替。啓用日誌並記錄卸載,你會明白我的意思。 – 2012-04-23 14:18:49

回答

6

我打破了,並與MS支持這一點。答案是將MSI中的ARPNOMODIFY屬性設置爲1以生成使用/ X參數的UninstallString。

/I參數意味着您有appwiz.cpl列表中的「更改」和「修復」選項。希望這可以幫助其他人面對這個問題。

下面的MSDN文章詳細描述了ARP屬性。

http://msdn.microsoft.com/en-us/library/windows/desktop/aa367590(v=vs.85).aspx

http://msdn.microsoft.com/en-us/library/windows/desktop/aa367591(v=vs.85).aspx

http://msdn.microsoft.com/en-us/library/windows/desktop/aa367592(v=vs.85).aspx

+1

仍然聽起來像一個UninstallString和ModifyPath總是相同的錯誤。 當然ModifyPath應該有/我和uninstallString有/ x? – 2012-12-10 18:33:55

+0

@MichaelParker:是的。 – Joshua 2017-10-27 20:58:33

2

您必須在WiX安裝程序中創建一個ARPAltRegistryEntries組件來設置UninstallString。將參數設置爲/ I而不是預期的/ X允許您使用自己的卸載UI。這裏是一個例子:

<DirectoryRef Id="TARGETDIR"> 
    <!-- Create alternative ARP entry that lets us launch uninstall with 
     full UI. Setting ARPSYSTEMCOMPONENT above hides WI generated key 
       that uses the product GUID.--> 
    <Component Id="ARPAltRegistryEntries" Guid=""> 
     <RegistryKey Root="HKLM" Key="SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Your Product"          Action="createAndRemoveOnUninstall">     
      <RegistryValue Type="string" Name="UninstallString" Value="MsiExec.exe /i[ProductCode] REMOVE=ALL"/> 
     </RegistryKey> 
    </Component> 
</DirectoryRef> 
+0

儘管我認爲這個答案很有用,但我不希望篡改應該由Windows Installer處理的設置 - 如果我在原始帖子中引用的文檔是可信的。我真的很想了解我的特定MSI是如何導致Windows Installer生成此UninstallString的。 – joebalt 2012-04-30 14:35:31

0

的問題是問維克斯項目,但如果有人正在使用的Visual Studio安裝項目,然後解決方案之一是將後生成的VB腳本添加到按照@joe的建議將ARPNOMODIFY更改爲1 Baltimore

  1. 創建一個VB腳本文件,作爲fol低 「setnomodify.vbs」:
Option Explicit 

    Const msiOpenDatabaseModeTransact = 1 
    Dim argNum, argCount:argCount = Wscript.Arguments.Count 

    Dim openMode : openMode = msiOpenDatabaseModeTransact 

    'This script adds a type 51 custom action into a given MSI database that 
    'ensures the ARPNOMODIFY is set to 1 


    ' Connect to Windows installer object 
    On Error Resume Next 
    Dim installer : Set installer = Nothing 
    Set installer = Wscript.CreateObject("WindowsInstaller.Installer") : 
    CheckError 

    ' Open database 
    Dim databasePath:databasePath = Wscript.Arguments(0) 
    Dim database : Set database = installer.OpenDatabase(databasePath, openMode) : CheckError 

    ' Process SQL statements 
    Dim query, view, record, message, rowData, columnCount, delim, column 

    query = "INSERT INTO `Property` (`Property`, `Value`) VALUES ('ARPNOMODIFY', '1')" 
    Set view = database.OpenView(query) : CheckError 
    view.Execute : CheckError 

    database.Commit 

    If Not IsEmpty(message) Then Wscript.Echo message 
    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 
  • 如下添加這個腳本路徑與正確的文件夾路徑安裝項目後生成事件:
  • PostBuildEvent = CSCRIPT 「$(PROJECTDIR)setnomodify.vbs」 「$(BuiltOuputPath)」

    現在只要您生成安裝程序安裝項目ARPNOMODIFY將被設置爲1, ü已安裝的應用程序的nistallstring將在註冊表中具有「/ X」而不是「/ I」

    您也可以通過使用ORCA並在MSI的「屬性」表中將ARPNOMODIFY添加爲1來手動執行此操作。