How to force Directory point to C:\? - wix

I've tried:
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ROOT_FOLDER" />
but ROOT_FOLDER sometimes pointing to C: drive, sometimes to other drives, on different machines. How can I fix and tell it should be C drive root?

There's a built-in Windows Installer property for this, it's called ROOTDRIVE. As you can see from its description:
...the installer sets ROOTDRIVE to the local drive that can be written to
having the most free space.
If you always need it to be C, you can add a record to the Property table for this. In WiX, this is done like this:
<property id="ROOTDRIVE" value="C:\" />

Related

I have created an msi file which i ran from D drive, even though it is installing in the C drive only. how can i change the installation path?

As i have this in my wix application it should install the msi file from where it is running . like if i run from D drive it should take SourceDir as D , but it is taking as C only . how to change it to D drive ?
According to this, TARGETDIR will default to the commandline value (if specified), then the ROOTDRIVE (usually C:) then the drive with the largest amount of space available.
The directory you opened your msi from has absolutely no bearing on the value of TARGETDIR which roots your directory installation path. If you want to allow the user to change the installation path you can implement WixUI_InstallDir UI or, using it as an example, implement your own UI. You can also usually make the Install's root folder (Usually the name of the Company or Product itself) have a public ID so that it can be set in the command line. Alternatively you can create a custom action to read the value of SourceDir and force the TARGETDIR to use the root of the SourceDir path (where you launched the installer) however this is not recommended.
I did this by setting a parameter when I run the installation (My default installation drive was C but sometimes I want to install on D drive):
ReSecServer.msi /L*v log.log APPLICATIONROOTDIRECTORY="D:\Program Files (x86)\XServer"
Here is an example of my directories:
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="APPLICATIONROOTDIRECTORY" Name="XServer">
</Directory>
</Directory>
</Directory>

How can you set an installer to install to the default IIS directory?

So, this is a followup to this question. It appears that TARGETDIR defaults to the drive with the most free space. How can I get a directory structure to be based in the default IIS directory (regardless of the drive on which that resides)?
<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="IISMain" Name="inetpub">
First you have to figure out where IIS expects its default folder to be. I'm not sure that is officially documented anywhere. If it, use that documentation to define it.
If we're just guessing, then I'd guess that it's the inetpub folder on the WindowsVolume. To implement that guess, I'd use your directory tree then do something like:
<SetDirectory Id='IISMain' Value='[WindowsVolume]\inetpub' />
Again, that's just a guess because I've never found documentation that says where IIS default folder is. If you find the documentation, use that definition instead.

Copy files to network share with WiX

As a part of my project, the installer has to copy files to network share(\system_name\Folder). I have tried it using the <Directory> element defining the path to the share (NetHoodFolder property) but it's throwing an error.
Error 5 ICE64: The directory SP9381 is in the user profile but is not listed in the RemoveFile table. C:\Wix\MainProject\MainProject\Product.wxs 25 1 MainProject
Can we do the same using element ? Is there any other way to copy files to network share?
You can copy files to a network share but there are a number of limitations. First, to get around the ICE issue, try structuring your directory tree like so:
<Directory Id='TARGETDIR' Source='SourceDir'>
<Directory Id='ProgramFilesFolder' Name='PFiles'>
<Directory Id='NETWORKSHAREFOLDER' Name='network'>
</Directory>
</Directory>
Then somehow you need to get the network share to be known. You could ask in the UI or take it from the command-line or whatever. I hardcoded the string in my test case (definitely not recommended for reals):
<Property Id='NETSHARE' Value='\\server\share\folder' />
<SetDirectory Id='NETWORKSHAREFOLDER' Value='[NETSHARE]' />
If you wanted to pass it on the command line, don't add any of the above, just do:
msiexec /i path\to\your.msi NETWORKSHAREFOLDER="\\server\share\folder"
Basically, just root your NETWORKSHAREFOLDER in a well known folder and then change it later as explained above.

How to give INSTALLDIR folder permission in WIX?

I am designing a WIX 3.6 installer project, during the installation we need to grand the user create file permission to the install folder(INSTALLDIR, especially with the default install folder, the Program Files, the user normally can't create file in the installation. We've experienced some failures). I guess it can be achieved by setting a Permission element, with CreateFile property. However, the INSTALLDIR is a directory, and only such elements as CreateFolder, File, FileShare, Registry, ServiceInstall can have permission element. So could anyone tell me how to do that? My directory declaration is something like this:
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFiles64Folder">
<Directory Id='MANUFACTUREFOLDER' Name='$(var.ManufacturerName)'>
<Directory Id="INSTALLDIR" Name="$(var.ProductName)">
Thanks!
UPDATED:
Now I have managed to create a file (not the deployed file. But a generated file based on one deployed file, and it is generated in a custom action in commit phase). However, I now have a problem deleting the deployed file I just described (because there is no use of it after the other file is successfully generated). When the installation folder is Program Files, I can't delete it in the custom action. It says access denied.
Another thing is, I really don't understand the purpose of CreateFolder element. If its aim is to create a folder, as its name implies, don't nested Directory(s) do the same thing, as in my example code? And I think it is more clear to describe the folder structure there since it is very common to separate the Component elements (in which CreateFolder elements will reside) and the Directory elements. The Component will just use DirectoryReference to refer to the correct directory. Secondly, it is also common that multiple Components reside in the same Directory. So if I add a CreateFolder to one of those Components, with the default directory as the common parent directory of those Components, what does it even mean? It is really not intuitive of such a structure.
As you noted, CreateFolder elements may have Permission elements, and they default to the directory of the parent component if no directory is specified. So the structure would look something like the following.
<Directory Id="INSTALLDIR" Name="$(var.ProductName)">
<Component>
<CreateFolder>
<Permission>
</Permission>
</CreateFolder>
</Component>
</Directory>
However, based on Vista and Windows 7 restrictions and Windows Logo guidelines, I wouldn't be surprised if you still have issues with this, since the Program Files directory is pretty locked down. After install you should not be writing to this directory.

Copying multiple files using wildcards/recursively using Wix

I'm a total noob on Wix (and installers in general) so please forgive me.
My goal is to be able to traverse a directory, search for all, say, *.exe files and copy them to a predefined destination folder. Thing is, I don't know what these files are and their names so I can't type them out one by one in the wxs file... hence wildcards.
Now, I ended up with something like this:
...
<Directory Id='TARGETDIR' Name='SourceDir'>
<Directory Id='ProgramFilesFolder' Name='PFiles'>
<Directory Id='MyDir' Name='TestProj'>
<Component Id='MyComponent' Guid='PUT_GUID_HERE'>
<CopyFile Id="CopyFiles" DestinationProperty="DESTDIR" SourceName="*.exe" SourceProperty="SRCDIR" />
</Component>
</Directory>
</Directory>
</Directory>
...
Well, this is ok if I'm reading only from SRCDIR but what if there are subfolders? How do I go down looking for files with a certain extension? Or is there another way of doing this...?
Same thing with removing those same files after the installation...
Thanks a bunch for any help you can give!
A way to do this is using John Robbin's command line tool Paraffin. It goes automatically through the directories you select and creates a WiX fragment that references these files. Paraffin is great for this since it supports adding new files later without creating new GUIDs for the old files - i.e. it supports an evolving project.