无法从WiX创建的MSI卸载程序

时间:2019-07-31 13:15:08

标签: wix windows-installer msiexec osquery

使用由WiXToolSet制作的MSI安装osquery后(使用osquery提供的脚本),我尝试卸载它失败。 另外,它也没有在appwiz中显示为程序。 (链接到脚本-https://github.com/osquery/osquery/blob/master/tools/deployment/make_windows_package.ps1

我尝试同时使用MSI本身-osquery.msi /uninstall和非整数字符串-msiexec /I{'uninstallstring'}。 我还尝试使用/fv选项进行修复。

与WiX一起使用以创建MSI的脚本代码:

@'
<?xml version='1.0' encoding='windows-1252'?>
<?define OsqueryVersion = 'OSQUERY_VERSION'?>
<?define OsqueryUpgradeCode = 'ea6c7327-461e-4033-847c-acdf2b85dede'?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">
  <Product
    Name='osquery'
    Manufacturer='Facebook'
'@
$wix += "`n    Id='$(New-Guid)'`n"
$wix +=
@'
    UpgradeCode='$(var.OsqueryUpgradeCode)'
    Language='1033'
    Codepage='1252'
    Version='$(var.OsqueryVersion)'>
    <Package Id='*'
      Keywords='Installer'
      Description='osquery standalone installer'
      Comments='Facebooks opensource host intrusion detection agent'
      Manufacturer='Facebook'
      InstallerVersion='200'
      Platform='x64'
      Languages='1033'
      Compressed='yes'
      SummaryCodepage='1252' />
    <MediaTemplate EmbedCab="yes" />
    <MajorUpgrade
      DowngradeErrorMessage="A later version of osquery is already installed. Setup will now exit." />
    <Condition Message='A newer version of osquery is already installed.'>
      NOT NEWERVERSIONDETECTED
    </Condition>
    <Condition Message="You need to be an administrator to install this product.">
        Privileged
    </Condition>
    <Property Id='SOURCEDIRECTORY' Value='packs'/>
    <PropertyRef Id="WIX_ACCOUNT_LOCALSYSTEM" />
    <PropertyRef Id="WIX_ACCOUNT_USERS" />
    <PropertyRef Id="WIX_ACCOUNT_ADMINISTRATORS" />
    <Directory Id='TARGETDIR' Name='SourceDir'>
      <Directory Id='ProgramFiles64Folder'>
        <Directory Id='INSTALLFOLDER' Name='osquery'>
          <Directory Id='DaemonFolder' Name='osqueryd'>
            <Component Id='osqueryd'
                Guid='41c9910d-bded-45dc-8f82-3cd00a24fa2f'>
                <CreateFolder>
                <Permission User="[WIX_ACCOUNT_USERS]" Read="yes"
                  ReadExtendedAttributes="yes" Traverse="yes"
                  ReadAttributes="yes" ReadPermission="yes" Synchronize="yes"
                  GenericWrite="no" WriteAttributes="no"/>
                <Permission User="[WIX_ACCOUNT_ADMINISTRATORS]" GenericAll="yes"/>
                <Permission User="[WIX_ACCOUNT_LOCALSYSTEM]" GenericAll="yes"/>
              </CreateFolder>
              <File Id='osqueryd'
                Name='osqueryd.exe'
                Source='OSQUERY_DAEMON_PATH'
                KeyPath='yes'/>
              <ServiceInstall Id='osqueryd'
                Name='osqueryd'
                Account='NT AUTHORITY\SYSTEM'
                Arguments='--flagfile="C:\Program Files\osquery\osquery.flags"'
                Start='auto'
                Type='ownProcess'
                Vital='yes'
                ErrorControl='normal'/>
              <ServiceControl Id='osqueryd'
                Name='osqueryd'
                Stop='both'
                Start='install'
                Remove='uninstall'
                Wait='no'/>
            </Component>
          </Directory>
          <Component Id='osqueryi' Guid='6a49524e-52b0-4e99-876f-ec50c0082a04'>
            <File Id='osqueryi'
              Name='osqueryi.exe'
              Source='OSQUERY_SHELL_PATH'
              KeyPath='yes'/>
          </Component>
          <Component Id='extras' Guid='3f435561-8fe7-4725-975a-95930c44d063'>
            <File Id='osquery.conf'
              Name='osquery.conf'
              Source='OSQUERY_CONF_PATH'
              KeyPath='yes'/>
            <File Id='osquery.flags'
              Name='osquery.flags'
              Source='OSQUERY_FLAGS_PATH'/>
            <File Id='osquery.man'
              Name='osquery.man'
              Source='OSQUERY_MAN_PATH'/>
            <File Id='osquery_utils.ps1'
              Name='osquery_utils.ps1'
              Source='OSQUERY_UTILS_PATH'/>
            <File Id='manage_osqueryd.ps1'
              Name='manage-osqueryd.ps1'
              Source='OSQUERY_MGMT_PATH'/>
'@

当尝试使用MSI进行卸载时,我看到以下消息: This patch package could not be opened. Verify that the patch package exists and that you can access it, or contact the application vendor to verify that this is a valid Windows Installer patch package 尝试使用卸载字符串时,我看到以下消息: This action is only valid for products that are currently installed

1 个答案:

答案 0 :(得分:0)

  

升级代码检索 How can I find the Upgrade Code for an installed MSI file?(如果您想使用其他软件包系列测试以下内容,请通过此处介绍的方法找到升级代码)。


调试 :要查找产品代码(假设它确实已定义),可以尝试运行以下代码:

Set installer = CreateObject("WindowsInstaller.Installer")
Set upgrades = installer.RelatedProducts("ea6c7327-461e-4033-847c-acdf2b85dede")

For Each u In upgrades
   MsgBox u, vbOKOnly, "Product Code: "
Next

过程 1) 将脚本复制并粘贴到记事本 2) 中>另存为ANSI文件:“ Find Related Products.vbs”在桌面上, 3) 双击脚本文件即可运行。记下消息框显示的产品代码(如果有)。点击 CTRL + C 复制实际的VBScript对话框的内容。

Uninstall:在 cmd.exe 中,使用通过运行上述脚本找到的产品代码:

msiexec.exe /x {Product-Code}

替代 :如果无法通过上述操作手动浏览 %SystemRoot%\Installer ,则{{3} }。 Locate ,选择正确的MSI, right click ,然后转到 "Uninstall"


链接