Skip to content

Feature: Windows Installer to offer option of context menu to open PowerShell in explorer #5012

Closed

Description

As a user, I often want to start PowerShell in the current directory in which I am browsing in explorer.exe.
Being able to have a context menu so that I can just right click and select Open PowerShell here or Open PowerShell as Admininstrator here would be very useful. Although a user can setup this manually via the Windows registry (see e.g. here), this is a tedious process that is often not worth the effort and therefore should rather be replaced by an option in the installer.
What do you think?

Activity

  1. added
    WG-Maintainers-Build
    Issue-Enhancement
    Hacktoberfest
    Up-for-Grabs
    on Oct 4, 2017
  2. SteveL-MSFT commented on Oct 4, 2017

    @SteveL-MSFT
    Member

    I think if you can make it a checkbox in the installer, then it seems like a great feature.

  3. xee5ch commented on Oct 7, 2017

    @xee5ch

    I have been meaning to learn about WiX for years now, and a quick examination shows this is a WiX-based installer. Can I take a stab at this?

  4. bergmeister commented on Oct 7, 2017

    @bergmeister
    ContributorAuthor

    Yes, it is a WiX based installer and quite a simple one, which is great to get started (all you need to have installed is the WiX toolset here). I have not started on it yet, so feel free to give it a try and also ask any questions you have. :)
    It is very easy to build the installer via this PowerShell function here and you do not even need to build the whole PowerShell project, you could just point the -ProductSourcePath parameter to a bin folder of a dummy project as long as it contains a file named powershell.exe (this is just a tip if you want to speedup compilation). When you run it you will see some warnings but you can ignore them. The script will always tell you where the expected MSI will be, even if there was an error, which means if you cannot find the MSI, you need to search for the WiX error in the verbose output.
    What you will need to do is basically creating and setting registry entries, which means that this action needs to happen in the part where the installer runs with elevated rights, i.e. you will probably need to create a new dialogue with 2 checkboxes. As part of this you will learn that WiX checkboxes to not give you true/false values but instead you need to check if the associated variables value is either set or not.
    Note that the example link that I have given at the top uses HKEY_CLASSES_ROOT but it might be better to use HKEY_CURRENT_USER. In terms of registry entries, I found that 2 entries need to be added:

    • One in the Directory\Background folder to enable the context menu when right clicking any where in explorer
    • Another one in Directory\shell to enable the context menu when right clicking on a specific folder
      The syntax between the 2 will be slightly different

    You will find that there are already folders named Powershell of Windows PowerShell in the registry so you will need to come up with a new folder name, so maybe PowerShellCore6? Since the installer does not allow side by side installation any more, a version number is not needed at the moment but it might be better since this might change in the future.,

  5. removed
    Up-for-Grabs
    on Oct 7, 2017
  6. SteveL-MSFT commented on Oct 7, 2017

    @SteveL-MSFT
    Member

    Al (@xee5ch) consider this yours! I've assigned it to myself as GitHub won't allow me to assign it to you, but I don't want other people duplicating your work.

  7. xee5ch commented on Oct 8, 2017

    @xee5ch

    Ok. Not sure on the ETA. I am newbish to Powershell, love what's being done, and need to review how to get the registry keys for the context menu (I know that part) but need to figure WiX and how to get that together.

    Hopefully will be back in the next few days with something passable. Thanks for the more welcome.

  8. xee5ch commented on Oct 8, 2017

    @xee5ch

    And just saw your comments, Christoph Bergmeister (@bergmeister). Apparently, you did all the research for me. That will cut down turnaround time.

  9. SteveL-MSFT commented on Oct 8, 2017

    @SteveL-MSFT
    Member

    Al (@xee5ch) don't worry about rushing it. We'll keep having ~3 week releases (even after 6.0.0 final), so it'll get into a release eventually :)

  10. xee5ch commented on Oct 8, 2017

    @xee5ch

    Roger that. But the likes of you all throwing pointers in my direction so quickly will motivate me to be good about this.

  11. 7 remaining items

  12. SteveL-MSFT commented on Nov 5, 2017

    @SteveL-MSFT
    Member

    Christoph Bergmeister (@bergmeister) I thought the original ask is a checkbox like:

    [ ] add PowerShell Core to Context Menu

    Where the context menu in Explorer would have the two options:

    Open PowerShell Core here
    Open PowerShell Core as administrator here
    
  13. bergmeister commented on Nov 5, 2017

    @bergmeister
    ContributorAuthor

    Steve Lee (@SteveL-MSFT) I was thinking of offering the user the choice between either or both context menu entries but if you prefer only one checkbox that includes admin and nonadmin then that's of course fine as well. And yes, the context menu would then look like as you described it.

  14. SteveL-MSFT commented on Nov 6, 2017

    @SteveL-MSFT
    Member

    Christoph Bergmeister (@bergmeister) apologies, I misread your screenshot. Since Windows doesn't have sudo, I think users will typically want/need both admin and non-admin.

  15. xee5ch commented on Nov 11, 2017

    @xee5ch

    So I spent the afternoon playing with this and no matter what string value I give to the ProductVersion argument of New-MSIPackage function in build.psm1, the Get-SemanticVersion call fails and does not bind a value to the necessary environment variable for the wxs declaration. I spent an hour or so on master pulling, resetting, and cleaning and I get the same result.

    I had to step a way for a bit but will post the error tonight because also setting the environment variable directly did not seem to work, so I am at a loss.

    wpap1fp

  16. bergmeister commented on Nov 11, 2017

    @bergmeister
    ContributorAuthor

    Al (@xee5ch) Just replace the call to Get-SemanticVersion inside the function with a hard coded value like 1.2.3.4 because for local testing the value does not matter. But this is why I mentioned in one of my comments above that New-MSiPackage should be refactored to be more developer friendly.

  17. bergmeister commented on Nov 11, 2017

    @bergmeister
    ContributorAuthor

    Al (@xee5ch) I also had a look at your screenshot (tip: in Github you can just drag and drop an image into the textbox and Giyhub will integrate and host the image for you) and some other parameters are wrong as well: the productsourcepath is the publish folder that it tells you after Start-psbuild and the licencefilepath must be the path to the licence.rtf file. There is also a Readme here with examples how to call the start-psbuild beforehand

  18. xee5ch commented on Nov 11, 2017

    @xee5ch

    Thanks, Christoph Bergmeister (@bergmeister), I updated the comment for posterity, since I was in a rush and I know imgur stuff goes away quickly. I was reading the help strings and had not thought much about the other docs, I should have git-grep'ed for some pointers.

    I will stuff the Get-SemanticVersion function with a hard-coded value. Perhaps I will work on that when I finish this, re developer friendly. I know I need to finish this because I have been taking my sweet time.

  19. bergmeister commented on Nov 13, 2017

    @bergmeister
    ContributorAuthor

    Al (@xee5ch) Could you manage to compile the MSI in the meantime? I came home only today, so I can give you some more straightforward copy-pastable instructions to build an MSI locally for the current latest state of master. I managed to improve it so that you do not need local modifications:

    cd $PathToYourLocalGitRepoFolder
    Import-Module .\build.psm1
    Start-PSBuild
    Import-Module .\tools\packaging\packaging.psd1
    New-MSIPackage -ProductSourcePath '.\src\powershell-win-core\bin\Debug\netcoreapp2.0\win7-x64\publish' -LicenseFilePath .\assets\license.rtf -ProductVersion '6.1.0' -AssetsPath .\assets\ -ProductTargetArchitecture x64 -Force -Verbose

    Please remember to update your Git repo/branch to the latest version due to recent changes (your fork is weeks behind but maybe you just haven't pushed yet?)

    P.S. Do not feel pressured to finish it just because of your initial interest, I can easily finish it as well if you don't want any more for whatever reason (difficult, time, etc.). The fact that it is difficult to get started on WiX here is definitely not your fault, sorry for that for that.

  20. xee5ch commented on Nov 14, 2017

    @xee5ch
  21. bergmeister commented on Dec 14, 2017

    @bergmeister
    ContributorAuthor

    Al (@xee5ch) Are you still interested/motivated in doing that (since I cannot see any work in your fork)? Do not feel pressured to do so just because you signed up for it initially. I'd be OK to finish it off myself otherwise since I myself proposed/requested this feature.

  22. xee5ch commented on Dec 16, 2017

    @xee5ch

    My gosh, so sorry. Yes, I shall work on this during the remainder of the weekend. Thanks for reminding me.

  23. bergmeister commented on Jan 2, 2018

    @bergmeister
    ContributorAuthor

    Al (@xee5ch) I appreciate your persistent motivation but there has simply been no progress at all in the last 3 months and there is not even a single commit or update in your fork. Since I created this issue originally because I would find this very useful, I will finish it off with a PR now. Your original intent was to learn about WiX so feel free to watch the PR and ask any question that you have. Otherwise there are still issues 5705, 5597, 5226, 2881 and 3341 open that are all to do with WiX if you really want to give it a go.

  24. bergmeister commented on Jan 5, 2018

    @bergmeister
    ContributorAuthor

    Steve Lee (@SteveL-MSFT) The PR got merged so I guess we can close this one?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

HacktoberfestIssue-EnhancementResolution-FixedWG-Maintainers-Build

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions