JSI Tip 10464. What is the mode of the forest that the domain I am logged onto is a member of?

Using only native commands, I have scripted ForestMode.bat to determine if the forest of the domain I am logged onto is running in one of the following modes:

Windows Server 2003
Windows 2003 Interim
Windows 2000
The syntax for using ForestMode.bat is:

\[Call\] ForestMode Mode

Where Mode is a call directed environment variable that will contain the Mode.

NOTE: See What is the mode of my domain?

ForestMode.bat contains:

@echo Off
if \{%1\}==\{\} @echo Syntax: ForestMode Mode&goto :EOF
if exist "%TEMP%/ForestMode.vbs" goto doit
@echo.set objRootDSE = GetObject("LDAP://RootDSE")>"%TEMP%/ForestMode.vbs"
@echo.set objDom = GetObject("LDAP://cn=partitions," ^& objRootDSE.Get("configurationNamingContext") )>>"%TEMP%/ForestMode.vbs"
@echo.if objDom.Get("msDS-Behavior-Version") = 2 then>>"%TEMP%/ForestMode.vbs"
@echo.  Wscript.Echo "Windows Server 2003">>"%TEMP%/ForestMode.vbs"
@echo.ElseIf objDom.Get("msDS-Behavior-Version") = 1 then>>"%TEMP%/ForestMode.vbs"
@echo.  script.Echo "Windows 2003 Interim">>"%TEMP%/ForestMode.vbs"
@echo.  Wscript.Echo "Windows 2000">>"%TEMP%/ForestMode.vbs"
@echo.End If>>"%TEMP%/ForestMode.vbs"
for /f "Tokens=*" %%f in ('cscript //nologo "%TEMP%/ForestMode.vbs"') do (
 set %1=%%f

Hide comments


  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.