Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

@REGQUERY with hostname fails

May
12,846
164
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 ...
 
P.S., I gather the "53" mentioned in the previous post is Windows error 53, "The network path was not found".
 
Fixed in build 68.
The failure when it should work is fixed but @REGQUERY still evaluates to "53" (as if it had worked) when the network path couldn't be found. "53" is a Windows error code.
Code:
v:\> echo %@regquery[\\no-exist\HKU\.DEFAULT\Environment\TEMP]
53
 
I don't understand your point -- what did you want it to evaluate to when you pass it a bad argument?
I'd expect
Code:
TCC: (Sys) The network path was not found.
 "\\no-exist"
or some indication that the evaluation of the variable function failed.
 
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.
 
You could use @REGEXIST to determine whether a -1 return from @REGQUERY is an indication of an error or the actual value.
 
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".
 

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).
 

Similar threads

Back
Top