[wix-users] Using user's home directory as working directory (a.k.a startup directory) for shortcuts

Christopher Painter chrpai at iswix.com
Tue Jan 5 10:19:04 PST 2021


FWIW,  I typically like to put this kind of logic in my application startup code.   It's a really easy problem to solve in code and prevents my application behavior from being dependent on the way a shortcut was defined.   For example a user might just create some random shortcut that wasn't even created by the installer and this way it would still behave the way I desire.

________________________________
From: wix-users <wix-users-bounces at lists.wixtoolset.org> on behalf of Herman van Drie via wix-users <wix-users at lists.wixtoolset.org>
Sent: Tuesday, January 5, 2021 10:39 AM
To: WiX Toolset Users Mailing List <wix-users at lists.wixtoolset.org>
Cc: Herman van Drie <hvandrie at outlook.com>
Subject: Re: [wix-users] Using user's home directory as working directory (a.k.a startup directory) for shortcuts

Windows Installer doesn't like unresolvable properties for shortcuts.
If you want to create a shortcut as you prefer, you need to use to utilize the api itself and create a shortcut using a CA:

https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-ishelllinka-setworkingdirectory
https://docs.microsoft.com/en-us/windows/win32/shell/links

You could also use a vbscript CA located in Binary table, this works as expected:

        set WshShell = CreateObject("WScript.Shell")
        set oShellLink = WshShell.CreateShortcut(session.Property[DesktopFolder] & "MyShortcut.lnk")
        oShellLink.TargetPath = session.Property[#MyApplication.Exe]
        oShellLink.WindowStyle = 1
        oShellLink.IconLocation = session.Property[#MyApplication.Exe] & ", 0"
        oShellLink.WorkingDirectory = "%USERPROFILE%"
        oShellLink.Save

Cheers,

Herman

-----Original Message-----
From: wix-users <wix-users-bounces at lists.wixtoolset.org> On Behalf Of Clifford Yapp via wix-users
Sent: dinsdag 5 januari 2021 16:44
Cc: Clifford Yapp <cliffyapp at gmail.com>; WiX Toolset Users Mailing List <wix-users at lists.wixtoolset.org>
Subject: Re: [wix-users] Using user's home directory as working directory (a.k.a startup directory) for shortcuts

I should provide a little more context:

When the attempt was made to do this for Powershell, they looked at using the WorkingDirectory property in Shortcut:
https://github.com/PowerShell/PowerShell/pull/6043#discussion_r164277035

Apparently, trying to store environment variables there didn't work - either they were evaluated, or the quoting resulted in invalid variables in the final install.  I was hoping there is some sort of special variable or syntax the Windows Installer might recognize to allow unresolved variables in the final shortcuts.

Thanks,
Cliff

On Tue, Jan 5, 2021 at 10:33 AM Clifford Yapp <cliffyapp at gmail.com> wrote:

> I was actually hoping to use something like %USERPROFILE% as the
> "Start In" directory - setting this manually in Windows on the link
> files appears to do what I would expect.
>
> Thanks,
> Cliff
>
>

____________________________________________________________________
WiX Toolset Users Mailing List provided by FireGiant http://www.firegiant.com/

____________________________________________________________________
WiX Toolset Users Mailing List provided by FireGiant http://www.firegiant.com/



More information about the wix-users mailing list