Skip to content

Conversation

@bergmeister
Copy link
Contributor

@bergmeister bergmeister commented Jan 2, 2018

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 @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
Member

@bergmeister Thanks for doing this. I think I prefer the submenu to starting a process to start elevated PowerShell. cc @joeyaiello

@bergmeister
Copy link
Contributor Author

bergmeister commented Jan 3, 2018

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
Copy link
Contributor Author

bergmeister commented Jan 3, 2018

@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
Copy link
Contributor Author

bergmeister commented Jan 3, 2018

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.

Copy link
Member

@SteveL-MSFT SteveL-MSFT left a comment

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
Copy link
Contributor Author

bergmeister commented Jan 4, 2018

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 SteveL-MSFT added the Documentation Needed in this repo Documentation is needed in this repo label Jan 4, 2018
@SteveL-MSFT
Copy link
Member

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

@sdwheeler
Copy link
Collaborator

sdwheeler commented Jan 4, 2018

@bergmeister @SteveL-MSFT Please create an issue for this in the PowerShell-Docs repo. It should probably be assigned to @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
Member

Created MicrosoftDocs/PowerShell-Docs#2007

@bergmeister
Copy link
Contributor Author

@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 @SteveL-MSFT ?

@SteveL-MSFT
Copy link
Member

@bergmeister this is planned for 6.1

@iSazonov
Copy link
Collaborator

iSazonov commented Jan 5, 2018

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 iSazonov self-assigned this Jan 5, 2018
@iSazonov
Copy link
Collaborator

iSazonov commented Jan 5, 2018

Do you think we should document the new property EXPLORER_CONTEXT_MENU_OPENPOWERSHELL

Maybe ADD_EXPLORER_CONTEXT_MENU_OPENPOWERSHELL.

iSazonov
iSazonov approved these changes Jan 5, 2018
@bergmeister
Copy link
Contributor Author

@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
Collaborator

iSazonov commented Jan 5, 2018

@bergmeister Thanks!
I'll open a Issue about PSModulePath if @SteveL-MSFT approve.

<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.

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