pwsh: add context menu (explorer, file) (#3411)

* pwsh: add context menu (explorer, file)

* pwsh: fix regedit script line ending

* pwsh: rename to powershell core, rewrite post_install script

* change regedit path from powershell7 to powershellcore as a name

Co-authored-by: Gitea <gitea@fake.local>
This commit is contained in:
Oussama Delassi 2022-03-21 06:32:36 +01:00 committed by GitHub
parent 0cf1ddb258
commit 8f41760f3e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 80 additions and 0 deletions

View File

@ -3,6 +3,10 @@
"description": "Cross-platform automation and configuration tool/framework, known as Powershell Core, that works well with existing tools and is optimized for dealing with structured data.",
"homepage": "https://github.com/PowerShell/PowerShell",
"license": "MIT",
"notes": [
"Add PowerShell Core as a explorer context menu by running: '$dir\\install-explorer-context.reg'",
"For file context menu, run '$dir\\install-file-context.reg'"
],
"architecture": {
"64bit": {
"url": "https://github.com/PowerShell/PowerShell/releases/download/v7.2.2/PowerShell-7.2.2-win-x64.zip",
@ -18,6 +22,18 @@
" if (!(Test-Path \"$persist_dir\\$_\")) { New-Item \"$dir\\$_\" | Out-Null }",
"}"
],
"post_install": [
"if ($architecture -eq '32bit') { $pwshArch = 'x86' } else { $pwshArch = 'x64' }",
"$pwshPath = \"$dir\\pwsh.exe\".Replace('\\', '\\\\')",
"'install-explorer-context', 'uninstall-explorer-context', 'install-file-context' , 'uninstall-file-context' | ForEach-Object {",
" if (Test-Path \"$bucketsdir\\main\\scripts\\pwsh\\$_.reg\") {",
" $content = (Get-Content \"$bucketsdir\\main\\scripts\\pwsh\\$_.reg\").Replace('$pwshPath', $pwshPath)",
" $content = $content.Replace('$pwshArch', $pwshArch)",
" if ($global) { $content = $content.Replace('HKEY_CURRENT_USER', 'HKEY_LOCAL_MACHINE') }",
" Set-Content \"$dir\\$_.reg\" $content -Encoding Ascii -Force",
" }",
"}"
],
"bin": "pwsh.exe",
"shortcuts": [
[

View File

@ -0,0 +1,41 @@
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Classes\Directory\Background\shell\PowerShellCore$pwshArch]
"ExtendedSubCommandsKey"="Directory\\ContextMenus\\PowerShellCore$pwshArch"
"MUIVerb"="&PowerShell Core"
"Icon"="$pwshPath"
[HKEY_CURRENT_USER\Software\Classes\Drive\shell\PowerShellCore$pwshArch]
"MUIVerb"="&PowerShell Core"
"Icon"="$pwshPath"
"ExtendedSubCommandsKey"="Directory\\ContextMenus\\PowerShellCore$pwshArch"
[HKEY_CURRENT_USER\Software\Classes\DesktopBackground\Shell\PowerShellCore$pwshArch]
"MUIVerb"="&PowerShell Core"
"Icon"="$pwshPath"
"ExtendedSubCommandsKey"="Directory\\ContextMenus\\PowerShellCore$pwshArch"
[HKEY_CURRENT_USER\Software\Classes\Directory\shell\PowerShellCore$pwshArch]
"MUIVerb"="&PowerShell Core"
"Icon"="$pwshPath"
"ExtendedSubCommandsKey"="Directory\\ContextMenus\\PowerShellCore$pwshArch"
[HKEY_CURRENT_USER\Software\Classes\LibraryFolder\background\shell\PowerShellCore$pwshArch]
"MUIVerb"="&PowerShell Core"
"Icon"="$pwshPath"
"ExtendedSubCommandsKey"="Directory\\ContextMenus\\PowerShellCore$pwshArch"
[HKEY_CLASSES_ROOT\Directory\ContextMenus\PowerShellCore$pwshArch\shell\openpwsh]
"MUIVerb"="Open &here"
"Icon"="$pwshPath"
[HKEY_CURRENT_USER\Software\Classes\Directory\ContextMenus\PowerShellCore$pwshArch\shell\openpwsh\command]
@="$pwshPath -NoExit -RemoveWorkingDirectoryTrailingCharacter -WorkingDirectory \"%V!\" -Command \"$host.UI.RawUI.WindowTitle = 'PowerShell Core ($pwshArch)'\""
[HKEY_CURRENT_USER\Software\Classes\Directory\ContextMenus\PowerShellCore$pwshArch\shell\runas]
"MUIVerb"="Open here as &Administrator"
"Icon"="$pwshPath"
"HasLUAShield"=""
[HKEY_CURRENT_USER\Software\Classes\Directory\ContextMenus\PowerShellCore$pwshArch\shell\runas\command]
@="$pwshPath -NoExit -RemoveWorkingDirectoryTrailingCharacter -WorkingDirectory \"%V!\" -Command \"$host.UI.RawUI.WindowTitle = 'PowerShell Core ($pwshArch)'\""

View File

@ -0,0 +1,8 @@
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Classes\*\shell\PowerShellCore$pwshArch]
"Icon"="$pwshPath"
"MUIVerb"="Run with PowerShell Core"
[HKEY_CURRENT_USER\Software\Classes\*\shell\PowerShellCore$pwshArch\Command]
@="$pwshPath -Command \"$host.UI.RawUI.WindowTitle = 'PowerShell Core ($pwshArch)'; if((Get-ExecutionPolicy ) -ne 'AllSigned') { Set-ExecutionPolicy -Scope Process Bypass }; & '%1'\""

View File

@ -0,0 +1,11 @@
Windows Registry Editor Version 5.00
[-HKEY_CURRENT_USER\Software\Classes\Directory\Background\shell\PowerShellCore$pwshArch]
[-HKEY_CURRENT_USER\Software\Classes\Drive\shell\PowerShellCore$pwshArch]
[-HKEY_CURRENT_USER\Software\Classes\DesktopBackground\Shell\PowerShellCore$pwshArch]
[-HKEY_CURRENT_USER\Software\Classes\Directory\shell\PowerShellCore$pwshArch]
[-HKEY_CURRENT_USER\Software\Classes\LibraryFolder\background\shell\PowerShellCore$pwshArch]
[-HKEY_CURRENT_USER\Software\Classes\Directory\ContextMenus\PowerShellCore$pwshArch\shell\openpwsh]
[-HKEY_CURRENT_USER\Software\Classes\Directory\ContextMenus\PowerShellCore$pwshArch\shell\openpwsh\command]
[-HKEY_CURRENT_USER\Software\Classes\Directory\ContextMenus\PowerShellCore$pwshArch\shell\runas]
[-HKEY_CURRENT_USER\Software\Classes\Directory\ContextMenus\PowerShellCore$pwshArch\shell\runas\command]

View File

@ -0,0 +1,4 @@
Windows Registry Editor Version 5.00
[-HKEY_CURRENT_USER\Software\Classes\*\shell\PowerShellCore$pwshArch]
[-HKEY_CURRENT_USER\Software\Classes\*\shell\PowerShellCore$pwshArch\Command]