HIGHESTNUMANODENUMBER

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

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

Re: HIGHESTNUMANODENUMBER

#16 Post by dbenham » 25 Sep 2014 06:14

penpen wrote: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.

This is not a different interpretation. We are trying to say the same thing. But I like your way of putting it.


penpen wrote: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

But I don't think Magoo was aware that %__CD__% behaves differently on XP, as evidenced by MC ND's answer and foxidrive's comment. On XP, ECHO %__CD__% displays the static environment variable, if one is defined. On Win 7 and Win 8 it always displays the actual current directory, even if a static user value is defined.


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

Excellent! I believe this proves that FOR must not be using the dynamic variable to retrieve the current directory. If you can add one more line to the end of the test: echo %__CD__%, then all the evidence will be in one place.

Based on what you report, %%~fA returns C:\test on XP.

Based on MC ND's answer and foxidrive's comment, echo %__CD__% should return z:\bogus\test on XP.

In my mind, this would disprove Magoo's theory that FOR needs the __CD__ dynamic variable to work properly.


Dave Benham

bars143
Posts: 87
Joined: 01 Sep 2013 20:47

Re: HIGHESTNUMANODENUMBER

#17 Post by bars143 » 25 Sep 2014 09:11

code below:

Code: Select all


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



will output in my window xp sp3 :

Code: Select all


z:\bogus\test


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

Re: HIGHESTNUMANODENUMBER

#18 Post by foxidrive » 25 Sep 2014 10:13

This returns the folowing in XP Sp3 Eng 32 bit


c:\test
z:\bogus\


Code: Select all

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

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

Re: HIGHESTNUMANODENUMBER

#19 Post by dbenham » 25 Sep 2014 10:25

Thanks foxi :!: I think this disproves Magoo's theory once and for all.


Dave Benham

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

Re: HIGHESTNUMANODENUMBER

#20 Post by aGerman » 25 Sep 2014 10:31

Interesting read :)

Finally it's still a miracle for what the __CD__ variable is used internally.
Maybe we will find the answer somewhen by a fluke.

Regards
aGerman

carlos
Expert
Posts: 503
Joined: 20 Aug 2010 13:57
Location: Chile
Contact:

Re: HIGHESTNUMANODENUMBER

#21 Post by carlos » 23 Dec 2014 10:39

npocmaka_ the variable HIGHESTNUMANODENUMBER is present in windows 7, and when you query it to cmd, it look in the environment variable if is present, it do a thing similar to this in pseudocode:

var_name = "HIGHESTNUMANODENUMBER"
result = GetEnvironmentVariable(var_name)
if not result then
if var_name == "HIGHESTNUMANODENUMBER" then
return GetNumaHighestNodeNumber()
end if
end if

if you not set a environment variable called HIGHESTNUMANODENUMBER, cmd call to the function GetNumaHighestNodeNumber() http://msdn.microsoft.com/en-us/library/windows/desktop/ms683203%28v=vs.85%29.aspx

Post Reply