找回密码
 注册
搜索
[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
查看: 20738|回复: 1

[注册表类] 批处理修改注册表,如何为程序添加右键打开菜单?

[复制链接]
发表于 2017-5-12 19:48:54 | 显示全部楼层 |阅读模式
本帖最后由 3518228042 于 2017-5-13 12:07 编辑

批处理修改注册表,如何获取路径添加到注册表,为程序添加右键打开菜单?grepWin.exe可能放在任何位置。
注册表转BAT内容如下:
这个是删除注册表项的
  1. reg delete "HKLM\SOFTWARE\Classes\Directory\shell\grepWin" /f
  2. reg delete "HKCR\*\shell\grepWin" /f
复制代码
下面是需要添加的,但是文件路径没添加进去,需要自动获取文件路径添加进去并且运行。
需要在HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\shell里面添加grepWin项,并且添加字符串值为grepWin.exe的路径
  1. reg add "HKLM\SOFTWARE\Classes\Directory\shell\grepWin" /f /v "Icon" /t REG_SZ /d "grepWin.exe,-107"
复制代码
需要在HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\shell\grepWin里面添加command项,并且添加字符串值为grepWin.exe的路径
  1. reg add "HKLM\SOFTWARE\Classes\Directory\shell\grepWin\command" /f /ve /t REG_SZ /d "grepWin.exe /searchpath:"%%1""
复制代码
需要在HKEY_CLASSES_ROOT\*\shell\里面添加grepWin项,并且添加字符串值为grepWin.exe的路径
  1. reg add "HKCR\*\shell\grepWin" /f /v "Icon" /t REG_SZ /d "grepWin.exe,-107"
复制代码
需要在HKEY_CLASSES_ROOT\*\shell\grepWin里面添加command项,并且添加字符串值为grepWin.exe的路径
  1. reg add "HKCR\*\shell\grepWin\command" /f /ve /t REG_SZ /d "grepWin.exe /searchpath:"%%1""
复制代码
也就是说grepWin.exe必须在C:\Windows\System32目录才能运行,
REG_SZ /d "grepWin.exe这个只有程序名称,根本没有路径值,
BAT文件和grepWin.exe文件放在任意目录,运行后路径会添加进去,比如当路径为F:\grepWin\grepWin.exe时候,BAT执行的命令会变成下面的情况
  1. reg add "HKLM\SOFTWARE\Classes\Directory\shell\grepWin" /f /v "Icon" /t REG_SZ /d "F:\grepWin\grepWin.exe,-107"
  2. reg add "HKLM\SOFTWARE\Classes\Directory\shell\grepWin\command" /f /ve /t REG_SZ /d "F:\grepWin\grepWin.exe /searchpath:"%%1""
  3. reg add "HKCR\*\shell\grepWin" /f /v "Icon" /t REG_SZ /d "F:\grepWin\grepWin.exe,-107"
  4. reg add "HKCR\*\shell\grepWin\command" /f /ve /t REG_SZ /d "F:\grepWin\grepWin.exe /searchpath:"%%1""
复制代码
grepWin.exe论坛下载地址
http://batch-cn.qiniudn.com/tool/grepWin.exe
 楼主| 发表于 2017-5-13 13:56:04 | 显示全部楼层

  1. for /f "delims=" %%a in ('dir /a/s/b/on grepWin.exe') do reg add "HKLM\SOFTWARE\Classes\Directory\shell\grepWin" /f /v "Icon" /t REG_SZ /d ""%%a",-107"

  2. for /f "delims=" %%a in ('dir /a/s/b/on grepWin.exe') do reg add "HKLM\SOFTWARE\Classes\Directory\shell\grepWin\command" /f /ve /t REG_SZ /d ""%%a" /searchpath:"%%1""

  3. for /f "delims=" %%a in ('dir /a/s/b/on grepWin.exe') do reg add "HKCR\*\shell\grepWin" /f /v "Icon" /t REG_SZ /d ""%%a",-107"

  4. for /f "delims=" %%a in ('dir /a/s/b/on grepWin.exe') do reg add "HKCR\*\shell\grepWin\command" /f /ve /t REG_SZ /d ""%%a" /searchpath:"%%1""
复制代码
运行后添加菜单,在文件或文件夹上鼠标右键能看见grepWin选项,
有没有写得短的?
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|批处理之家 ( 渝ICP备10000708号 )

GMT+8, 2026-3-17 14:47 , Processed in 0.016682 second(s), 8 queries , File On.

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

快速回复 返回顶部 返回列表