Win11 图片右键菜单 用画图编辑【修正】
该文章之前的做法过于简单粗暴,导致其适用性仅限我的电脑,特此更新:
前置条件:已安装画图(商店版)
0. 启动 PowerShell
在开始菜单搜索 Windows PowerShell ,右键管理员打开;若你没有,请百度自查。
下面提供的代码,点击复制,右键粘贴到 PowerShell 窗口回车执行。
如果你想导出 reg 文件也可以,无需管理员权限。
1. 添加右键菜单
添加右键菜单(管理员)
function addEditWithMsPaintMenu() {
# 获取你的画图程序包位置
$pkgs = Get-AppxPackage
$mspaint = $pkgs | Where-Object { $_.Name -eq "Microsoft.Paint" }
$mspaintLocation = $mspaint.InstallLocation
# 注册表路径
$regPath = 'Registry::HKEY_CLASSES_ROOT\SystemFileAssociations\Image\shell\Edit'
$regPathCmd = "$regPath\command"
# 创建新的注册表项
if (Test-Path $regPath) { Remove-Item -Recurse -Path $regPath }
New-Item -Path $regPath
New-Item -Path $regPathCmd
# 设置显示名
New-ItemProperty -Path $regPath -Name 'MUIVerb' -PropertyType String -Value '用画图编辑'
# 设置显示图标
New-ItemProperty -Path $regPath -Name 'Icon' -PropertyType String -Value "$mspaintLocation\PaintApp\mspaint.exe"
# 设置命令行
New-ItemProperty -Path $regPathCmd -Name '(default)' -PropertyType String -Value 'mspaint.exe "%1"'
}
addEditWithMsPaintMenu
# 需要管理员权限,没有红色报错即可。
添加右键菜单(文件版)
function genEditWithMsPaintMenuRegFile() {
# 获取你的画图程序包位置
$pkgs = Get-AppxPackage
$mspaint = $pkgs | Where-Object { $_.Name -eq "Microsoft.Paint" }
$mspaintLocation = $mspaint.InstallLocation -replace '\\', '\\'
$regFile = @"
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\SystemFileAssociations\Image\shell\Edit]
"MUIVerb"="用画图编辑"
"Icon"="$mspaintLocation\\PaintApp\\mspaint.exe"
[HKEY_CLASSES_ROOT\SystemFileAssociations\Image\shell\Edit\command]
@="mspaint.exe \"%1\""
"@
# 获取当前用户桌面路径
$desktopPath = [System.Environment]::GetFolderPath('Desktop')
$regFile | Out-File -FilePath "$desktopPath\EditWithMsPaintMenu.reg" -Force -Encoding default
}
genEditWithMsPaintMenuRegFile
# 文件在桌面上:EditWithMsPaintMenu.reg,打开它进行导入即可,仅限你的电脑哦。
2. 清除右键菜单
如果你不喜欢这个右键菜单了,以下是清除的办法:
移除右键菜单(管理员)
function removeEditWithMsPaintMenu() {
# 注册表路径
$regPath = 'Registry::HKEY_CLASSES_ROOT\SystemFileAssociations\Image\shell\Edit'
# 删除注册表项
if (Test-Path $regPath) { Remove-Item -Recurse -Path $regPath }
}
removeEditWithMsPaintMenu
# 需要管理员权限。
移除右键菜单(文件版)
function genDeleteRegFile() {
$regFile = @"
Windows Registry Editor Version 5.00
[-HKEY_CLASSES_ROOT\SystemFileAssociations\Image\shell\Edit]
"@
# 获取当前用户桌面路径
$desktopPath = [System.Environment]::GetFolderPath('Desktop')
$regFile | Out-File -FilePath "$desktopPath\DeleteMenu.reg" -Force -Encoding default
}
genDeleteRegFile
# 文件在桌面上:DeleteMenu.reg,打开它进行导入即可,仅限你的电脑哦。
3. 清除旧版右键菜单
如果你“有幸”使用过下面的旧版博客的代码,虽然能用,但是不显示图标。这里提供清除的方法:
清除旧版右键菜单(管理员)
function removeOldRegItems() {
$notfound = @()
@(
"pps_jpg", "pps_jpe", "pps_jpeg", "pps_jfif"
"pps_tfif", "pps_tif", "pps_heic", "pps_hif"
"pps_png", "pps_bmp", "pps_gif"
) | ForEach-Object {
$path = "Registry::HKEY_CLASSES_ROOT\$_\shell\editWithPaint"
if (Test-Path $path) {
Remove-Item -Recurse $path
}
else {
$notfound += "HKEY_CLASSES_ROOT\$_\shell\editWithPaint"
}
}
Write-Host "`n移除完毕!"
$notfound | ForEach-Object {
Write-Host "未找到:$_"
}
}
removeOldRegItems
# 需要管理员权限
清除旧版右键菜单(文件版)
function genDeleteOldRegFile() {
$regFile = @"
Windows Registry Editor Version 5.00
[-HKEY_CLASSES_ROOT\pps_jpg\shell\editWithPaint]
[-HKEY_CLASSES_ROOT\pps_jpe\shell\editWithPaint]
[-HKEY_CLASSES_ROOT\pps_jpeg\shell\editWithPaint]
[-HKEY_CLASSES_ROOT\pps_jfif\shell\editWithPaint]
[-HKEY_CLASSES_ROOT\pps_tfif\shell\editWithPaint]
[-HKEY_CLASSES_ROOT\pps_tif\shell\editWithPaint]
[-HKEY_CLASSES_ROOT\pps_heic\shell\editWithPaint]
[-HKEY_CLASSES_ROOT\pps_hif\shell\editWithPaint]
[-HKEY_CLASSES_ROOT\pps_png\shell\editWithPaint]
[-HKEY_CLASSES_ROOT\pps_bmp\shell\editWithPaint]
[-HKEY_CLASSES_ROOT\pps_gif\shell\editWithPaint]
"@
# 获取当前用户桌面路径
$desktopPath = [System.Environment]::GetFolderPath('Desktop')
$regFile | Out-File -FilePath "$desktopPath\DeleteOldMenu.reg" -Force -Encoding default
}
genDeleteOldRegFile
# 文件在桌面上:DeleteOldMenu.reg,打开它进行导入即可,仅限你的电脑哦。
注意:以下是旧版本,不再适用!!
1. 首先确保安装了画图App
设置 → 应用 → 安装的应用 → 输入“画图”筛选:
没有就去 Microsoft Store 搜索 paint 下载:
2. 然后运行REG代码
复制以下注册表代码到 新建文本文件 中,保存,保存千万记得选择 ANSI 编码。
最后修改后缀为 .reg ,双击运行。
Windows Registry Editor Version 5.00
; JPG
[HKEY_CLASSES_ROOT\pps_jpg\shell\editWithPaint]
@="用画图编辑(E)"
"icon"="C:\\Program Files\\WindowsApps\\Microsoft.Paint_11.2302.19.0_x64__8wekyb3d8bbwe\\PaintApp\\mspaint.exe"
[HKEY_CLASSES_ROOT\pps_jpg\shell\editWithPaint\command]
@="mspaint.exe %1"
; JPE
[HKEY_CLASSES_ROOT\pps_jpe\shell\editWithPaint]
@="用画图编辑(E)"
"icon"="C:\\Program Files\\WindowsApps\\Microsoft.Paint_11.2302.19.0_x64__8wekyb3d8bbwe\\PaintApp\\mspaint.exe"
[HKEY_CLASSES_ROOT\pps_jpe\shell\editWithPaint\command]
@="mspaint.exe %1"
; JPEG
[HKEY_CLASSES_ROOT\pps_jpeg\shell\editWithPaint]
@="用画图编辑(E)"
"icon"="C:\\Program Files\\WindowsApps\\Microsoft.Paint_11.2302.19.0_x64__8wekyb3d8bbwe\\PaintApp\\mspaint.exe"
[HKEY_CLASSES_ROOT\pps_jpeg\shell\editWithPaint\command]
@="mspaint.exe %1"
; JFIF
[HKEY_CLASSES_ROOT\pps_jfif\shell\editWithPaint]
@="用画图编辑(E)"
"icon"="C:\\Program Files\\WindowsApps\\Microsoft.Paint_11.2302.19.0_x64__8wekyb3d8bbwe\\PaintApp\\mspaint.exe"
[HKEY_CLASSES_ROOT\pps_jfif\shell\editWithPaint\command]
@="mspaint.exe %1"
; PNG
[HKEY_CLASSES_ROOT\pps_png\shell\editWithPaint]
@="用画图编辑(E)"
"icon"="C:\\Program Files\\WindowsApps\\Microsoft.Paint_11.2302.19.0_x64__8wekyb3d8bbwe\\PaintApp\\mspaint.exe"
[HKEY_CLASSES_ROOT\pps_png\shell\editWithPaint\command]
@="mspaint.exe %1"
; BMP
[HKEY_CLASSES_ROOT\pps_bmp\shell\editWithPaint]
@="用画图编辑(E)"
"icon"="C:\\Program Files\\WindowsApps\\Microsoft.Paint_11.2302.19.0_x64__8wekyb3d8bbwe\\PaintApp\\mspaint.exe"
[HKEY_CLASSES_ROOT\pps_bmp\shell\editWithPaint\command]
@="mspaint.exe %1"
; GIF
[HKEY_CLASSES_ROOT\pps_gif\shell\editWithPaint]
@="用画图编辑(E)"
"icon"="C:\\Program Files\\WindowsApps\\Microsoft.Paint_11.2302.19.0_x64__8wekyb3d8bbwe\\PaintApp\\mspaint.exe"
[HKEY_CLASSES_ROOT\pps_gif\shell\editWithPaint\command]
@="mspaint.exe %1"
; TIFF
[HKEY_CLASSES_ROOT\pps_tfif\shell\editWithPaint]
@="用画图编辑(E)"
"icon"="C:\\Program Files\\WindowsApps\\Microsoft.Paint_11.2302.19.0_x64__8wekyb3d8bbwe\\PaintApp\\mspaint.exe"
[HKEY_CLASSES_ROOT\pps_tfif\shell\editWithPaint\command]
@="mspaint.exe %1"
; TIF
[HKEY_CLASSES_ROOT\pps_tif\shell\editWithPaint]
@="用画图编辑(E)"
"icon"="C:\\Program Files\\WindowsApps\\Microsoft.Paint_11.2302.19.0_x64__8wekyb3d8bbwe\\PaintApp\\mspaint.exe"
[HKEY_CLASSES_ROOT\pps_tif\shell\editWithPaint\command]
@="mspaint.exe %1"
; HEIC
[HKEY_CLASSES_ROOT\pps_heic\shell\editWithPaint]
@="用画图编辑(E)"
"icon"="C:\\Program Files\\WindowsApps\\Microsoft.Paint_11.2302.19.0_x64__8wekyb3d8bbwe\\PaintApp\\mspaint.exe"
[HKEY_CLASSES_ROOT\pps_heic\shell\editWithPaint\command]
@="mspaint.exe %1"
; HIF
[HKEY_CLASSES_ROOT\pps_hif\shell\editWithPaint]
@="用画图编辑(E)"
"icon"="C:\\Program Files\\WindowsApps\\Microsoft.Paint_11.2302.19.0_x64__8wekyb3d8bbwe\\PaintApp\\mspaint.exe"
[HKEY_CLASSES_ROOT\pps_hif\shell\editWithPaint\command]
@="mspaint.exe %1"
如: