@REGQUERY with hostname fails

#1
This was working back in September. @REGQUERY fails whenever a hostname, local or remote, is given.
Code:
v:\> echo %@regquery[HKU\.DEFAULT\Environment\TEMP]
%USERPROFILE%\AppData\Local\Temp

v:\> echo %_winname
ZZ

v:\> echo %@regquery[\\zz\HKU\.DEFAULT\Environment\TEMP]
-1

v:\> echo %@regquery[\\lucky\HKU\.DEFAULT\Environment\TEMP]
-1
With a '.' as hostname, it seems to work but gives a result which is incorrect.
Code:
v:\> echo %@regquery[\\.\hklm\system\currentcontrolset\services\w32time\w32tmparams\ratedefault]
53 (incorrect)

v:\> echo %@regquery[hklm\system\currentcontrolset\services\w32time\w32tmparams\ratedefault]
156001 (correct)
And the help for many of the @REG functions contains a sentence apparently copied from @REGBREAD but not personalized for the function in question. For example, %REGQUERY's help says
Code:
If the key name begins with \\machinename, @REGBREAD opens ...
 
#9
P.S., The "53" is the return value of RegConnectRegistry(); it's not from GetLastError().

And when viewing a thread, the user names (under the avatar) are no longer centered ... don't know why but it sticks out like a sore thumb.
 
#12
You could use @REGEXIST to determine whether a -1 return from @REGQUERY is an indication of an error or the actual value.
I don't want to, but even that seems to fail, not returning 0 or 1 as documented.
Code:
v:\> echo %@regexist[\\no-exist\HKU\.DEFAULT\Environment\TEMP]
53
That's the Windows error code for "The network path was not found".
 

rconn

Administrator
Staff member
May 14, 2008
10,607
97
#13
Well -- no. If a variable function fails, it doesn't return *anything* (just an error message). Some variable functions expect the occasional missing argument or result, and return -1 to indicate they didn't find something.

The question is whether a non-existent machine name is a fatal error (abort the command line) or an occasionally expected error (return some error code).