Capture registry value of variable number of words
Posted: 02 Mar 2022 12:26
I would like to know how to capture a value from the registry as a variable when that value may be multiple words or not. Here is a quick example that would work if the value was one word:
So, if the value was just "Company" this would return the proper value. If the value was "The Company" I know that I could use "regOrg=%%a %%b" instead. But, what if I don't know how many words are in that value?
I know how this can be done using the powershell Get-ItemProperty option, but I'm curious if this is possible in pure batch.
Thank you.
Code: Select all
for /f "tokens=3*" %%a in ('%__APPDIR__%reg.exe query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v "RegisteredOrganization"') do set "regOrg=%%a"
I know how this can be done using the powershell Get-ItemProperty option, but I'm curious if this is possible in pure batch.
Thank you.