开发者

Read Windows Product Name via REG.exe within a BAT script

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 th开发者_Python百科e 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?


Add the closing quote char ' possibly (after "ProductName")?

for /f "tokens=3*" %%A in ^
('reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v "ProductName"') ^
do echo Product is %%A %%B

At least, it helped me :).


EDIT

%%B was added for the complete name based on the OP's comment.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜