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 i开发者_如何学运维s 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
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.
精彩评论