Skip to content

Installer should start PS Core with user's home dir as the working dir #5705

Description

Steps to reproduce

Install PS Core rc2 and at the select check the box to start PowerShell.
Find PowerShell Core in the task bar, right-click it and select "Pin to taskbar"

Expected behavior

PowerShell Core as started by the installer, starts in my home dir.
PowerShell Core as started by the taskbar icon, starts in my home dir.

Actual behavior

PowerShell Core in both cases starts in C:\Program Files\PowerShell\6.0.0-rc.2.

I wind up having to edit the taskbar shortcut's properties to change the "Start in:" location to %USERPROFILE% - which works but I shouldn't have to do this. I suspect other folks will use the PS Core started by the installer as the easy means to get PS Core pinned to their taskbar.

If the installer could set the working dir to the current user's home dir before launching PowerShell, that would probably fix both scenarios.

Environment data

> $PSVersionTable
Name                           Value
----                           -----
PSVersion                      6.0.0-rc.2
PSEdition                      Core
GitCommitId                    v6.0.0-rc.2
OS                             Microsoft Windows 10.0.16299
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Activity

  1. bergmeister commented on Jan 4, 2018

    @bergmeister
    Contributor

    Keith Hill (@rkeithhill) My branch here has modified the installer to launch PowerShell when having ticked the checkbox as pwsh.exe -NoExit -Command Set-Location $env:HOME. However, if I then right-click on the shell and pin it to the taskbar, the Start in is still the installation location of pwsh.

  2. rkeithhill commented on Jan 4, 2018

    @rkeithhill
    CollaboratorAuthor

    Try changing the Directory="INSTALLFOLDER" attribute. Hopefully WiX has a predefined variable for the user's home dir.

  3. rkeithhill commented on Jan 4, 2018

    @rkeithhill
    CollaboratorAuthor

    Looks like you can use either [%USERPROFILE] or [%HOMEDRIVE][%HOMEPATH]. See https://stackoverflow.com/questions/9635813/how-can-i-reference-the-users-home-directory-in-wix The last answer has a number of WiX steps that you might need to follow.

  4. bergmeister commented on Jan 4, 2018

    @bergmeister
    Contributor

    Thanks for the pointers. I am struggling to get a valid syntax that Wix accepts at the moment but will come back to it tomorrow.

  5. SteveL-MSFT commented on Jan 5, 2018

    @SteveL-MSFT
    Member

    The last time I looked into this, I couldn't find a way to get this to work because the environment variables get resolved at install time, not runtime. Also tried to escape the string so it shows up as literally %USERPROFILE% in the shortcut, but Wix doesn't allow it.

  6. SteveL-MSFT commented on Jun 14, 2018

    @SteveL-MSFT
    Member

    Looks like this isn't actually fixed. Working on a PR.

  7. rkeithhill commented on Jun 14, 2018

    @rkeithhill
    CollaboratorAuthor

    Yup, just noticed that.

  8. bergmeister commented on Jun 14, 2018

    @bergmeister
    Contributor

    The new -WorkingDirectory parameter should make it possible to overcome WiX's syntax limitations. One can already configure a shortcut manually after installation.

  9. SteveL-MSFT commented on Jun 14, 2018

    @SteveL-MSFT
    Member

    Christoph Bergmeister (@bergmeister) yeah, I think what happened is that Ilya (@iSazonov) made a fix, but we reverted it planning on using the new -WorkingDirectory parameter, but the work to actually add that was missed. I'll have a PR submitted shortly.

  10. added a commit that references this issue on Jun 20, 2018
    b25c1f6
  11. added a commit that references this issue on Aug 6, 2026
    6e0b0eb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions