开发者

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

开发者 https://www.devze.com 2023-03-11 23:20 出处:网络
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 foll

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

精彩评论

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