Daniel Harms
Daniel Harms

Reputation: 1208

WiX -- Installing files to system drive

I'm working on an installer that drops some files into another application that keeps its files at [SystemDrive]\appName. The installer is only used in internal automation, so it's fine if it doesn't consider other install locations.

I've found that by default WiX sets the target directory to the drive with the most free space. What's the best way to specify a certain directory in the system drive instead?

Upvotes: 6

Views: 5465

Answers (2)

Sunil Agarwal
Sunil Agarwal

Reputation: 4277

Set the value of rootdrive to the drive you want

<CustomAction Id='SetRootDrive' Property='ROOTDRIVE' Value='[%SystemDrive]\'/>

System drive will be by default the default drive used by OS

Added code to call 'SetRootDrive' action: You need to call it from InstallUISequence

<InstallUISequence>
  <Show Dialog="MyWelcomeDlg" Before="CostFinalize">NOT Installed</Show>
  <!-- App search is what does FindInstallLocation, and it is dependent on FindRelatedProducts -->
  <AppSearch After="FindRelatedProducts"/>
  <Custom Action="SetRootDrive" Before="CostInitialize"></Custom>
</InstallUISequence>

Upvotes: 6

Bob Arnson
Bob Arnson

Reputation: 21886

MSI already gives you the value in the WindowsVolume property. Use that as the parent Directory/@Id.

Upvotes: 3

Related Questions