Hello All
I am trying to get and assign a registry value to a variable.
The script starting at GETLOCATION is below. There is a tab after delims=. Also an example of what the output is as follows:
1-1018 Net Team, Joe J User x1234
What I want is just up to the first space: 1-1018:GETLOCATION
Echo GETTING LOCATION
FOR /F "tokens=2* delims= " %%A IN ('REG QUERY "HKLM\Software\CompanyName\Workstation\Inventory\Workstation" /v "Location"') DO SET Location=%%B
Echo %Location%
Echo.
pause
instead of using B* as token use * and then echo %a and %b and see if works.. Subhash Chandra.
Could you spell that out my friend as I am not quite understanding the change you are suggesting. Just spell out the For statement as you would suggest I rewrite it plz. TY
try this..
I created a reg key under HKEY_LOCAL_MACHINE\SOFTWARE\CompanyName\Workstation\Inventory\Workstation and value named location with data 1-1018 Net Team, Joe J User x1234. The batch just showsGETTING LOCATION
1-1018
is that what you want ?@echo off
:GETLOCATION
Echo GETTING LOCATION
FOR /F "tokens=2,3,4 delims= " %%A IN ('REG QUERY "HKLM\Software\CompanyName\Workstation\Inventory\Workstation" /v "Location"') DO set Location=%%B
Echo %Location%
Echo.
pauseSubhash Chandra.
That could even be stripped down a bit:
FOR /F "tokens=3" %%A IN ('
REG QUERY "HKLM\Software\CompanyName\Workstation\Inventory\Workstation" /v "Location"
') DO set Location=%%A
mmm.. thats the difference between an expert and newbie :)
still in learning phase..Subhash Chandra.
Yes (14) | ![]() | |
No (14) | ![]() | |
I don't know (15) | ![]() |