Quantcast
Channel: wixsharp Discussions Rss Feed
Viewing all articles
Browse latest Browse all 1354

New Post: ExeFileShortcut set working directory to %TEMP%

$
0
0
There are a few things that prevents your code from working. The temporary directory WiX property name is TempFoder thus you need to encode it as below:
WorkingDirectory="%TempFolder%"//or 
WorkingDirectory="[TempFolder]"//or
WorkingDirectory="TempFolder"
Though I just added to support for %Temp% as well and it will be available in the next release.

The second problem is MSI/WiX but not Wix# related. The WiX Shortcut element must be a Directory or Property identifier (not path). Thus if you have in your wxs file WorkingDirectory="TempFolder" then it is exactly what you need. However there is a problem here and I will illustrate it with the code. This is a fragment from Shortcut sample that has been modified to set working directory for an application shortcut and for the exe (msiexe.exe) shortcut:
new File(@"AppFiles\MyApp.exe",
    new FileShortcut("MyApp", "INSTALLDIR"), //INSTALLDIR is the ID of "%ProgramFiles%\My Company\My Product" new FileShortcut("MyApp", @"%Desktop%")
    {
        IconFile = @"AppFiles\Icon.ico",
        WorkingDirectory = "%Temp%"
    }),
new ExeFileShortcut("Uninstall MyApp", "[System64Folder]msiexec.exe", "/x [ProductCode]")
{
    WorkingDirectory = "%Temp%"
}),
This would lead to the correct wxs for both shortcuts:
<ShortcutId="INSTALLDIR.Uninstall_MyApp"WorkingDirectory="TempFolder"Target="[System64Folder]msiexec.exe"Arguments="/x [ProductCode]"Name="Uninstall MyApp.lnk"/><ShortcutId="Shortcut.MyApp.exe.MyApp.1"WorkingDirectory="TempFolder"Directory="DesktopFolder"Name="MyApp.lnk"Icon="IconFile1_Icon.ico"IconIndex="0"/>
This also produces correct msi table content:
Image
However for some unknown reason the final result is mixed. One shortcut gets correct working dir another one doesn't:
Image

Meaning that even after fixing your code the final result is not guaranteed.

Cheers

Viewing all articles
Browse latest Browse all 1354

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>