通过 BAT 脚本中的 REG.exe 读取 Windows 产品名称
如何在 BAT 或 CMD 脚本中使用 reg.exe 从 HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion 获取 Windows 产品名称(值:ProductName)?我已经尝试了以下代码,但我无法弄清楚如何让它工作......
for /f "tokens=3*" %%A in ('reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v "ProductName") do echo Product is %%A
我确信我做错了什么,因为我知道可以像这样获取其他值的注册表数据。有人能指出我正确的方向吗?
How can I use reg.exe within a BAT or CMD script to fetch the Windows product name from HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion (value: ProductName)? I've tried the following code, but I'm unable to figure out how to get it to work...
for /f "tokens=3*" %%A in ('reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v "ProductName") do echo Product is %%A
I'm sure I'm doing something wrong since I know it's possible to fetch registry data like this for other values. Can anyone point me in the right direction?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是否可以添加结束引号字符
'
(在"ProductName"
之后)?至少,它对我有帮助:)。
编辑
%%B
是根据OP的评论添加的完整名称。Add the closing quote char
'
possibly (after"ProductName"
)?At least, it helped me :).
EDIT
%%B
was added for the complete name based on the OP's comment.