mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
Enable Open Here context menu on Windows to work with root of a drive (#8287)
support being started by Windows Shell (Open Here) where a trailing slash followed by a quote is handled incorrectly
This commit is contained in:
+2
-2
@@ -207,7 +207,7 @@
|
||||
<RegistryValue Type="string" Name="Icon" Value="[$(var.ProductDirectoryName)]$(env.IconPath)"/>
|
||||
</RegistryKey>
|
||||
<RegistryKey Root="HKCR" Key="Directory\ContextMenus\$(var.ProductName)$(var.SimpleProductVersion)$(sys.BUILDARCH)\shell\openpwsh\command">
|
||||
<RegistryValue Type="string" Value="[$(var.ProductDirectoryName)]pwsh.exe -NoExit -WorkingDirectory "%V" -Command "$host.UI.RawUI.WindowTitle = '$(var.ProductName) $(var.SimpleProductVersion) ($(sys.BUILDARCH))'""/>
|
||||
<RegistryValue Type="string" Value="[$(var.ProductDirectoryName)]pwsh.exe -NoExit -RemoveWorkingDirectoryTrailingCharacter -WorkingDirectory "%V!" -Command "$host.UI.RawUI.WindowTitle = '$(var.ProductName) $(var.SimpleProductVersion) ($(sys.BUILDARCH))'""/>
|
||||
</RegistryKey>
|
||||
<RegistryKey Root="HKCR" Key="Directory\ContextMenus\$(var.ProductName)$(var.SimpleProductVersion)$(sys.BUILDARCH)\shell\runas">
|
||||
<RegistryValue Type="string" Name="MUIVerb" Value="$(var.ExplorerContextSubMenuElevatedDialogText)"/>
|
||||
@@ -215,7 +215,7 @@
|
||||
<RegistryValue Type="string" Value="" Name="HasLUAShield"/>
|
||||
</RegistryKey>
|
||||
<RegistryKey Root="HKCR" Key="Directory\ContextMenus\$(var.ProductName)$(var.SimpleProductVersion)$(sys.BUILDARCH)\shell\runas\command">
|
||||
<RegistryValue Type="string" Value="[$(var.ProductDirectoryName)]pwsh.exe -NoExit -WorkingDirectory "%V" -Command "$host.UI.RawUI.WindowTitle = '$(var.ProductName) $(var.SimpleProductVersion) ($(sys.BUILDARCH))'""/>
|
||||
<RegistryValue Type="string" Value="[$(var.ProductDirectoryName)]pwsh.exe -NoExit -RemoveWorkingDirectoryTrailingCharacter -WorkingDirectory "%V!" -Command "$host.UI.RawUI.WindowTitle = '$(var.ProductName) $(var.SimpleProductVersion) ($(sys.BUILDARCH))'""/>
|
||||
</RegistryKey>
|
||||
</Component>
|
||||
</Directory>
|
||||
|
||||
@@ -188,7 +188,8 @@ namespace Microsoft.PowerShell
|
||||
"command",
|
||||
"settingsfile",
|
||||
"help",
|
||||
"workingdirectory"
|
||||
"workingdirectory",
|
||||
"removeworkingdirectorytrailingcharacter"
|
||||
};
|
||||
|
||||
internal CommandLineParameterParser(PSHostUserInterface hostUI, string bannerText, string helpText)
|
||||
@@ -401,9 +402,25 @@ namespace Microsoft.PowerShell
|
||||
|
||||
internal string WorkingDirectory
|
||||
{
|
||||
get { return _workingDirectory; }
|
||||
get
|
||||
{
|
||||
#if !UNIX
|
||||
if (_removeWorkingDirectoryTrailingCharacter && _workingDirectory.Length > 0)
|
||||
{
|
||||
return _workingDirectory.Remove(_workingDirectory.Length - 1);
|
||||
}
|
||||
#endif
|
||||
return _workingDirectory;
|
||||
}
|
||||
}
|
||||
|
||||
#if !UNIX
|
||||
internal bool RemoveWorkingDirectoryTrailingCharacter
|
||||
{
|
||||
get { return _removeWorkingDirectoryTrailingCharacter; }
|
||||
}
|
||||
#endif
|
||||
|
||||
#endregion Internal properties
|
||||
|
||||
#region static methods
|
||||
@@ -934,6 +951,12 @@ namespace Microsoft.PowerShell
|
||||
|
||||
_workingDirectory = args[i];
|
||||
}
|
||||
#if !UNIX
|
||||
else if (MatchSwitch(switchKey, "removeworkingdirectorytrailingcharacter", "removeworkingdirectorytrailingcharacter"))
|
||||
{
|
||||
_removeWorkingDirectoryTrailingCharacter = true;
|
||||
}
|
||||
#endif
|
||||
else
|
||||
{
|
||||
// The first parameter we fail to recognize marks the beginning of the file string.
|
||||
@@ -1364,6 +1387,10 @@ namespace Microsoft.PowerShell
|
||||
private string _file;
|
||||
private string _executionPolicy;
|
||||
private string _workingDirectory;
|
||||
|
||||
#if !UNIX
|
||||
private bool _removeWorkingDirectoryTrailingCharacter = false;
|
||||
#endif
|
||||
}
|
||||
} // namespace
|
||||
|
||||
|
||||
Reference in New Issue
Block a user