VS2010 Wix proj - 如何传递用作目录名称的命令行变量

发布于 2024-09-26 12:42:45 字数 1618 浏览 0 评论 0原文

我们有一个需求,在同一台机器上的多个目录中安装相同的软件。我想使用批处理文件安装该软件。我在使用作为目录名称传入的变量时遇到困难。 (我使用的是VS 2010)。

批处理文件代码 msiexec /i "SetupProjectTestMultiInstalls.msi" CUSTOMER="TESTCUSTOMER"

但是创建的路径是 C:\Program Files\SetupProjectTestMultiInstalls[客户] 与我想要的相反 C:\Program Files\SetupProjectTestMultiInstalls\TESTCUSTOMER

这是我的 wix xml

    <Media Id="1" Cabinet="media1.cab" EmbedCab="yes" />
<?define MYVARIABLE = "Temp" ?>
<?define FORMDIR = "$(var.SolutionDir)WindowsFormsApplication1\bin\Debug\"?>

<Condition Message="CUSTOMER variable must be set in the command line">
  CUSTOMER
</Condition>
    <Directory Id="TARGETDIR" Name="SourceDir">
        <Directory Id="ProgramFilesFolder">
            <Directory Id="INSTALLLOCATION" Name="SetupProjectTestMultiInstalls">
      <Directory Id="Customer" Name="[CUSTOMER]">
      <Component Id="ConfigFiles" Guid ="4fdbee76-d149-11df-aa02-05feded72085">
        <File Id="WindowsFormsApplication1.exe" DiskId ="1" Vital="yes" ReadOnly="no"
              Name="WindowsFormsApplication1.exe"
              Source ="$(var.FORMDIR)WindowsFormsApplication1.exe" />
      </Component>
            </Directory>
        </Directory>
    </Directory>
</Directory>
    <Feature Id="ProductFeature" Title="SetupProjectTestMultiInstalls" Level="1">
        <ComponentGroupRef Id="Product.Generated" />
  <ComponentRef Id="ConfigFiles" />
    </Feature>
</Product>

任何想法

谢谢

杰克

We have a requirement to install the same software in multiple directories on the same machine. I want to install the software using a batch file. I am having difficulty using the variable I have passed in as a directory name. (I am using VS 2010).

Batch file code
msiexec /i "SetupProjectTestMultiInstalls.msi" CUSTOMER="TESTCUSTOMER"

However the path created is
C:\Program Files\SetupProjectTestMultiInstalls[CUSTOMER]
as oppose to what I want
C:\Program Files\SetupProjectTestMultiInstalls\TESTCUSTOMER

Here is my wix xml

    <Media Id="1" Cabinet="media1.cab" EmbedCab="yes" />
<?define MYVARIABLE = "Temp" ?>
<?define FORMDIR = "$(var.SolutionDir)WindowsFormsApplication1\bin\Debug\"?>

<Condition Message="CUSTOMER variable must be set in the command line">
  CUSTOMER
</Condition>
    <Directory Id="TARGETDIR" Name="SourceDir">
        <Directory Id="ProgramFilesFolder">
            <Directory Id="INSTALLLOCATION" Name="SetupProjectTestMultiInstalls">
      <Directory Id="Customer" Name="[CUSTOMER]">
      <Component Id="ConfigFiles" Guid ="4fdbee76-d149-11df-aa02-05feded72085">
        <File Id="WindowsFormsApplication1.exe" DiskId ="1" Vital="yes" ReadOnly="no"
              Name="WindowsFormsApplication1.exe"
              Source ="$(var.FORMDIR)WindowsFormsApplication1.exe" />
      </Component>
            </Directory>
        </Directory>
    </Directory>
</Directory>
    <Feature Id="ProductFeature" Title="SetupProjectTestMultiInstalls" Level="1">
        <ComponentGroupRef Id="Product.Generated" />
  <ComponentRef Id="ConfigFiles" />
    </Feature>
</Product>

Any ideas

Thanks

Jake

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

时间海 2024-10-03 12:42:45

您可以使用 INSTALLDIR 而不是 CUSTOMER 执行类似的操作,从命令行传递位置:

msiexec /i "SetupProjectTestMultiInstalls.msi" INSTALLDIR="C:\Program Files\SetupProjectTestMultiInstalls\TESTCUSTOMER"

<Directory Id="TARGETDIR" Name="SourceDir">
  <Directory Id="ProgramFilesFolder">
    <Directory Id="INSTALLDIR" Name=".">
      <Component Id="ConfigFiles" Guid ="4fdbee76-d149-11df-aa02-05feded72085">
        <File Id="WindowsFormsApplication1.exe" DiskId ="1" Vital="yes" ReadOnly="no"
          Name="WindowsFormsApplication1.exe"
          Source ="$(var.FORMDIR)WindowsFormsApplication1.exe" />
      </Component>
    </Directory>
  </Directory>
</Directory>

但是,我不认为您可以多次运行安装程序以将软件安装到不同的位置。如果产品 ID 已被使用,那么它可能会进行修复而不是全新安装。

You can do something like this using INSTALLDIR instead of CUSTOMER to pass the location from the command line :

msiexec /i "SetupProjectTestMultiInstalls.msi" INSTALLDIR="C:\Program Files\SetupProjectTestMultiInstalls\TESTCUSTOMER"

<Directory Id="TARGETDIR" Name="SourceDir">
  <Directory Id="ProgramFilesFolder">
    <Directory Id="INSTALLDIR" Name=".">
      <Component Id="ConfigFiles" Guid ="4fdbee76-d149-11df-aa02-05feded72085">
        <File Id="WindowsFormsApplication1.exe" DiskId ="1" Vital="yes" ReadOnly="no"
          Name="WindowsFormsApplication1.exe"
          Source ="$(var.FORMDIR)WindowsFormsApplication1.exe" />
      </Component>
    </Directory>
  </Directory>
</Directory>

However, I don't think that you can run the installer several times to install the software to different places. If the Product Id is already used then it will probably do a repair instead of a fresh install.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文