Dev
Dev

Reputation: 1020

How to check the existence of D and E drives in WIX?

I want to install my application into E drive (E:\MyApp) if not exists then D drive (D:\MyApp), if D drive also doesn't exist in the target computer then I want to install in C drive (C:\MyApp). Which variable should I use in preproccessor to check drive existence ? Can anyone help me?

<?if E Drive exists ?> 
<?define varRootDrive = "E:\" ?> 
<?elseif  D Drive exists ?> 
<?define varRootDrive = "D:\" ?> 
<?else ?> 
<?define varRootDrive = "C:\" ?> 
<?endif ?> 
<?endif ?> 

<Property Id="TARGETDIR"> $(var.varRootDrive) </Property>

Upvotes: 2

Views: 985

Answers (1)

Christopher Painter
Christopher Painter

Reputation: 55571

The preprocessor statements evaluate at build time not install time. You will need a custom action to detect if valid drive letters exist and to set the installlocation dynamically at install time.

Upvotes: 1

Related Questions