标题: [注册表类] 注册表解析环境变量%SystemRoot%不正确,请老师指正。谢谢! [打印本页]
作者: Shuye 时间: 2023-2-23 18:23 标题: 注册表解析环境变量%SystemRoot%不正确,请老师指正。谢谢!
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Folder\Shell\CMDCMD]
@="CMDCMD"
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Folder\Shell\CMDCMD\Command]
@="%SystemRoot%\\System32\\Cmd"
导入注册表后,右击文件夹,点击CMDCMD时警告:Windows 无法访问
但用 @="C:\\Windows\\System32\\Cmd" 替换掉 @="%SystemRoot%\\System32\\Cmd" 则正常打开。
要怎样设置%SystemRoot%,注册表才能解析?
谢谢啦!
作者: WHY 时间: 2023-2-23 19:09
本帖最后由 WHY 于 2023-2-23 19:58 编辑
注册表默认值数据类型为REG_SZ
包含有 %SystemRoot% 变量的类型应该是 REG_EXPAND_SZ
可以直接用批处理命令:- @echo off
- reg add "HKLM\SOFTWARE\Classes\Folder\Shell\CMDCMD" /ve /d "CMDCMD"
- reg add "HKLM\SOFTWARE\Classes\Folder\Shell\CMDCMD\Command" /ve /t REG_EXPAND_SZ /d "%%SystemRoot%%\System32\Cmd"
- pause
复制代码
如果一定要用reg文件导入,可以这样:
打开 PowerShell 控制台窗口,输入命令:- ([char[]]'%SystemRoot%\System32\Cmd'|%{([int]$_).ToString('X')+',00'}) -join ','
复制代码
得到一串值:
25,00,53,00,79,00,73,00,74,00,65,00,6D,00,52,00,6F,00,6F,00,74,00,25,00,5C,00,53,00,79,00,73,00,74,00,65,00,6D,00,33,00,32,00,5C,00,43,00,6D,00,64,00
把这串值写入reg文件:- Windows Registry Editor Version 5.00
-
- [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Folder\Shell\CMDCMD]
- @="CMDCMD"
- [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Folder\Shell\CMDCMD\Command]
- @=hex(2):25,00,53,00,79,00,73,00,74,00,65,00,6D,00,52,00,6F,00,6F,00,74,00,25,00,5C,\
- 00,53,00,79,00,73,00,74,00,65,00,6D,00,33,00,32,00,5C,00,43,00,6D,00,64,00
复制代码
作者: Shuye 时间: 2023-2-24 00:31
回复 2# WHY
好办法!详细周到,效果很好,谢谢 WHY 兄!
欢迎光临 批处理之家 (http://bbs.bathome.net/) |
Powered by Discuz! 7.2 |