anchor.diff:  if defined DIR goto :dirname.next
   set "DIR=."			&:# If empty, return the current directory
   :dirname.done
  +%PREPVAR% DIR
   endlocal & set "%~2=%DIR%" & exit /b
  +
  +:#----------------------------------------------------------------------------#
  +
  +:IsAdmin
  +>NUL 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"
  +exit /b
  +
  +:#----------------------------------------------------------------------------#
  +
  +:# Get the current console code page.
  +:GetCP %1=variable name
  +for /f "tokens=2 delims=:" %%n in ('chcp') do for %%p in (%%n) do set "%1=%%p"
  +exit /b
  +
  +:#----------------------------------------------------------------------------#
  +
  +:# Get a registry value content. Args: KEY NAME [VALUEVAR [TYPEVAR]]
  +:GetRegistryValue
  +%ENTER%
  +setlocal enableextensions enabledelayedexpansion
  +set "KEY=%~1"
  +set "NAME=%~2"
  +set "VALUEVAR=%~3"
  +set "TYPEVAR=%~4"
  +if not defined VALUEVAR set "VALUEVAR=VALUE"
  +set "%VALUEVAR%="
  +:# Returning the type is optional. Do not define a default for TYPEVAR.
  +%ECHOVARS.D% KEY NAME VALUEVAR TYPEVAR
  +if defined NAME (
  +  set CMD=reg query "%KEY%" /v "%NAME%"
  +) else (
  +  set CMD=reg query "%KEY%" /ve
  +)
  +%ECHO.D% %CMD%
  +set "RETCODE=1"
  +:# For each line in CMD output...
  +%FOREACHLINE% %%i in ('%CMD% 2^>NUL') do (
  +  set "RETCODE=0"
  +  set "LINE=%%i"
  +  %ECHOVARS.D% LINE
  +  :# Values are indented by 4 spaces.
  +  set "HEAD=!LINE:~0,4!"
  +  set "LINE=!LINE:~4!"
  +  :# But extra lines of multi-lined values are indented by >20 spaces.
  +  set "HEAD2=!LINE:~0,4!"
  +  if "!HEAD!"=="    " if not "!HEAD2!"=="    " (
  +    :# Some versions of reg.exe use 4 spaces as field separator; others use a TAB. 
  +    :# Change the 4-spaces around the REG_XX type word to a TAB.
  +    set "TOKENS=!LINE:    =	!"
  +    %ECHOVARS.D% TOKENS
  +    :# Extract the value name as the first item before the first TAB.
  +    :# Names can contain spaces, but assume they don't contain TABs.
  +    for /f "tokens=1,2* delims=	" %%j in ("!TOKENS!") do (
  +      set "NAME=%%j"
  +      set "TYPE=%%k"
  +      set "VALUE=%%l"
  +      %ECHOVARS.D% NAME TYPE VALUE
  +    )
  +  )
  +)
  +%PREPVAR% VALUE
  +endlocal & (if defined TYPEVAR set "%TYPEVAR%=%TYPE%") & set "%VALUEVAR%=%VALUE%" & %RETURN% %RETCODE%
  +
  +:#----------------------------------------------------------------------------#
  +
  +:# Append a file pathname to a list of pathnames if it's not already there
  +:FileSet.append %1=LIST_VAR_NAME %2=VALUE
  +setlocal EnableDelayedExpansion
  +set "LIST=!%1!"
  +set "FOUND=0"
  +for %%e in (!LIST!) do if /i "%%~e"=="%~2" set "FOUND=1"
  +if "%FOUND%"=="0" set "LIST=!LIST! %2"
  +%PREPVAR% LIST
  +endlocal & set "%1=%LIST%" & exit /b
   
   :#----------------------------------------------------------------------------#
   
  
positive.code: if [%1]==[] goto :start
  if [%1]==[/?] goto :help
  if [%1]==[-?] goto :help
  if [%1]==[-d] set "ECHO.D=call :Echo" & set "ECHOVARS.D=call :EchoVars.d" & set "RETURN=call :Return" & goto :next_arg
  if [%1]==[-V] (echo %VERSION%) & exit /b 0
  if [%1]==[-X] set "EXEC=echo" & goto :next_arg
  if [%1]==[-y] set "QUIET=1" & goto :next_arg
  >&2 echo Error: Unexpected argument: %1
  exit /b 1
  
  :start
  cd "%SPATH%"
  
  :# Get this new instance version
  call :GetAgVersion "win32\ag.exe"
  
negative.code: exit /b
  
  :CompareInteger %1=Integer1 %2=Integer2
  if "%1%2"=="" exit /b 0				&:# They're both empty, thus equal
  if "%2"=="" exit /b 1				&:# Integer1 > nothing
  if "%1"=="" exit /b -1				&:# nothing < Integer2
  setlocal
  set /a "DIFF=%1-%2"
  if "%DIFF%"=="0" endlocal & exit /b 0		&:# They're equal
  if "%DIFF:-=%"=="%DIFF%" endlocal & exit /b 1	&:# Integer1 > Integer2
  endlocal & exit /b -1				&:# Integer1 < Integer2
  
  :CompareVersions %1=Version1 %2=Version2
  %ENTER%
  setlocal
  call :SplitVer %1 V1MAJOR V1MINOR V1PATCH V1BUILD
  call :SplitVer %2 V2MAJOR V2MINOR V2PATCH V2BUILD
  call :CompareInteger %V1MAJOR% %V2MAJOR%
  