Skip to content

Add option to add explorer context menu in Windows installer - #5774

Merged
Ilya (iSazonov) merged 22 commits into
PowerShell:masterfrom
bergmeister:wix_explorer_contextmenu
Jan 5, 2018
Merged

Ilya (iSazonov) merged 22 commits into
PowerShell:masterfrom
bergmeister:wix_explorer_contextmenu

Conversation

@bergmeister

@bergmeister Christoph Bergmeister (bergmeister) commented Jan 2, 2018 •

Copy link
Copy Markdown
Contributor

PR Summary

A new dialogue is added in the Windows installer to offer the option of adding explorer.exe context menus to open PowerShell in the current location as a normal shell or as administrator. The context menu entries are achiveven via registry entries and is available when right-clicking on:

  • the background of explorer
  • a folder in explorer
  • a drive in explorer
  • on the Desktop

Adding the new custom dialog required copy-pasting the WiX source code of WixUI_InstallDir.wxs as a base as described in the official WiX documentation here.
The registry entries are quite standard but the approach for the context menu of opening PowerShell as an Administrator must be discussed:
The Windows registry has the limitation that it only offers a runas/command structure but not a runas/proogram/command structure, which means there can only be one main context entry to open PowerShell as an Admin. Since a user might have alerady configured this context menu, I decided that it is best to not stomp over it but rather open PowerShell normally but then elevate it. This of course has the disadvantage that it takes a bit longer and a window is visible for a brief moment. The only alternative that would allow to launch PowerShell elevated the first time is to have the 2 context menu in a submenu, see here
The registry keys contain the PowerShell version to cater for side by side installations of future versions.
Some stuff had to be created in a WiX fragment, which means that this XML section could be factored out into its own file (with the disadvantage of having to linkt this file then into the compilation process of candle,, light, etc.)
The best person to review is probably Steve Lee (@SteveL-MSFT)

This is how it currently looks like:
Installer:
image
Explorer context menu:
image

PR Checklist

Note: Please mark anything not applicable to this PR NA.

Because this is the first custom dialog, I had to take in the source code of WixUI_InstallDir and modify as it is officially recommended http://wixtoolset.org/documentation/manual/v3/wixui/wixui_customizations.html
…he future.

refactor common usage of pwsh.exe path
… error). I found that New-MsiPackage does not cleanup the temporary wix files and therefore did not see the errors myself first locally.
Due to a limitation of the registry, the admin prompt has to launch from a PS process. the only alternative would be to use sub menus: https://blogs.msdn.microsoft.com/andrew_richards/2017/03/01/enhancing-the-open-command-prompt-here-shift-right-click-context-menu-experience/
@SteveL-MSFT

Copy link
Copy Markdown
Member

Christoph Bergmeister (@bergmeister) Thanks for doing this. I think I prefer the submenu to starting a process to start elevated PowerShell. cc Joey Aiello (@joeyaiello)

@bergmeister

Christoph Bergmeister (bergmeister) commented Jan 3, 2018 •

Copy link
Copy Markdown
Contributor Author

Ok. Any preference on the naming of the menu? I am thinking of PowerShell X.Y.Z for the menu and then Open here and Open here as Administrator here for the 2 submenus.

@bergmeister

Christoph Bergmeister (bergmeister) commented Jan 3, 2018 •

Copy link
Copy Markdown
Contributor Author

Steve Lee (@SteveL-MSFT) I changed it to use submenus to properly elevate it. This is how it looks now (the logic whether the submenu pops out on the left or right hand side is handled by Windows depending on where one right-clicks):
image

@bergmeister

Christoph Bergmeister (bergmeister) commented Jan 3, 2018 •

Copy link
Copy Markdown
Contributor Author

NB: I also tweaked the tabbing index on the new installer page to be consistent with other WiX dialogues and to be able to use the spacebar to toggle the checkbox. Additionally, the context menus also have accessibility shortcuts now, which means that the top context menu can be selected using the P key (or pressing it multiple times if other menus also have the same key configured) and H or A for the submenus (the latter is the Admin shell). I am done now and the PR can be reviewed again.

@SteveL-MSFT Steve Lee (SteveL-MSFT) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, built off your branch and works for me. Great work!

@bergmeister

Christoph Bergmeister (bergmeister) commented Jan 4, 2018 •

Copy link
Copy Markdown
Contributor Author

Thanks. Do you think we should document the new property EXPLORER_CONTEXT_MENU_OPENPOWERSHELL for people who want to install the MSI quietly (/q option of msiexec.exe) to allow them to use this new feature as well?

@SteveL-MSFT Steve Lee (SteveL-MSFT) added the Documentation Needed in this repo Documentation is needed in this repo label Jan 4, 2018
@SteveL-MSFT

Copy link
Copy Markdown
Member

Christoph Bergmeister (@bergmeister) yes, we should document it. However, since this msi is new, we don't have an existing doc to put it. Sean Wheeler (@sdwheeler) can you suggest how we should document the property that can be passed to the msi installer for non-interactive (quiet) installs?

@sdwheeler

Sean Wheeler (sdwheeler) commented Jan 4, 2018 •

Copy link
Copy Markdown
Contributor

Christoph Bergmeister (@bergmeister) Steve Lee (@SteveL-MSFT) Please create an issue for this in the PowerShell-Docs repo. It should probably be assigned to Joey Aiello (@joeyaiello). He is working on the V6 setup docs. Joey and I can work out how and where this should be documented. Also include all possible MSI properties that could be used so we can be complete.

@SteveL-MSFT

Copy link
Copy Markdown
Member

Created MicrosoftDocs/PowerShell-Docs#2007

@bergmeister

Copy link
Copy Markdown
Contributor Author

Sean Wheeler (@sdwheeler) The new property is the only one as far as I am aware. But I thought that this would go only into 6.1 or this a candidate for merge to the release branch Steve Lee (@SteveL-MSFT) ?

@SteveL-MSFT

Copy link
Copy Markdown
Member

Christoph Bergmeister (@bergmeister) this is planned for 6.1

@iSazonov

Copy link
Copy Markdown
Collaborator

Currently we have a nuget package to set PSModulePath with Windows PowerShell module paths. It is not obvious. My request (for follow PR) is to add the option to the installer too.

@iSazonov Ilya (iSazonov) self-assigned this Jan 5, 2018
@iSazonov

Copy link
Copy Markdown
Collaborator

Do you think we should document the new property EXPLORER_CONTEXT_MENU_OPENPOWERSHELL

Maybe ADD_EXPLORER_CONTEXT_MENU_OPENPOWERSHELL.

iSazonov
Ilya (iSazonov) approved these changes Jan 5, 2018 •
@bergmeister

Copy link
Copy Markdown
Contributor Author

Ilya (@iSazonov) I applied your renaming suggestion. Please open an issue about your PSModulePath request with more details in it, I would be happy to help you by doing the UI/WiX bit of it in case you haven't worked much with WiX much yet.

@iSazonov

Copy link
Copy Markdown
Collaborator

Christoph Bergmeister (@bergmeister) Thanks!
I'll open a Issue about PSModulePath if Steve Lee (@SteveL-MSFT) approve.

Comment thread assets/Product.wxs
<Publish Dialog="LicenseAgreementDlg" Control="Back" Event="NewDialog" Value="WelcomeDlg">1</Publish>
<Publish Dialog="LicenseAgreementDlg" Control="Next" Event="NewDialog" Value="InstallDirDlg">LicenseAccepted = "1"</Publish>

<Publish Dialog="ExplorerContextMenuDialog" Control="Back" Event="NewDialog" Value="InstallDirDlg">1</Publish>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This implementation of the Back button looks OK, does not have bug #12055 yet.

Thatgfsj (Thatgfsj) pushed a commit to Thatgfsj-contribs/PowerShell that referenced this pull request Aug 6, 2026
…ell#5774)

A new dialogue is added in the Windows installer to offer the option of adding explorer.exe context menus to open PowerShell in the current location as a normal shell or as administrator. The context menu entries are achiveven via registry entries and is available when right-clicking on:
- the background of explorer
- a folder in explorer
- a drive in explorer
- on the Desktop
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants