how to get the return value on variable
Moderator: DosItHelp
how to get the return value on variable
Dear Gurus,
I am reading the regedit by
REG QUERY "HKLM\Software\Oracle" /v FORMS60
the return value is like below :
FORMS60 REG_EXPAND_RZ d:\forms6i\FORMS60
How may i store the return value on a variable
Please Help me
Thanks
Jebesh
I am reading the regedit by
REG QUERY "HKLM\Software\Oracle" /v FORMS60
the return value is like below :
FORMS60 REG_EXPAND_RZ d:\forms6i\FORMS60
How may i store the return value on a variable
Please Help me
Thanks
Jebesh
I have written the script like this below
FOR "TOKENS=1-3,DELIMS= " %%A IN ('REG QUERY HKLM\Software\Oracle /v FORMS60') DO SET result=%%C
echo %result%
pause
it shows the following error message
"TOKENS=1-3,DELIMS=" Was unexpected at this time.
I am new to dos script please tel me is there any mistake in the above script
please help me to resolve it
Thanks
Jebesh
FOR "TOKENS=1-3,DELIMS= " %%A IN ('REG QUERY HKLM\Software\Oracle /v FORMS60') DO SET result=%%C
echo %result%
pause
it shows the following error message
"TOKENS=1-3,DELIMS=" Was unexpected at this time.
I am new to dos script please tel me is there any mistake in the above script
please help me to resolve it
Thanks
Jebesh
thanks for reply,
if i user for /f it accepts the token part, but it is not accepting the delimeters parts
my script is
--------------
FOR /f "TOKENS=1-3,DELIMS=" %%A IN ('REG QUERY HKLM\Software\Oracle /v FORMS60') DO SET result=%%C
echo %result%
pause
it raise the following error
Delims=" was unexpected at this time
Thanks
Jebesh S
if i user for /f it accepts the token part, but it is not accepting the delimeters parts
my script is
--------------
FOR /f "TOKENS=1-3,DELIMS=" %%A IN ('REG QUERY HKLM\Software\Oracle /v FORMS60') DO SET result=%%C
echo %result%
pause
it raise the following error
Delims=" was unexpected at this time
Thanks
Jebesh S
Well spotted Jeb
Thats what happens when you don't test.....
/F needs to be included, but its not there so that tokens and delims work. /F identifies that the 'set' in the round brackets is not a filename to be interrogated, but either a file with a list of filenames in it, or a command that the individual lines ouput, are treated as the results and parsed to the variable defined (%%A B and C in this case.)
The default for DELIMS is SPACE and TAB. so without TOKENS defined, the fist space in the output is deamed as a delimiter and therefore %%A results in FORMS60 %%B is not defined and neither is %%C and will equal nothing.
This line would work aswell.
FOR /F "TOKENS=1-3" %%A IN ('REG QUERY HKLM\Software\Oracle /v FORMS60') DO SET result=%%C
ECHO %result%
Your delims doesn't work cos you have missed the SPACE after the equals sign.
,DELIMS= "
but as I said you dont need it, its just good practice.
ANYWAYS,
Now that i've looked a bit harder at it, it appears that the output does have TABS in it and also lots of lines that we are not interested in, so use this line to be exact.
FOR /F "TOKENS=1-3 SKIP=4" %%A IN ('REG QUERY HKLM\Software\Oracle /v FORMS60') DO SET result=%%C
DID everyone follow that?
BSOD
Thats what happens when you don't test.....
/F needs to be included, but its not there so that tokens and delims work. /F identifies that the 'set' in the round brackets is not a filename to be interrogated, but either a file with a list of filenames in it, or a command that the individual lines ouput, are treated as the results and parsed to the variable defined (%%A B and C in this case.)
The default for DELIMS is SPACE and TAB. so without TOKENS defined, the fist space in the output is deamed as a delimiter and therefore %%A results in FORMS60 %%B is not defined and neither is %%C and will equal nothing.
This line would work aswell.
FOR /F "TOKENS=1-3" %%A IN ('REG QUERY HKLM\Software\Oracle /v FORMS60') DO SET result=%%C
ECHO %result%
Your delims doesn't work cos you have missed the SPACE after the equals sign.
,DELIMS= "
but as I said you dont need it, its just good practice.
ANYWAYS,
Now that i've looked a bit harder at it, it appears that the output does have TABS in it and also lots of lines that we are not interested in, so use this line to be exact.
FOR /F "TOKENS=1-3 SKIP=4" %%A IN ('REG QUERY HKLM\Software\Oracle /v FORMS60') DO SET result=%%C
DID everyone follow that?
BSOD
Hi,
ok, ok, you are right I don't test...
No.
Because it works sometimes, but not really exact.
If the result value has spaces in it (like a path to c:\Documents and Settings) you only get c:\Documents
Better use, Tokens 1-2* so you get also three tokens, but the last one contains the rest of the line
FOR /F "TOKENS=1-2* SKIP=4" %%A IN ('REG QUERY HKLM\Software\Oracle /v FORM') DO SET result=%%C
test and peace
jeb
Well spotted Jeb
Thats what happens when you don't test.....
ok, ok, you are right I don't test...
Now that i've looked a bit harder at it, it appears that the output does have TABS in it and also lots of lines that we are not interested in, so use this line to be exact.
FOR /F "TOKENS=1-3 SKIP=4" %%A IN ('REG QUERY HKLM\Software\Oracle /v FORMS60') DO SET result=%%C
DID everyone follow that?
No.
Because it works sometimes, but not really exact.
If the result value has spaces in it (like a path to c:\Documents and Settings) you only get c:\Documents
Better use, Tokens 1-2* so you get also three tokens, but the last one contains the rest of the line
FOR /F "TOKENS=1-2* SKIP=4" %%A IN ('REG QUERY HKLM\Software\Oracle /v FORM') DO SET result=%%C
test and peace
jeb