HIGHESTNUMANODENUMBER

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Message
Author
npocmaka_
Posts: 512
Joined: 24 Jun 2013 17:10
Location: Bulgaria
Contact:

HIGHESTNUMANODENUMBER

#1 Post by npocmaka_ » 23 Sep 2014 04:42

HIGHESTNUMANODENUMBER is an environment variable in command prompt which I suppose implements:

http://msdn.microsoft.com/en-us/library ... 03(v=vs.85).aspx

Strangely I can't see it even with

Code: Select all

SET "
(can anybody else can?)

but these works:


Code: Select all

>echo %HIGHESTNUMANODENUMBER%

>if defined HIGHESTNUMANODENUMBER echo defined
defined


I have no idea which windows versions have it (mine is win8 and it is here) - according to this :

Windows Server 2008, Windows Vista, Windows Server 2003, and Windows XP: Processor groups are not supported.


But in the first link is written:

Minimum supported client
Windows Vista, Windows XP Professional x64 Edition, Windows XP with SP2 [desktop apps only]
Minimum supported server
Windows Server 2003 [desktop apps only]
Header
WinBase.h on Windows XP, Windows Server 2003, Windows Vista, Windows 7, Windows Server 2008, and Windows Server 2008 R2 (include Windows.h);
Systemtopologyapi.h on Windows 8 and Windows Server 2012

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: HIGHESTNUMANODENUMBER

#2 Post by foxidrive » 23 Sep 2014 05:57

It exists in Windows 8.1 32 bit Eng

Code: Select all

c:\>echo %HIGHESTNUMANODENUMBER%
0

npocmaka_
Posts: 512
Joined: 24 Jun 2013 17:10
Location: Bulgaria
Contact:

Re: HIGHESTNUMANODENUMBER

#3 Post by npocmaka_ » 23 Sep 2014 06:35

foxidrive wrote:It exists in Windows 8.1 32 bit Eng

Code: Select all

c:\>echo %HIGHESTNUMANODENUMBER%
0


Thanks for the reply.But can you see it in set " output?

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: HIGHESTNUMANODENUMBER

#4 Post by foxidrive » 23 Sep 2014 06:42

npocmaka_ wrote:
foxidrive wrote:It exists in Windows 8.1 32 bit Eng

Code: Select all

c:\>echo %HIGHESTNUMANODENUMBER%
0


Thanks for the reply.But can you see it in set " output?


Negative.

Squashman
Expert
Posts: 4471
Joined: 23 Dec 2011 13:59

Re: HIGHESTNUMANODENUMBER

#5 Post by Squashman » 23 Sep 2014 06:52

There are few environmental variables that you can not see from running the SET command.

npocmaka_
Posts: 512
Joined: 24 Jun 2013 17:10
Location: Bulgaria
Contact:

Re: HIGHESTNUMANODENUMBER

#6 Post by npocmaka_ » 23 Sep 2014 06:59

Squashman wrote:There are few environmental variables that you can not see from running the SET command.


I know but I thought that all of them can be seen with set "

I don't know about other that cannot be seen in that way.
Last edited by npocmaka_ on 23 Sep 2014 07:01, edited 1 time in total.

Squashman
Expert
Posts: 4471
Joined: 23 Dec 2011 13:59

Re: HIGHESTNUMANODENUMBER

#7 Post by Squashman » 23 Sep 2014 07:01

npocmaka_ wrote:
Squashman wrote:There are few environmental variables that you can not see from running the SET command.


I know but I thought that all of them can be seen with set "

Your reply contradicts itself.

npocmaka_
Posts: 512
Joined: 24 Jun 2013 17:10
Location: Bulgaria
Contact:

Re: HIGHESTNUMANODENUMBER

#8 Post by npocmaka_ » 23 Sep 2014 07:15

ok.

cmdcmdline ,random ,time , date ,cd are dynamically generated and not seen in SET output.

Suppose HIGHESTNUMANODENUMBER is dynamically generated which fit in the description given by MS

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: HIGHESTNUMANODENUMBER

#9 Post by foxidrive » 23 Sep 2014 07:31

npocmaka_ wrote:ok.

cmdcmdline ,random ,time , date ,cd are dynamically generated and not seen in SET output.

Suppose HIGHESTNUMANODENUMBER is dynamically generated which fit in the description given by MS


I wonder how many other variables are hidden that way... :D

dbenham
Expert
Posts: 2461
Joined: 12 Feb 2011 21:02
Location: United States (east coast)

Re: HIGHESTNUMANODENUMBER

#10 Post by dbenham » 23 Sep 2014 08:30

I've been fascinated by dynamic variables for a while. My testing shows there are 3 distinct classes of dynamic variables: http://stackoverflow.com/a/20169219/1012053. I recommend reading the entire link, but below is a very brief summary that excludes some of the more interesting details.

1) Normal looking "variables" without any prefix or suffix that can be overridden.

I believe HIGHESTNUMANODENUMBER can be lumped into this class

Other examples include ERRORLEVEL, CD, DATE, TIME, etc.

2) Dynamic variables prefixed with =
These values cannot be overridden except by another process outside of CMD.EXE

Examples include =C: =EXITCODE =EXITCODEASCII

Then there is the mysterious =:: which exists on some machines, and not on others: viewtopic.php?p=8231#p8231

3) The unique variable __C__

This baby is really wierd. An override value can be defined, but not accessed, except via SET or SET /A EDIT: This is true on Win 7 and Win 8, but not true on XP. Not sure about Vista


Dave Benham
Last edited by dbenham on 25 Sep 2014 05:58, edited 2 times in total.

penpen
Expert
Posts: 1999
Joined: 23 Jun 2013 06:15
Location: Germany

Re: HIGHESTNUMANODENUMBER

#11 Post by penpen » 23 Sep 2014 15:34

I think that the environment variable cmdcmdline should be in its own category (named "Heisenberg Variables"), too.
It's the only one that could vanish, when accessing only parts of it, and it stays always defined:

Code: Select all

echo %cmdcmdline%
echo %cmdcmdline:~1%
echo %cmdcmdline%
echo %cmdcmdline:~1000%
if defined cmdcmdline echo Cmdcmdline is still defined.

penpen

dbenham
Expert
Posts: 2461
Joined: 12 Feb 2011 21:02
Location: United States (east coast)

Re: HIGHESTNUMANODENUMBER

#12 Post by dbenham » 23 Sep 2014 16:12

Oooh, I forgot about that nasty CMDCMDLINE behavior :!:

I think I would classify it as 1A instead of a totally new class unto itself. It has all of the behaviors of all of the other class 1 variables, but it also has a unique "feature" that causes the value to be permanently changed if substring or search/replace operations are performed during expansion.

I think the underlying mechanism for CMDCMDLINE is the same as all the other class 1 variables, except I believe there is an implementation bug. I suspect the code to get the dynamic value is supposed to provide a pointer to a copy of the string, but %CMDCMDLINE% returns a pointer to the original string instead. So value manipulation ends up being destructive.

It does not surprise me that IF DEFINED CMDCMDLINE returns true after the value has been erased by %CMDCMDLINE:~1000%. I think it is still pointing to a valid memory address, but the string shows as empty because of a null byte at the first position.

Of course, all of this is only an educated guess :wink:


Dave Benham

aGerman
Expert
Posts: 4654
Joined: 22 Jan 2010 18:01
Location: Germany

Re: HIGHESTNUMANODENUMBER

#13 Post by aGerman » 24 Sep 2014 13:38

Dave

Were you able to follow Magoo's (SO) assumption that __CD__ could be related to the ~f modifier of FOR variables?

Regards
aGerman

dbenham
Expert
Posts: 2461
Joined: 12 Feb 2011 21:02
Location: United States (east coast)

Re: HIGHESTNUMANODENUMBER

#14 Post by dbenham » 24 Sep 2014 19:42

I think I understand his suggestion, but it is purely speculative.

When a FOR variable (call it %%V) does not include a full path, then %%~fV must access the current directory information to establish the full path. He is speculating that the virtual __CD__ variable is used to get the current directory. I don't see any reason to suspect that, but I suppose it could be true.

Perhaps it could be tested on XP, but I no longer have access to XP. If you look at the comments to MC ND's answer you will see reports that ECHO %__CD__% does echo a user supplied value, if it exists.

Take the following code:

Code: Select all

@echo off
setlocal
set "__CD__=z:\bogus\"
pushd c:\
for %%A in (test) do echo %%~fA

On my Win 7 machine I get c:\test

If Magoo is correct, then I think XP should produce z:\bogus\test.

My guess is that XP will not give that result, but who knows :?: :twisted:


Dave Benham

penpen
Expert
Posts: 1999
Joined: 23 Jun 2013 06:15
Location: Germany

Re: HIGHESTNUMANODENUMBER

#15 Post by penpen » 25 Sep 2014 00:49

My interpretation of what Magoo has written differs a lot!
I think he said(in other words): The "for" command needs the dynamic variable in order to work correctly.

And in addition i think Magoo predicts, that "c:\test" is returned in your above example, although the static environment variable __CD__ is set to "z:\bogus\".
Magoo wrote:SET __CD__ to whatever you like, the current dirname will STILL be echoed.
PUSHD someconvenientdir before that FOR and someconvenientdir will be echoed.
SET CD=bogus and the current directory will be echoed (...)
After using "PUSHD someconvenientdir" someconvenientdir is the current directory.
=> Prediction: The current (real) directory is returned no matter of the value in the static environment variable:
Magoo wrote:~f will use %__CD__% NOT from the environment where the directoryname isn't explicit

Btw: Using your above example, Windows XP returns "C:\test".

penpen

Edit: I've changed the first (misleading) part, so it should be more clear.

Post Reply