REM #################### Universal Environment Settings ####################
REM #
REM #  ⲿݣĿͬһ²޸
REM #
REM ########################################################################

REM ## Jenkins Server
set JenkinsServerName=

REM ## Klocwork server
set KlocworkProjectServerHost=

REM ## Klocwork ProjectServer Port
set KlocworkProjectServerPort=

REM ## Klocwork LicenseServer Host
set KlocworkLicenseServerHost=

REM ## Klocwork LicenseServer Port
set KlocworkLicenseServerPort=

REM ## Klocwork projects_root dir
set KlocworkProjectsRoot=

REM ## Klocwork Script Path
set KlocworkScriptsPath=

REM ## JenkinsִʱĿĿ¼һworkspaceĿ¼һ(workspace·Դ)⽫ĿĿ¼ΪԴĿ¼ΪĿĿ¼»ɵıļӶ
set ProjectPath=%WORKSPACE%

REM ## Jenkinsjobƣһ㲻޸ġ
set ProjectName=%JOB_NAME%

REM ########################### Project Settings ###########################
REM #
REM #  ĿģʽԡSet
REM #
REM ########################################################################

REM ## SCM ͣȡֵ svngit
set SCM=svn

REM ## JenkinsִʱbuildKlocworkڴĿ¼ִ
set SourcePath=%WORKSPACE%

REM ## Jenkins Ŀ˵ɰġŵַ
set ProjectDescription=

REM ## Ŀģʽ0=У1=ֻʼߣ2=ʼ
set RunningMode=

REM ## Klocwork ʱõĲ߳(cpu core/thread) 1==>10
set JobNumber=

REM ## KlocworkĿƣĬΪJenkinsĿĿͬܰģŽ֧» -->
set KlocworkProjectName=%ProjectName%

REM ## Klocwork: Source Language: c,cxx,java,csharp
set SourceLanguage=

REM ## Klocwork: Source Encoding: UTF-8, GBK, GB2312, US-ASCII, ISO-8859-1
set SourceEncoding=UTF-8

REM ## Klocwork Clean Command
set CleanCommand=

REM ## Klocwork Make Command: ˫(")ת룺pythonűԶ(')滻Ϊ˫
set KlocworkMakeCommand=

REM ###################### Email Notification Setting ######################
REM #
REM #  Set Email
REM #
REM ########################################################################

REM ## Email Domain
set EmailDomain=
REM ## Email Smtp server
set EmailSmtp=
REM ## EmailSender
set EmailSender=
REM ## EmailAuthUserID
set EmailAuthUserID=
REM ## EmailAuthUserPassword
set EmailAuthUserPassword=

REM ## ʼ͵ַΪʼʼַӢĶ(,)ָűԳ͵ַκδ
set CCEmailAddress=
REM ## ʼܾûΪʼӢĶ(",")ָû"*"ʾȫûűݴ˻ʼռˣԴOwnerй˴
set RejectEmailName=

python "%KlocworkScriptsPath%\analysis.py" %JenkinsServerName% %SCM% %KlocworkProjectServerHost% %KlocworkProjectServerPort% %KlocworkLicenseServerHost% %KlocworkLicenseServerPort% %EmailDomain% %EmailSmtp% %EmailSender% %EmailAuthUserID% %EmailAuthUserPassword% %RunningMode% %JobNumber% %ProjectName% %ProjectDescription% %KlocworkProjectName% %KlocworkScriptsPath% %ProjectPath% %SourcePath% %SourceLanguage% %SourceEncoding% %CleanCommand% %KlocworkMakeCommand% %CCEmailAddress% %RejectEmailName% %KlocworkProjectsRoot% END

REM ####################### Universal Environment Settings #######################
REM ## Jenkins Server
set JenkinsServerName=

REM ## Klocwork Server
set KlocworkProjectServerHost=

REM ## Klocwork ProjectServer Port
set KlocworkProjectServerPort=

REM ## Klocwork LicenseServer Host
set KlocworkLicenseServerHost=

REM ## Klocwork LicenseServer Port
set KlocworkLicenseServerPort=

REM ## Klocwork projects_root dir
set KlocworkProjectsRoot=

REM ## Klocwork Script Path
set KlocworkScriptsPath=

REM ## Jenkins Project Path, usually %WORKSPACE%/../
set ProjectPath=%WORKSPACE%/../

REM ## Jenkins Job Name
set ProjectName=%JOB_NAME%

REM ############################## Project Settings ##############################
REM ## SCM tool: svn or git
set SCM=svn

REM ## the path Jenkins stores the source code
set SourcePath=%WORKSPACE%

REM ## Jenkins project description, Chinese characters are acceptable
set ProjectDescription=

REM ## running mode0 Normal Mode; 1 send mail to CCList; 2 don't send mail
set RunningMode=

REM ## Klocwork cpu core/thread number
set JobNumber=

REM ## Klocwork project name, usually same with jenkins job name, Chinese characters and hyphens are not allowed
set KlocworkProjectName=%ProjectName%

REM ## Klocwork: Source Language: c,cxx,java,csharp
set SourceLanguage=

REM ## Klocwork: Source Encoding: UTF-8, GBK, GB2312, US-ASCII, ISO-8859-1
set SourceEncoding=UTF-8

REM ## Klocwork Clean Command, replace double quotation mark with single quotation mark
set CleanCommand=

REM ## Klocwork Make Command, replace double quotation mark with single quotation mark
set KlocworkMakeCommand=

REM ######################### Email Notification Setting #########################
REM ## Email Domain
set EmailDomain=
REM ## Email Smtp server
set EmailSmtp=
REM ## EmailSender
set EmailSender=
REM ## EmailAuthUserID
set EmailAuthUserID=
REM ## EmailAuthUserPassword
set EmailAuthUserPassword=

REM ## CCList.EmailAddresses with Email domain, separated with comma(,)
set CCEmailAddress=
REM ## Email reject name list without Email domain, separated with comma(,). Asterisk mark(*) represents whole user names.
set RejectEmailName=

python "%KlocworkScriptsPath%\analysis.py" %JenkinsServerName% %SCM% %KlocworkProjectServerHost% %KlocworkProjectServerPort% %KlocworkLicenseServerHost% %KlocworkLicenseServerPort% %EmailDomain% %EmailSmtp% %EmailSender% %EmailAuthUserID% %EmailAuthUserPassword% %RunningMode% %JobNumber% %ProjectName% %ProjectDescription% %KlocworkProjectName% %KlocworkScriptsPath% %ProjectPath% %SourcePath% %SourceLanguage% %SourceEncoding% %CleanCommand% %KlocworkMakeCommand% %CCEmailAddress% %RejectEmailName% %KlocworkProjectsRoot% END

convert into English due to GBK encoding bug in Sublime


"C:\Program Files\PostgreSQL\9.4\bin\psql.exe" -h localhost -U postgres -d report_manager_database  -p 5432 -f ..\action_change_password.sql 1> test_action_change_password.log 2>&1

"C:\Program Files\PostgreSQL\9.4\bin\psql.exe" -h localhost -U postgres -d report_manager_database  -p 5432 -f test_action_change_password.sql  1>> test_action_change_password.log 2>>&1

REM install db
call C:\funda_components\system_user\system_user_database\system_user_test_db\install_system_user_test_db.bat

"C:\Program Files\PostgreSQL\9.6\bin\psql.exe" -h localhost -U postgres -d system_user_test_db  -p 5432 -f ..\action_change_password.sql 1> test_action_change_password.log 2>&1

"C:\Program Files\PostgreSQL\9.6\bin\psql.exe" -h localhost -U postgres -d system_user_test_db  -p 5432 -f test_action_change_password.sql  1>> test_action_change_password.log 2>>&1

update psql path

update psql path


@echo off

setlocal

set "FTP_HOME=%~dp0..\vendors\FTP"
set "FTP_NAME=FileZilla Server.exe"
set "FTP_CONF=FileZilla Server.xml"
set "FTP_CTRL=FileZilla Server Interface.exe"

if /i "%~1" == "start" for /f "tokens=2 delims==>" %%d in ( '
	findstr /i /r /c:"<Permission Dir=\".*\">" "%FTP_HOME%\%FTP_CONF%"
' ) do (
	if exist %%~dd if not exist %%d md %%d
)

for %%a in ( install uninstall start stop ) do if /i "%~1" == "%%~a" (
	"%FTP_HOME%\%FTP_NAME%" /%%~a
	endlocal
	goto :EOF

)

if /i "%~1" == "status" (
	echo:Service
	wmic Service WHERE "Name = '%FTP_NAME%'" get Name,State /value | findstr "."
	echo:
	echo:Process
	tasklist /fi "IMAGENAME EQ %FTP_NAME%" /fo list
	endlocal
	goto :EOF
)

if /i "%~1" == "control" (
	start "" "%FTP_HOME%\%FTP_CTRL%"
	endlocal
	goto :EOF
)

:: More command line arguments
:: https://wiki.filezilla-project.org/Command-line_arguments_%28Server%29
echo:Usage:
echo:	%~n0 INSTALL ^| UNINSTALL
echo:	%~n0 START ^| STOP
echo:	%~n0 STATUS ^| CONTROL
echo:
echo:INSTALL		install or uninstall the service
echo:UNINSTALL
echo:START		start or stop the server as the service
echo:STOP
echo:STATUS		check the status of processes and services
echo:CONTROL		launch the controlling client

endlocal

:: EOF

@echo off

setlocal

set "FTP_HOME=%~dp0..\vendors\FTP"
set "FTP_NAME=FileZilla Server.exe"
set "FTP_CONF=FileZilla Server.xml"
set "FTP_CTRL=FileZilla Server Interface.exe"

if /i "%~1" == "start" call :prepare-dirs
if /i "%~1" == "compat-start" call :prepare-dirs

for %%a in ( install uninstall start stop ) do if /i "%~1" == "%%~a" (
	"%FTP_HOME%\%FTP_NAME%" /%%~a
	endlocal
	goto :EOF

)

for %%a in ( start stop ) do if /i "%~1" == "compat-%%~a" (
	start "" "%FTP_HOME%\%FTP_NAME%" /compat /%%~a
	endlocal
	goto :EOF

)

if /i "%~1" == "status" (
	echo:Service
	wmic Service WHERE "Name = '%FTP_NAME%'" get Name,State /value | findstr "."
	echo:
	echo:Process
	tasklist /fi "IMAGENAME EQ %FTP_NAME%" /fo list
	endlocal
	goto :EOF
)

if /i "%~1" == "control" (
	start "" "%FTP_HOME%\%FTP_CTRL%"
	endlocal
	goto :EOF
)

:: More command line arguments
:: https://wiki.filezilla-project.org/Command-line_arguments_%28Server%29
echo:Usage:
echo:	%~n0 INSTALL ^| UNINSTALL
echo:	%~n0 START ^| STOP ^| COMPAT-START ^| COMPAT-STOP
echo:	%~n0 STATUS ^| CONTROL
echo:
echo:INSTALL		install or uninstall the service
echo:UNINSTALL
echo:START		start or stop the server as the service
echo:STOP
echo:COMPAT-START	start or stop the server as the application
echo:COMPAT-STOP
echo:STATUS		check the status of processes and services
echo:CONTROL		launch the controlling client

endlocal
goto :EOF

:prepare-dirs
for /f "tokens=2 delims==>" %%d in ( '
	findstr /i /r /c:"<Permission Dir=\".*\">" "%FTP_HOME%\%FTP_CONF%"
' ) do (
	if exist %%~dd if not exist %%d md %%d
)
goto :EOF

:: EOF

improve ftpd.bat

improve ftpd.bat


@echo off

setlocal

set "FTP_HOME=%~dp0..\vendors\FTP"
set "FTP_NAME=FileZilla Server.exe"
set "FTP_CONF=FileZilla Server.xml"
set "FTP_CTRL=FileZilla Server Interface.exe"

if /i "%~1" == "start" call :prepare-dirs
if /i "%~1" == "compat-start" call :prepare-dirs

for %%a in ( install uninstall start stop ) do if /i "%~1" == "%%~a" (
	"%FTP_HOME%\%FTP_NAME%" /%%~a
	endlocal
	goto :EOF

)

for %%a in ( start stop ) do if /i "%~1" == "compat-%%~a" (
	start "" "%FTP_HOME%\%FTP_NAME%" /compat /%%~a
	endlocal
	goto :EOF

)

if /i "%~1" == "status" (
	echo:Service
	wmic Service WHERE "Name = '%FTP_NAME%'" get Name,State /value | findstr "."
	echo:
	echo:Process
	tasklist /fi "IMAGENAME EQ %FTP_NAME%" /fo list
	endlocal
	goto :EOF
)

if /i "%~1" == "control" (
	start "" "%FTP_HOME%\%FTP_CTRL%"
	endlocal
	goto :EOF
)

:: More command line arguments
:: https://wiki.filezilla-project.org/Command-line_arguments_%28Server%29
echo:Usage:
echo:	%~n0 INSTALL ^| UNINSTALL
echo:	%~n0 START ^| STOP ^| COMPAT-START ^| COMPAT-STOP
echo:	%~n0 STATUS ^| CONTROL
echo:
echo:INSTALL		install or uninstall the service
echo:UNINSTALL
echo:START		start or stop the server as the service
echo:STOP
echo:COMPAT-START	start or stop the server as the application
echo:COMPAT-STOP
echo:STATUS		check the status of processes and services
echo:CONTROL		launch the controlling client

endlocal
goto :EOF

:prepare-dirs
for /f "tokens=2 delims==>" %%d in ( '
	findstr /i /r /c:"<Permission Dir=\".*\">" "%FTP_HOME%\%FTP_CONF%"
' ) do (
	if exist %%~dd if not exist %%d md %%d
)
goto :EOF

:: EOF

@echo off

setlocal

set "FTP_HOME=%~dp0..\vendors\FTP-0.9.53"

set "FTP_PROC_NAME=FileZilla Server"
set "FTP_CTRL_NAME=FileZilla Server Interface"

set "FTP_PROC=%FTP_PROC_NAME%.exe"
set "FTP_CONF=%FTP_PROC_NAME%.xml"
set "FTP_CTRL=%FTP_CTRL_NAME%.exe"

if /i "%~1" == "start" call :prepare-dirs
if /i "%~1" == "compat-start" call :prepare-dirs

for %%a in ( install uninstall start stop ) do if /i "%~1" == "%%~a" (
	"%FTP_HOME%\%FTP_PROC%" /%%~a
	endlocal
	goto :EOF

)

for %%a in ( start stop ) do if /i "%~1" == "compat-%%~a" (
	start "" "%FTP_HOME%\%FTP_PROC%" /compat /%%~a
	endlocal
	goto :EOF

)

if /i "%~1" == "status" (
	echo:Service
	echo:
	wmic Service WHERE "Name = '%FTP_PROC_NAME%'" get Name,State /value | findstr "."
	echo:
	echo:Process
	echo:
	wmic Process WHERE "Name = '%FTP_PROC%'" get Name,CommandLine,ProcessId,SessionId /value | findstr "."
	rem tasklist /fi "IMAGENAME EQ %FTP_PROC%" /fo list
	endlocal
	goto :EOF
)

if /i "%~1" == "control" (
	start "" "%FTP_HOME%\%FTP_CTRL%"
	endlocal
	goto :EOF
)

:: More command line arguments
:: https://wiki.filezilla-project.org/Command-line_arguments_%28Server%29
echo:Usage:
echo:	%~n0 INSTALL ^| UNINSTALL
echo:	%~n0 START ^| STOP ^| COMPAT-START ^| COMPAT-STOP
echo:	%~n0 STATUS ^| CONTROL
echo:
echo:INSTALL		install or uninstall the service
echo:UNINSTALL
echo:START		start or stop the server as the service
echo:STOP
echo:COMPAT-START	start or stop the server as the application
echo:COMPAT-STOP
echo:STATUS		check the status of processes and services
echo:CONTROL		launch the controlling client

endlocal
goto :EOF

:prepare-dirs
for /f "tokens=2 delims==>" %%d in ( '
	findstr /i /r /c:"<Permission Dir=\".*\">" "%FTP_HOME%\%FTP_CONF%"
' ) do (
	if exist %%~dd if not exist %%d md %%d
)
goto :EOF

:: EOF

improve the output for "ftpd status"

improve the output for "ftpd status"


@echo off
rem ----------------------------------------------------------------------------
rem Copyright (c) 2022, WSO2 Inc. (http://www.wso2.com).
rem
rem WSO2 Inc. licenses this file to you under the Apache License,
rem Version 2.0 (the "License"); you may not use this file except
rem in compliance with the License.
rem You may obtain a copy of the License at
rem
rem http://www.apache.org/licenses/LICENSE-2.0
rem
rem Unless required by applicable law or agreed to in writing,
rem software distributed under the License is distributed on an
rem "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
rem KIND, either express or implied.  See the License for the
rem specific language governing permissions and limitations
rem under the License.

rem ----------------------------------------------------------------------------
rem Adaptive Authentication Script for the WSO2 Carbon Server
rem
rem Environment Variable Prequisites
rem
rem    CARBON_HOME   	Home of WSO2 Carbon installation. If not set I will  try
rem                    	to figure it out.
rem    NASHORN_VERSION   	OpenJDK Nashorn Version
rem
rem    ASM_VERSION   	ASM Util, Commons Version.
rem
rem -----------------------------------------------------------------------------

set NASHORN_VERSION=15.3
set ASM_VERSION=9.2

set SERVER_RESTART_REQUIRED="false"

set CARBON_HOME=%1
set DISABLE=%2

set LIB_REPO=%CARBON_HOME%\repository\components\lib

setlocal enabledelayedexpansion

rem commandline arguement 'DISABLE' or 'disable' is passed
if "%DISABLE%"=="DISABLE" goto disableAdaptiveAuth
if "%DISABLE%"=="disable" goto disableAdaptiveAuth
rem no commandline arguements are passed
goto enableAdaptiveAuth

:disableAdaptiveAuth
set LOCAL_NASHORN_VERSION=""
set LOCAL_ASM_VERSION=""
if exist "%CARBON_HOME%\repository\components\lib\nashorn-core-*.jar" (
  set SERVER_RESTART_REQUIRED="true"
  for /f "delims=" %%i in ('dir /s /b %CARBON_HOME%\repository\components\lib\nashorn-core-*.jar') do set "location=%%i"
  for %%j in (!location!!) do set "full_artifact_name=%%~nxj"
  for /f "tokens=3 delims=-" %%k in ("!full_artifact_name!") do set "artifact_name=%%k"
  for /f "tokens=1,2 delims=." %%l in ("!artifact_name!") do set "LOCAL_NASHORN_VERSION=%%l.%%m"
  echo Remove existing Nashorn library from lib folder: !full_artifact_name!
  del !location!
  echo Nashorn library Removed from components\lib.
)
if exist "%CARBON_HOME%\repository\components\dropins\nashorn_core_*.jar" (
  set SERVER_RESTART_REQUIRED="true"
  for /f "delims=" %%i in ('dir /s /b %CARBON_HOME%\repository\components\dropins\nashorn_core_!LOCAL_NASHORN_VERSION!*.jar') do set "location=%%i"
  for %%j in (!location!!) do set "full_artifact_name=%%~nxj"
  echo Remove existing Nashorn library from dropins: !full_artifact_name!
  del /f !location!
  echo Nashorn library Removed from components\dropins.
)
if exist "%CARBON_HOME%\repository\components\lib\asm-util-*.jar" (
  set SERVER_RESTART_REQUIRED="true"
  for /f "delims=" %%i in ('dir /s /b %CARBON_HOME%\repository\components\lib\asm-util-*.jar') do set "location=%%i"
  for %%j in (!location!!) do set "full_artifact_name=%%~nxj"
  for /f "tokens=3 delims=-" %%k in ("!full_artifact_name!") do set "artifact_name=%%k"
  for /f "tokens=1,2 delims=." %%l in ("!artifact_name!") do set "LOCAL_ASM_VERSION=%%l.%%m"
  echo Remove existing ASM Util library from lib folder: !full_artifact_name!
  del !location!
  echo ASM Util library Removed from components\lib.
)
if exist "%CARBON_HOME%\repository\components\dropins\asm_util_*.jar" (
  set SERVER_RESTART_REQUIRED="true"
  for /f "delims=" %%i in ('dir /s /b %CARBON_HOME%\repository\components\dropins\asm_util_!LOCAL_ASM_VERSION!*.jar') do set "location=%%i"
  for %%j in (!location!!) do set "full_artifact_name=%%~nxj"
  echo Remove existing ASM Util library from dropins: !full_artifact_name!
  del !location!
  echo ASM Util library Removed from components\dropins.
)
echo Adaptive authentication successfully disabled.
goto printRestartMsg

:enableAdaptiveAuth
if exist "%CARBON_HOME%\repository\components\lib\nashorn-core-*.jar" (
  for /f "delims=" %%i in ('dir /s /b %CARBON_HOME%\repository\components\lib\nashorn-core-*.jar') do set "location=%%i"
  for %%j in (!location!!) do set "full_artifact_name=%%~nxj"
  for /f "tokens=3 delims=-" %%k in ("!full_artifact_name!") do set "artifact_name=%%k"
  for /f "tokens=1,2 delims=." %%l in ("!artifact_name!") do set "LOCAL_NASHORN_VERSION=%%l.%%m"

  if %NASHORN_VERSION%==!LOCAL_NASHORN_VERSION!  (
    echo Nashorn library exists. No need to download.
  ) else (
    set SERVER_RESTART_REQUIRED="true"
    echo Required Nashorn library not found. Remove existing library : !full_artifact_name!
    del !location!
    if exist "%CARBON_HOME%\repository\components\dropins\nashorn_core_*.jar" (
       for /f "delims=" %%i in ('dir /s /b %CARBON_HOME%\repository\components\dropins\nashorn_core_!LOCAL_NASHORN_VERSION!*.jar') do set "location=%%i"
       for %%j in (!location!!) do set "full_artifact_name=%%~nxj"
       echo Remove existing Nashorn library from dropins: !full_artifact_name!
       del !location!
       echo Nashorn library Removed from components\dropins.
    )
    echo Downloading required Nashorn library : nashorn-core-%NASHORN_VERSION%
    call mvn dependency:get -Dartifact=org.openjdk.nashorn:nashorn-core:%NASHORN_VERSION% -Ddest=%LIB_REPO%
    echo Nashorn library updated.
  )
) else (
  set SERVER_RESTART_REQUIRED="true"
  echo Nashorn library not found. Starting to download.....
  call mvn dependency:get -Dartifact=org.openjdk.nashorn:nashorn-core:%NASHORN_VERSION% -Ddest=%LIB_REPO%
  echo Nashorn download completed. Downloaded version : nashorn-core-%NASHORN_VERSION%
)

if exist "%CARBON_HOME%\repository\components\lib\asm-util-*.jar" (
  for /f "delims=" %%i in ('dir /s /b %CARBON_HOME%\repository\components\lib\asm-util-*.jar') do set "location=%%i"
  for %%j in (!location!!) do set "full_artifact_name=%%~nxj"
  for /f "tokens=3 delims=-" %%k in ("!full_artifact_name!") do set "artifact_name=%%k"
  for /f "tokens=1,2 delims=." %%l in ("!artifact_name!") do set "LOCAL_ASM_VERSION=%%l.%%m"

  if %ASM_VERSION%==!LOCAL_ASM_VERSION!  (
    echo ASM-Util library exists. No need to download.
  ) else (
    set SERVER_RESTART_REQUIRED="true"
    echo Required ASM-Util library not found. Remove existing library : !full_artifact_name!
    del !location!
    if exist "%CARBON_HOME%\repository\components\dropins\asm_util_*.jar" (
       for /f "delims=" %%i in ('dir /s /b %CARBON_HOME%\repository\components\dropins\asm_util_!LOCAL_ASM_VERSION!*.jar') do set "location=%%i"
       for %%j in (!location!!) do set "full_artifact_name=%%~nxj"
       echo Remove existing ASM Util library from dropins: !full_artifact_name!
       del !location!
       echo ASM Util library Removed from components\dropins.
    )
    echo Downloading required ASM-Util library : asm-util-%ASM_VERSION%
    call mvn dependency:get -Dartifact=org.ow2.asm:asm-util:%ASM_VERSION% -Ddest=%LIB_REPO%
    echo ASM-Util library updated.
  )
) else (
  set SERVER_RESTART_REQUIRED="true"
  echo ASM-Util library not found. Starting to download.....
  call mvn dependency:get -Dartifact=org.ow2.asm:asm-util:%ASM_VERSION% -Ddest=%LIB_REPO%
  echo ASM-Util download completed. Downloaded version : asm-util-%ASM_VERSION%
)
echo Adaptive authentication successfully enabled.
goto printRestartMsg

:printRestartMsg
if %SERVER_RESTART_REQUIRED%=="true" (
  echo Please restart the server.
)
goto end

:end
endlocal

Add adaptive auth batch script for integration tests on windows


@echo off
setlocal

java -jar -Dlog4j.configurationFile=./conf/log4j2.xml -Dorg.jboss.logging.provider=slf4j ./lib/raildelays-batch.jar
PAUSE

@echo off
setlocal

java -jar -Dlog4j.configurationFile=./conf/log4j2.xml -Dorg.jboss.logging.provider=slf4j -DLog4jContextSelector=org.apache.logging.log4j.core.async.AsyncLoggerContextSelector ./lib/raildelays-batch.jar
PAUSE

Update run.bat

Update run.bat

[#15] Configured Log4j2 to enable asynchronous logging


@echo off
echo 'Will change the versions in pom.xml files based on git branch name when doing Jenkins CI build...'

::
:: get git branch_name
::

:: get current git branch name
:: Jenkins will set GIT_BRANCH environment variable if this batch is running in a Jenkins job
goto getbranch_name-2

:getbranch_name-1
if %GIT_BRANCH%==""  (
	echo GIT_BRANCH is NOT defined
	for /f %%i in ('"git rev-parse --abbrev-ref HEAD"') do set branch_name=%%i
) else (
 	echo GIT_BRANCH is defined
 	set branch_name=%GIT_BRANCH%
)

:getbranch_name-2
if defined GIT_BRANCH (
 	echo GIT_BRANCH is defined
 	set branch_name=%GIT_BRANCH%
) else (
 	echo GIT_BRANCH is NOT defined
 	for /f %%i in ('"git rev-parse --abbrev-ref HEAD"') do set branch_name=%%i
)

:: replace origin/ with empty if have
set branch_name=%branch_name:origin/=%

echo branch_name is %branch_name%

if %branch_name%==dev (
	echo It is dev branch build. Do nothing
	goto end
)

::
:: get current_version in parent pom
::

:: get the pathname of the batch script itself with %0
REM echo %0
:: parameter extensions can be applied to this so %~dp0 will return the Drive and Path to the batch script
REM echo %~dp0
:: %~f0 will return the full pathname
REM echo %~f0
:: You can refer to other files in the same folder as the batch script by using this syntax
:: echo %0\..\SecondBatch.cmd
REM echo %~dp0\access-control-service
:: set the working directory of a command in windows batch file
REM pushd %~dp0\access-control-service

:: WORKSPACE  The absolute path of the workspace if running in a Jenkins job.
:: set the working directory of a command in windows batch file
pushd %WORKSPACE%\c2s-ui-api

:: get current version of the top level pom
:: call mvn help:evaluate -Dexpression=project.version
:: for /f %%i in ('"mvn help:evaluate -Dexpression=project.version | grep -v '\[.*'"') do set current_version=%%i
:: run the following line first to have downloading done before next line
call mvn help:evaluate -Dexpression=project.version
:: The following link couldn't excluding Downloading: line
for /f %%i in ('"mvn help:evaluate -Dexpression=project.version | grep -v '\[.*'"') do set current_version=%%i

echo current_version is %current_version%

::
:: get Jenkins BUILD_NUMBER
::

:: Jenkins will set BUILD_NUMBER environment variable if this batch is running in a Jenkins job
if defined BUILD_NUMBER (
 	echo BUILD_NUMBER is defined
) else (
 	set BUILD_NUMBER=0
)

::
:: build new version
::

if %branch_name%==dev (
	echo It is dev branch build
	goto end
) else if %branch_name%==master (
	echo It is master branch build
	:: replace .0-SNAPSHOT with empty and append build number
	set new_version=%current_version:.0-SNAPSHOT=%.%BUILD_NUMBER%
) else (
	echo It is not master/dev branch
	echo Put the branch name in the qualifier
	:: replace .0-SNAPSHOT with empty, append build number and add branch name as quilifier
	set new_version=%current_version:.0-SNAPSHOT=%.%BUILD_NUMBER%-%branch_name%
)

echo new_version is %new_version%

:: Sets the current projects version, updating the details of any child modules as necessary.
call mvn versions:set -DgenerateBackupPoms=false -DnewVersion=%new_version%

:: Scans the current projects child modules, updating the versions of any which use the current project to the version of the current project.
::call mvn versions:update-child-modules -DgenerateBackupPoms=false -DnewVersion=%new_version%

::
:: generate a version properties file to be used by Jenkins Enviorenment Injector Plugin to generate a Jenkins PROJECT_VERSION environment variable
::

echo PROJECT_VERSION=%new_version% > version.properties

::
:: generate a commit properties file to be used by Jenkins Enviorenment Injector Plugin to generate a Jenkins GIT_COMMIT_ID environment variable
::
for /f %%i in ('"git rev-parse HEAD"') do set commit_id=%%i
echo GIT_COMMIT_ID=%commit_id% > commit.properties

:: reset the working directory
popd

:end

Change version in pom.xml during Jenkins CI build

#12893 - As a developer, I will have released C2S version [3.0.0]


@ECHO OFF
SET VBM="c:\program files\oracle\virtualbox\vboxmanage.exe"

rem Shutdown existing VM:s
%VBM% controlvm Abitti-KOE poweroff
%VBM% controlvm Abitti-KTP poweroff

rem Delete existing VM:s and related files
%VBM% unregistervm Abitti-KOE --delete
%VBM% unregistervm Abitti-KTP --delete

rem Delete existing disk images
IF NOT EXIST *.vdi GOTO Create_VMs

SET /P ANSWER=VDI files exist. Delete vdi files? (Y/N)?
IF /i {%ANSWER%}=={y} (GOTO Remove_Disks)
GOTO Create_VMs

:Remove_Disks
del *.vdi

:Create_VMs
rem Convert disk images
%VBM% convertfromraw ktp.dd ktp.vdi --format vdi
%VBM% convertfromraw koe.dd koe.vdi --format vdi

rem Add more size to KTP image
%VBM% modifyhd "%CD%\ktp.vdi" --resize 8192

rem Create VM
%VBM% createvm --name Abitti-KOE --register --ostype Linux_64
%VBM% createvm --name Abitti-KTP --register --ostype Linux_64

rem Modify VM: Add storage, network, memory...
%VBM% modifyvm Abitti-KOE --memory 2048 --nic1 intnet --intnet1 abitti --usb on --usbehci on --firmware efi
%VBM% modifyvm Abitti-KTP --memory 4096 --nic1 intnet --intnet1 abitti --usb on --usbehci on --firmware efi

%VBM% storagectl Abitti-KOE --name SATA --add sata --controller IntelAHCI --portcount 1
%VBM% storagectl Abitti-KTP --name SATA --add sata --controller IntelAHCI --portcount 1

%VBM% storageattach Abitti-KOE --storagectl "SATA" --device 0 --port 0 --type hdd --medium "%CD%\koe.vdi"
%VBM% storageattach Abitti-KTP --storagectl "SATA" --device 0 --port 0 --type hdd --medium "%CD%\ktp.vdi"

%VBM% modifyvm Abitti-KOE --audiocontroller hda

rem Take initial snapshots
%VBM% snapshot Abitti-KOE take "Before first boot"
%VBM% snapshot Abitti-KTP take "Before first boot"

echo "All Done!"
pause

@ECHO OFF
SET VBM="c:\program files\oracle\virtualbox\vboxmanage.exe"

rem Shutdown existing VM:s
%VBM% controlvm Abitti-KOE poweroff
%VBM% controlvm Abitti-KTP poweroff

rem Delete existing VM:s and related files
%VBM% unregistervm Abitti-KOE --delete
%VBM% unregistervm Abitti-KTP --delete

rem Delete existing disk images
IF NOT EXIST *.vdi GOTO Create_VMs

SET /P ANSWER=VDI files exist. Delete vdi files? (Y/N)?
IF /i {%ANSWER%}=={y} (GOTO Remove_Disks)
GOTO Create_VMs

:Remove_Disks
del *.vdi

:Create_VMs
rem Convert disk images
%VBM% convertfromraw ktp.dd ktp.vdi --format vdi
%VBM% convertfromraw koe.dd koe.vdi --format vdi

rem Add more size to KOE/KTP image
%VBM% modifyhd "%CD%\ktp.vdi" --resize 8192
%VBM% modifyhd "%CD%\koe.vdi" --resize 8192

rem Create VM
%VBM% createvm --name Abitti-KOE --register --ostype Linux_64
%VBM% createvm --name Abitti-KTP --register --ostype Linux_64

rem Modify VM: Add storage, network, memory...
%VBM% modifyvm Abitti-KOE --memory 2048 --nic1 intnet --intnet1 abitti --usb on --usbehci on --firmware efi
%VBM% modifyvm Abitti-KTP --memory 4096 --nic1 intnet --intnet1 abitti --usb on --usbehci on --firmware efi

%VBM% storagectl Abitti-KOE --name SATA --add sata --controller IntelAHCI --portcount 1
%VBM% storagectl Abitti-KTP --name SATA --add sata --controller IntelAHCI --portcount 1

%VBM% storageattach Abitti-KOE --storagectl "SATA" --device 0 --port 0 --type hdd --medium "%CD%\koe.vdi"
%VBM% storageattach Abitti-KTP --storagectl "SATA" --device 0 --port 0 --type hdd --medium "%CD%\ktp.vdi"

%VBM% modifyvm Abitti-KOE --audiocontroller hda

rem Take initial snapshots
%VBM% snapshot Abitti-KOE take "Before first boot"
%VBM% snapshot Abitti-KTP take "Before first boot"

echo "All Done!"
pause

Add more storage also to test takers' disk (Windows hosts)


mvn install:install-file -DgroupId=jamberoo -DartifactId=bsh-2.0b4 -Dversion=1.0 -Dpackaging=jar -Dfile=./bsh-2.0b4.jar
mvn install:install-file -DgroupId=jamberoo -DartifactId=cct-globus -Dversion=1.0 -Dpackaging=jar -Dfile=./cct-globus.jar
mvn install:install-file -DgroupId=jamberoo -DartifactId=Fragments -Dversion=1.0 -Dpackaging=jar -Dfile=./Fragments.jar
mvn install:install-file -DgroupId=jamberoo -DartifactId=j2ssh-common -Dversion=1.0 -Dpackaging=jar -Dfile=./j2ssh-common.jar
mvn install:install-file -DgroupId=jamberoo -DartifactId=j2ssh-core -Dversion=1.0 -Dpackaging=jar -Dfile=./j2ssh-core.jar
mvn install:install-file -DgroupId=jamberoo -DartifactId=Jamberoo-help -Dversion=1.0 -Dpackaging=jar -Dfile=./Jamberoo-help.jar
mvn install:install-file -DgroupId=jamberoo -DartifactId=jbzip2-0.9.1 -Dversion=1.0 -Dpackaging=jar -Dfile=./jbzip2-0.9.1.jar
mvn install:install-file -DgroupId=jamberoo -DartifactId=jcommon-1.0.12 -Dversion=1.0 -Dpackaging=jar -Dfile=./jcommon-1.0.12.jar
mvn install:install-file -DgroupId=jamberoo -DartifactId=jfreechart-1.0.9 -Dversion=1.0 -Dpackaging=jar -Dfile=./jfreechart-1.0.9.jar
mvn install:install-file -DgroupId=jamberoo -DartifactId=jhall -Dversion=1.0 -Dpackaging=jar -Dfile=./jhall.jar
mvn install:install-file -DgroupId=jamberoo -DartifactId=mysql-connector-java-5.1.33-bin -Dversion=1.0 -Dpackaging=jar -Dfile=./mysql-connector-java-5.1.33-bin.jar
mvn install:install-file -DgroupId=jamberoo -DartifactId=Solvents -Dversion=1.0 -Dpackaging=jar -Dfile=./Solvents.jar

Add windows batch file to install jamberoo libs


cd ..
"C:\Program Files\qemu\qemu-system-i386.exe" -d mmu,cpu_reset,guest_errors -soundhw pcspk -serial stdio -no-reboot -m 16M -kernel build/bin/LudOS.bin -append "loglevel=info" -drive id=disk,file=build/bin/LudOS.img,if=none -device ahci,id=ahci -device ide-drive,drive=disk,bus=ahci.0 -initrd 'isodir/boot/initrd.img initrd'
cd tools

cd ..
"C:\Program Files\qemu\qemu-system-i386.exe" -d mmu,cpu_reset,guest_errors -soundhw pcspk -serial stdio -no-reboot -m 16M -kernel build/bin/LudOS.bin -append "loglevel=info" -drive id=disk,file=build/bin/LudOS.img,if=none -device ahci,id=ahci -device ide-drive,drive=disk,bus=ahci.0 -initrd 'build/bin/initrd.img initrd'
cd tools

Update run_windows.bat

Update run_windows.bat


CD git/re2                                                          || EXIT /B 1

cmake -D CMAKE_BUILD_TYPE=Debug -A x64 .                            || EXIT /B 1
cmake --build . --config Debug --clean-first                        || EXIT /B 1
ctest -C Debug --output-on-failure -E dfa^|exhaustive^|random       || EXIT /B 1

cmake -D CMAKE_BUILD_TYPE=Release -A x64 .                          || EXIT /B 1
cmake --build . --config Release --clean-first                      || EXIT /B 1
ctest -C Release --output-on-failure -E dfa^|exhaustive^|random     || EXIT /B 1

EXIT /B 0

CD git/re2                                                            || EXIT /B 1

cmake -D CMAKE_BUILD_TYPE=Debug -G "Visual Studio 12 2013" -A x64 .   || EXIT /B 1
cmake --build . --config Debug --clean-first                          || EXIT /B 1
ctest -C Debug --output-on-failure -E dfa^|exhaustive^|random         || EXIT /B 1

cmake -D CMAKE_BUILD_TYPE=Release -G "Visual Studio 12 2013" -A x64 . || EXIT /B 1
cmake --build . --config Release --clean-first                        || EXIT /B 1
ctest -C Release --output-on-failure -E dfa^|exhaustive^|random       || EXIT /B 1

EXIT /B 0

Use MSVC 2013 for continuous integration.

We claim to support it, so we should ensure
that we actually support it. ;)

Fixes #112.

Change-Id: Ia1fd23eb0e6f83ead453306be0b203782d62fd1c
Reviewed-on: https://code-review.googlesource.com/7492
Reviewed-by: Paul Wankadia <62d4e38bb1380f055ec4b899baa75e52af09c5f7@google.com>


@echo off
setlocal

set VERSION=%1
set VERSTATUS=%2
if [%VERSION%] == [] set VERSION=0.0.0
echo publishing version %VERSION%

set HERE=%~dp0

call :dopublish || goto :ko
goto :ok

:dopublish
%HERE%\src\fullbuild\bin\fullbuild publish * || goto :ko
robocopy %HERE%\apps\full-build %HERE%\refbin /MIR

nuget pack -NoDefaultExcludes -NoPackageAnalysis -NonInteractive -OutputDirectory apps -Version %VERSION%%VERSTATUS% full-build.nuspec || goto :ko
move apps\full-build.%VERSION%.nupkg apps\full-build.nupkg || goto :ko
verify >nul
goto :eof

:ok
exit /b 0

:ko
exit /b 5

@echo off
setlocal

set VERSION=%1
set VERSTATUS=%2
if [%VERSION%] == [] set VERSION=0.0.0
echo publishing version '%VERSION%' with status '%VERSTATUS%'

set HERE=%~dp0

call :dopublish || goto :ko
goto :ok

:dopublish
%HERE%\src\fullbuild\bin\fullbuild publish * || goto :ko
robocopy %HERE%\apps\full-build %HERE%\refbin /MIR

set NUGETVERSION=%VERSION%%VERSTATUS%
nuget pack -NoDefaultExcludes -NoPackageAnalysis -NonInteractive -OutputDirectory apps -Version %NUGETVERSION% full-build.nuspec || goto :ko
move apps\full-build.%NUGETVERSION%.nupkg apps\full-build.nupkg || goto :ko
verify >nul
goto :eof

:ok
exit /b 0

:ko
exit /b 5

add logs

add logs


@echo off
"C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Bin\msbuild.exe" "src/Skybrud.Umbraco.GridData" /t:rebuild /t:pack /p:BuildTools=1 /p:Configuration=Release /p:PackageOutputPath=../../releases/nuget

@echo off
dotnet build src/Skybrud.Umbraco.GridData --configuration Release /t:rebuild /t:pack -p:BuildTools=1 -p:PackageOutputPath=../../releases/nuget

Build stuff

Build stuff


echo Building installer...

echo Building Release shieldbattery binaries...
call "%~dp0\vcbuild.bat"
if errorlevel 1 goto binary-build-failed
echo "Done!"

echo Bundling JS and building update manifest...
cd "%~dp0\bundler"
cmd.exe /c npm start
cd "%~dp0"

echo Building Release Installer...
if not defined VS140COMNTOOLS goto msbuild-not-found
if not exist "%VS140COMNTOOLS%\..\..\vc\vcvarsall.bat" goto msbuild-not-found
echo Found Visual Studio 2015
if "%VCVARS_VER%" NEQ "140" (
  call "%VS140COMNTOOLS%\..\..\vc\vcvarsall.bat"
  SET VCVARS_VER=140
)
if not defined VCINSTALLDIR goto msbuild-not-found

msbuild installer\installer.sln /m /t:Build /p:Configuration=Release /clp:NoSummary;NoItemAndPropertyList;Verbosity=minimal /nologo
if errorlevel 1 goto installer-build-failed
echo Done!
goto exit

:msbuild-not-found
echo Build skipped. To build, this file needs to run from VS cmd prompt.
goto exit

:binary-build-failed
echo Building the binaries failed.
goto exit

:installer-build-failed
echo Building the installer failed.
goto exit

:exit
cd "%~dp0"
goto :EOF

echo Building installer...

echo Building Release shieldbattery binaries...
call "%~dp0\vcbuild.bat" %*
if errorlevel 1 goto binary-build-failed
echo "Done!"

echo Bundling JS and building update manifest...
cd "%~dp0\bundler"
cmd.exe /c npm start
cd "%~dp0"

echo Building Release Installer...
if not defined VS140COMNTOOLS goto msbuild-not-found
if not exist "%VS140COMNTOOLS%\..\..\vc\vcvarsall.bat" goto msbuild-not-found
echo Found Visual Studio 2015
if "%VCVARS_VER%" NEQ "140" (
  call "%VS140COMNTOOLS%\..\..\vc\vcvarsall.bat"
  SET VCVARS_VER=140
)
if not defined VCINSTALLDIR goto msbuild-not-found

msbuild installer\installer.sln /m /t:Build /p:Configuration=Release /clp:NoSummary;NoItemAndPropertyList;Verbosity=minimal /nologo
if errorlevel 1 goto installer-build-failed
echo Done!
goto exit

:msbuild-not-found
echo Build skipped. To build, this file needs to run from VS cmd prompt.
goto exit

:binary-build-failed
echo Building the binaries failed.
goto exit

:installer-build-failed
echo Building the installer failed.
goto exit

:exit
cd "%~dp0"
goto :EOF

Allow for passing arguments to vcbuild from build-installer (e.g. nobuild when you know you don't need to rebuild binaries).


@echo off
setlocal enabledelayedexpansion
::
:: Copyright (c) 2017, HarpyWar (harpywar@gmail.com)
::
@call module\config.inc.bat

echo.
echo ###############################################################################
echo #                    PvPGN Visual Studio Solution Builder                     #
echo # --------------------------------------------------------------------------- #
call %i18n% 10_0_0
call %i18n% 10_0_1
echo # --------------------------------------------------------------------------- #
echo ###############################################################################
echo.

:: redefine %PVPGN_BUILD% without a slash
set PVPGN_BUILD=build

if not exist %PVPGN_BUILD%\pvpgn.sln (
	call %i18n% 10_1
	goto :THEEND
)

call %i18n% 10_2 "%PVPGN_DEVKIT%"
choice
echo.
echo --------------------------------------------------------------------------------

if %errorlevel%==2 goto :THEEND

if not exist %PVPGN_DEVKIT% mkdir %PVPGN_DEVKIT%

:: copy config.h
copy /Y "%PVPGN_BUILD%\config.h" "%PVPGN_DEVKIT%\"

:: copy pvpgn.sln
copy /Y "%PVPGN_BUILD%\pvpgn.sln" "%PVPGN_DEVKIT%\"

:: build each project
call :build_project bnetd bnetd
call :build_project bnpass bnpass
call :build_project bnpass sha1hash
call :build_project bntrackd bntrackd
call :build_project bniutils bni2tga
call :build_project bniutils bnibuild
call :build_project bniutils bniextract
call :build_project bniutils bnilist
call :build_project bniutils tgainfo
call :build_project common common
call :build_project compat compat
call :build_project client bnbot
call :build_project client bnchat
call :build_project client bnftp
call :build_project client bnstat
call :build_project d2cs d2cs
call :build_project d2dbs d2dbs
call :build_project test bigint
call :build_project test bnetsrp3_test
call :build_project test bigint
call :build_project test bigint
call :build_project win32 win32

:: remove unused projects generated by cmake
call :remove_sln_project "%PVPGN_DEVKIT%pvpgn.sln" ALL_BUILD
call :remove_sln_project "%PVPGN_DEVKIT%pvpgn.sln" RUN_TESTS
call :remove_sln_project "%PVPGN_DEVKIT%pvpgn.sln" INSTALL
call :remove_sln_project "%PVPGN_DEVKIT%pvpgn.sln" purge
call :remove_sln_project "%PVPGN_DEVKIT%pvpgn.sln" uninstall

:: create shortcut on pvpgn.sln
call :create_shortcut "%CURRENT_PATH%%PVPGN_DEVKIT%pvpgn.sln" "%CURRENT_PATH%pvpgn.sln.lnk"

echo.
echo --------------------------------------------------------------------------------
call %i18n% 10_3 "%PVPGN_DEVKIT%"
call %i18n% 10_4 pvpgn.sln "%PVPGN_DEVKIT%pvpgn.sln"
call %i18n% 10_5 "release\"
echo --------------------------------------------------------------------------------

goto :THEEND

:build_project <path> <name>
	if not exist "%PVPGN_DEVKIT%projects\%2" mkdir "%PVPGN_DEVKIT%projects\%2"
	copy /Y "%PVPGN_BUILD%\src\%1\%2.vcxproj*" "%PVPGN_DEVKIT%projects\%2"

	call :create_vcxproj_user "%PVPGN_DEVKIT%projects\%2\%2.vcxproj.user"

	rem replace paths

	:: set atlmfc and release into additional include dir section
	@call %TOOLS_PATH%replacer.bat "%PVPGN_DEVKIT%projects\%2\%2.vcxproj" "%CURRENT_PATH%%PVPGN_BUILD%;%CURRENT_PATH%source\src;" "..\..\;%PROJECT_ROOT_DIR%source\src;%PROJECT_ROOT_DIR%release;%PROJECT_ROOT_DIR%module\include\atlmfc;"
	:: replace source path
	@call %TOOLS_PATH%replacer.bat "%PVPGN_DEVKIT%projects\%2\%2.vcxproj" "%CURRENT_PATH%source" "%PROJECT_ROOT_DIR%source"
	@call %TOOLS_PATH%replacer.bat "%PVPGN_DEVKIT%projects\%2\%2.vcxproj.filters" "%CURRENT_PATH%source" "%PROJECT_ROOT_DIR%source"
	:: replace release and debug paths
	@call %TOOLS_PATH%replacer.bat "%PVPGN_DEVKIT%projects\%2\%2.vcxproj" "%CURRENT_PATH%%PVPGN_BUILD%\src\%1\Debug" "%PROJECT_ROOT_DIR%release"
	@call %TOOLS_PATH%replacer.bat "%PVPGN_DEVKIT%projects\%2\%2.vcxproj" "%CURRENT_PATH%%PVPGN_BUILD%\src\%1\Release" "%PROJECT_ROOT_DIR%release"
	:: replace unix like build path
	@call %TOOLS_PATH%replacer.bat "%PVPGN_DEVKIT%projects\%2\%2.vcxproj" "%CURRENT_PATH_BACKSLASH%%PVPGN_BUILD%/src/%1" "../%2"
	:: replace path for magic builder module
	@call %TOOLS_PATH%replacer.bat "%PVPGN_DEVKIT%projects\%2\%2.vcxproj" "%CURRENT_PATH%module" "%PROJECT_ROOT_DIR%module"
	:: replace new path in pvpgn.sln
	@call %TOOLS_PATH%replacer.bat "%PVPGN_DEVKIT%pvpgn.sln" "src\%1\%2" "projects\%2\%2"

	:: libs now build into release
	@call %TOOLS_PATH%replacer.bat "%PVPGN_DEVKIT%projects\%2\%2.vcxproj" "..\common\Debug\common.lib" "%PROJECT_ROOT_DIR%release\common.lib"
	@call %TOOLS_PATH%replacer.bat "%PVPGN_DEVKIT%projects\%2\%2.vcxproj" "..\compat\Debug\compat.lib" "%PROJECT_ROOT_DIR%release\compat.lib"
	@call %TOOLS_PATH%replacer.bat "%PVPGN_DEVKIT%projects\%2\%2.vcxproj" "..\tinycdb\Debug\tinycdb.lib" "%PROJECT_ROOT_DIR%release\tinycdb.lib"
	@call %TOOLS_PATH%replacer.bat "%PVPGN_DEVKIT%projects\%2\%2.vcxproj" "..\win32\Debug\win32.lib" "%PROJECT_ROOT_DIR%release\win32.lib"
	:: this replacement only for bncdb project
	@call %TOOLS_PATH%replacer.bat "%PVPGN_DEVKIT%projects\%2\%2.vcxproj" "Debug\tinycdb.lib" "%PROJECT_ROOT_DIR%release\tinycdb.lib"
	@call %TOOLS_PATH%replacer.bat "%PVPGN_DEVKIT%projects\%2\%2.vcxproj" "Release\tinycdb.lib" "%PROJECT_ROOT_DIR%release\tinycdb.lib"

	:: remove reduntant cmake node that executes cmake.exe on each build
	call :remove_xml_node "%PVPGN_DEVKIT%projects\%2\%2.vcxproj" Project/ItemGroup/CustomBuild

	exit /b 0

:create_vcxproj_user <filename>

	echo ^<?xml version="1.0" encoding="utf-8"?^> > %1
	echo ^<Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"^> >> %1
	echo   ^<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"^> >> %1
	echo 	^<LocalDebuggerWorkingDirectory^>%PROJECT_ROOT_DIR%release^</LocalDebuggerWorkingDirectory^> >> %1
	echo 	^<DebuggerFlavor^>WindowsLocalDebugger^</DebuggerFlavor^> >> %1
	echo   ^</PropertyGroup^> >> %1
	echo   ^<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"^> >> %1
	echo 	^<LocalDebuggerWorkingDirectory^>%PROJECT_ROOT_DIR%release^</LocalDebuggerWorkingDirectory^> >> %1
	echo 	^<DebuggerFlavor^>WindowsLocalDebugger^</DebuggerFlavor^> >> %1
	echo   ^</PropertyGroup^> >> %1
	echo ^</Project^> >> %1

	exit /b 0

:create_shortcut <source> <destination>
	set SCRIPT="%TEMP%\%RANDOM%-%RANDOM%-%RANDOM%-%RANDOM%.vbs"
	echo Set oWS = WScript.CreateObject("WScript.Shell") >> %SCRIPT%
	echo sLinkFile = %2 >> %SCRIPT%
	echo Set oLink = oWS.CreateShortcut(sLinkFile) >> %SCRIPT%
	echo oLink.TargetPath = %1 >> %SCRIPT%
	echo oLink.Save >> %SCRIPT%

	cscript /nologo %SCRIPT%
	del %SCRIPT%

	exit /b 0

:: removes given xml node from xml file
:remove_xml_node "<filename.vcxproj>" nodeName
	set SCRIPT="%TEMP%\%RANDOM%-%RANDOM%-%RANDOM%-%RANDOM%.vbs"
	echo Set objXMLDoc = Wscript.CreateObject("Microsoft.XMLDOM") >> %SCRIPT%
	echo objXMLDoc.async = False >> %SCRIPT%
	echo Dim XMLFile >> %SCRIPT%
	echo XMLFile = %1 >> %SCRIPT%
	echo objXMLDoc.load(XMLFile)  >> %SCRIPT%
	echo Set nodes = objXMLDoc.selectNodes("%2") >> %SCRIPT%
	echo For Each node In nodes >> %SCRIPT%
	echo   node.parentNode.removeChild(node) >> %SCRIPT%
	echo Next >> %SCRIPT%
	echo objXMLDoc.Save(XMLFile) >> %SCRIPT%

	cscript /nologo %SCRIPT%
	del %SCRIPT%

	exit /b 0

:: removes a project block from vs solution file
:remove_sln_project "<filename.sln>" <projectName>
	set SCRIPT="%TEMP%\%RANDOM%-%RANDOM%-%RANDOM%-%RANDOM%.vbs"

	echo Dim newText >> %SCRIPT%
	echo Dim inProject >> %SCRIPT%
	echo Dim isBadProject >> %SCRIPT%
	echo Dim line >> %SCRIPT%

	echo Set fso = CreateObject("Scripting.FileSystemObject") >> %SCRIPT%
	echo Set f = fso.OpenTextFile(%1, 1) >> %SCRIPT%

	echo Do Until f.AtEndOfStream >> %SCRIPT%
	echo 	line = f.ReadLine >> %SCRIPT%
	echo 	If InStr(1, line, "Project(") = 1 Then ' if line starts with Project( >> %SCRIPT%
	echo 		inProject = true >> %SCRIPT%
	echo 		If InStr(1, line, "%2") > 0 Then ' if line contains a given project name >> %SCRIPT%
	echo 			isBadProject = true >> %SCRIPT%
	echo 		Else >> %SCRIPT%
	echo 			isBadProject = false >> %SCRIPT%
	echo 		End If >> %SCRIPT%
	echo 	End If >> %SCRIPT%

	echo 	If Not isBadProject Or Not inProject Then  >> %SCRIPT%
	echo 		newText = newText + line ^& vbCrLf >> %SCRIPT%
	echo 	End If >> %SCRIPT%

	echo 	If line = "EndProject" Then ' if line equal EndProject >> %SCRIPT%
	echo 		inProject = false >> %SCRIPT%
	echo 	End If >> %SCRIPT%
	echo Loop >> %SCRIPT%
	echo f.Close >> %SCRIPT%

	echo Set objFile = fso.CreateTextFile(%1, True) >> %SCRIPT%
	echo objFile.Write newText >> %SCRIPT%
	echo objFile.Close >> %SCRIPT%

	cscript /nologo %SCRIPT%
	del %SCRIPT%

	exit /b 0

:THEEND
pause

@echo off
setlocal enabledelayedexpansion
::
:: Copyright (c) 2017, HarpyWar (harpywar@gmail.com)
::
@call module\config.inc.bat

echo.
echo ###############################################################################
echo #                    PvPGN Visual Studio Solution Builder                     #
echo # --------------------------------------------------------------------------- #
call %i18n% 10_0_0
call %i18n% 10_0_1
echo # --------------------------------------------------------------------------- #
echo ###############################################################################
echo.

:: redefine %PVPGN_BUILD% without a slash
set PVPGN_BUILD=build

if not exist %PVPGN_BUILD%\pvpgn.sln (
	call %i18n% 10_1
	goto :THEEND
)

call %i18n% 10_2 "%PVPGN_DEVKIT%"
choice
echo.
echo --------------------------------------------------------------------------------

if %errorlevel%==2 goto :THEEND

if not exist %PVPGN_DEVKIT% mkdir %PVPGN_DEVKIT%

:: copy config.h
copy /Y "%PVPGN_BUILD%\config.h" "%PVPGN_DEVKIT%\"

:: copy pvpgn.sln
copy /Y "%PVPGN_BUILD%\pvpgn.sln" "%PVPGN_DEVKIT%\"

:: build each project
call :build_project bnetd bnetd
call :build_project bnpass bnpass
call :build_project bnpass sha1hash
call :build_project bntrackd bntrackd
call :build_project bniutils bni2tga
call :build_project bniutils bnibuild
call :build_project bniutils bniextract
call :build_project bniutils bnilist
call :build_project bniutils tgainfo
call :build_project common common
call :build_project compat compat
call :build_project client bnbot
call :build_project client bnchat
call :build_project client bnftp
call :build_project client bnstat
call :build_project d2cs d2cs
call :build_project d2dbs d2dbs
call :build_project win32 win32

:: remove unused projects generated by cmake
call :remove_sln_project "%PVPGN_DEVKIT%pvpgn.sln" ALL_BUILD
call :remove_sln_project "%PVPGN_DEVKIT%pvpgn.sln" RUN_TESTS
call :remove_sln_project "%PVPGN_DEVKIT%pvpgn.sln" INSTALL
call :remove_sln_project "%PVPGN_DEVKIT%pvpgn.sln" purge
call :remove_sln_project "%PVPGN_DEVKIT%pvpgn.sln" uninstall

:: create shortcut on pvpgn.sln
call :create_shortcut "%CURRENT_PATH%%PVPGN_DEVKIT%pvpgn.sln" "%CURRENT_PATH%pvpgn.sln.lnk"

echo.
echo --------------------------------------------------------------------------------
call %i18n% 10_3 "%PVPGN_DEVKIT%"
call %i18n% 10_4 pvpgn.sln "%PVPGN_DEVKIT%pvpgn.sln"
call %i18n% 10_5 "release\"
echo --------------------------------------------------------------------------------

goto :THEEND

:build_project <path> <name>
	if not exist "%PVPGN_DEVKIT%projects\%2" mkdir "%PVPGN_DEVKIT%projects\%2"
	copy /Y "%PVPGN_BUILD%\src\%1\%2.vcxproj*" "%PVPGN_DEVKIT%projects\%2"

	call :create_vcxproj_user "%PVPGN_DEVKIT%projects\%2\%2.vcxproj.user"

	rem replace paths

	:: set atlmfc and release into additional include dir section
	@call %TOOLS_PATH%replacer.bat "%PVPGN_DEVKIT%projects\%2\%2.vcxproj" "%CURRENT_PATH%%PVPGN_BUILD%;%CURRENT_PATH%source\src;" "..\..\;%PROJECT_ROOT_DIR%source\src;%PROJECT_ROOT_DIR%release;%PROJECT_ROOT_DIR%module\include\atlmfc;"
	:: replace source path
	@call %TOOLS_PATH%replacer.bat "%PVPGN_DEVKIT%projects\%2\%2.vcxproj" "%CURRENT_PATH%source" "%PROJECT_ROOT_DIR%source"
	@call %TOOLS_PATH%replacer.bat "%PVPGN_DEVKIT%projects\%2\%2.vcxproj.filters" "%CURRENT_PATH%source" "%PROJECT_ROOT_DIR%source"
	:: replace release and debug paths
	@call %TOOLS_PATH%replacer.bat "%PVPGN_DEVKIT%projects\%2\%2.vcxproj" "%CURRENT_PATH%%PVPGN_BUILD%\src\%1\Debug" "%PROJECT_ROOT_DIR%release"
	@call %TOOLS_PATH%replacer.bat "%PVPGN_DEVKIT%projects\%2\%2.vcxproj" "%CURRENT_PATH%%PVPGN_BUILD%\src\%1\Release" "%PROJECT_ROOT_DIR%release"
	:: replace unix like build path
	@call %TOOLS_PATH%replacer.bat "%PVPGN_DEVKIT%projects\%2\%2.vcxproj" "%CURRENT_PATH_BACKSLASH%%PVPGN_BUILD%/src/%1" "../%2"
	:: replace path for magic builder module
	@call %TOOLS_PATH%replacer.bat "%PVPGN_DEVKIT%projects\%2\%2.vcxproj" "%CURRENT_PATH%module" "%PROJECT_ROOT_DIR%module"
	:: replace new path in pvpgn.sln
	@call %TOOLS_PATH%replacer.bat "%PVPGN_DEVKIT%pvpgn.sln" "src\%1\%2" "projects\%2\%2"

	:: libs now build into release
	@call %TOOLS_PATH%replacer.bat "%PVPGN_DEVKIT%projects\%2\%2.vcxproj" "..\common\Debug\common.lib" "%PROJECT_ROOT_DIR%release\common.lib"
	@call %TOOLS_PATH%replacer.bat "%PVPGN_DEVKIT%projects\%2\%2.vcxproj" "..\compat\Debug\compat.lib" "%PROJECT_ROOT_DIR%release\compat.lib"
	@call %TOOLS_PATH%replacer.bat "%PVPGN_DEVKIT%projects\%2\%2.vcxproj" "..\tinycdb\Debug\tinycdb.lib" "%PROJECT_ROOT_DIR%release\tinycdb.lib"
	@call %TOOLS_PATH%replacer.bat "%PVPGN_DEVKIT%projects\%2\%2.vcxproj" "..\win32\Debug\win32.lib" "%PROJECT_ROOT_DIR%release\win32.lib"
	:: this replacement only for bncdb project
	@call %TOOLS_PATH%replacer.bat "%PVPGN_DEVKIT%projects\%2\%2.vcxproj" "Debug\tinycdb.lib" "%PROJECT_ROOT_DIR%release\tinycdb.lib"
	@call %TOOLS_PATH%replacer.bat "%PVPGN_DEVKIT%projects\%2\%2.vcxproj" "Release\tinycdb.lib" "%PROJECT_ROOT_DIR%release\tinycdb.lib"

	:: remove reduntant cmake node that executes cmake.exe on each build
	call :remove_xml_node "%PVPGN_DEVKIT%projects\%2\%2.vcxproj" Project/ItemGroup/CustomBuild

	exit /b 0

:create_vcxproj_user <filename>

	echo ^<?xml version="1.0" encoding="utf-8"?^> > %1
	echo ^<Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"^> >> %1
	echo   ^<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"^> >> %1
	echo 	^<LocalDebuggerWorkingDirectory^>%PROJECT_ROOT_DIR%release^</LocalDebuggerWorkingDirectory^> >> %1
	echo 	^<DebuggerFlavor^>WindowsLocalDebugger^</DebuggerFlavor^> >> %1
	echo   ^</PropertyGroup^> >> %1
	echo   ^<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"^> >> %1
	echo 	^<LocalDebuggerWorkingDirectory^>%PROJECT_ROOT_DIR%release^</LocalDebuggerWorkingDirectory^> >> %1
	echo 	^<DebuggerFlavor^>WindowsLocalDebugger^</DebuggerFlavor^> >> %1
	echo   ^</PropertyGroup^> >> %1
	echo ^</Project^> >> %1

	exit /b 0

:create_shortcut <source> <destination>
	set SCRIPT="%TEMP%\%RANDOM%-%RANDOM%-%RANDOM%-%RANDOM%.vbs"
	echo Set oWS = WScript.CreateObject("WScript.Shell") >> %SCRIPT%
	echo sLinkFile = %2 >> %SCRIPT%
	echo Set oLink = oWS.CreateShortcut(sLinkFile) >> %SCRIPT%
	echo oLink.TargetPath = %1 >> %SCRIPT%
	echo oLink.Save >> %SCRIPT%

	cscript /nologo %SCRIPT%
	del %SCRIPT%

	exit /b 0

:: removes given xml node from xml file
:remove_xml_node "<filename.vcxproj>" nodeName
	set SCRIPT="%TEMP%\%RANDOM%-%RANDOM%-%RANDOM%-%RANDOM%.vbs"
	echo Set objXMLDoc = Wscript.CreateObject("Microsoft.XMLDOM") >> %SCRIPT%
	echo objXMLDoc.async = False >> %SCRIPT%
	echo Dim XMLFile >> %SCRIPT%
	echo XMLFile = %1 >> %SCRIPT%
	echo objXMLDoc.load(XMLFile)  >> %SCRIPT%
	echo Set nodes = objXMLDoc.selectNodes("%2") >> %SCRIPT%
	echo For Each node In nodes >> %SCRIPT%
	echo   node.parentNode.removeChild(node) >> %SCRIPT%
	echo Next >> %SCRIPT%
	echo objXMLDoc.Save(XMLFile) >> %SCRIPT%

	cscript /nologo %SCRIPT%
	del %SCRIPT%

	exit /b 0

:: removes a project block from vs solution file
:remove_sln_project "<filename.sln>" <projectName>
	set SCRIPT="%TEMP%\%RANDOM%-%RANDOM%-%RANDOM%-%RANDOM%.vbs"

	echo Dim newText >> %SCRIPT%
	echo Dim inProject >> %SCRIPT%
	echo Dim isBadProject >> %SCRIPT%
	echo Dim line >> %SCRIPT%

	echo Set fso = CreateObject("Scripting.FileSystemObject") >> %SCRIPT%
	echo Set f = fso.OpenTextFile(%1, 1) >> %SCRIPT%

	echo Do Until f.AtEndOfStream >> %SCRIPT%
	echo 	line = f.ReadLine >> %SCRIPT%
	echo 	If InStr(1, line, "Project(") = 1 Then ' if line starts with Project( >> %SCRIPT%
	echo 		inProject = true >> %SCRIPT%
	echo 		If InStr(1, line, "%2") > 0 Then ' if line contains a given project name >> %SCRIPT%
	echo 			isBadProject = true >> %SCRIPT%
	echo 		Else >> %SCRIPT%
	echo 			isBadProject = false >> %SCRIPT%
	echo 		End If >> %SCRIPT%
	echo 	End If >> %SCRIPT%

	echo 	If Not isBadProject Or Not inProject Then  >> %SCRIPT%
	echo 		newText = newText + line ^& vbCrLf >> %SCRIPT%
	echo 	End If >> %SCRIPT%

	echo 	If line = "EndProject" Then ' if line equal EndProject >> %SCRIPT%
	echo 		inProject = false >> %SCRIPT%
	echo 	End If >> %SCRIPT%
	echo Loop >> %SCRIPT%
	echo f.Close >> %SCRIPT%

	echo Set objFile = fso.CreateTextFile(%1, True) >> %SCRIPT%
	echo objFile.Write newText >> %SCRIPT%
	echo objFile.Close >> %SCRIPT%

	cscript /nologo %SCRIPT%
	del %SCRIPT%

	exit /b 0

:THEEND
pause

delete test projects

delete test projects


@echo off
REM BL-MCP version 1.3.1
REM @author acomputerdog 2-14-14
REM TODO:
REM * get blazeloader sources that are not the newest dev version.
REM * get libraries without hardcoding them
if not exist "%cd%/BlazeLoader/instlflg" (
    setlocal EnableDelayedExpansion
    echo --- MCP and BL setup script ---
    echo Please select an install type:
    echo 1 - Cancel install
    echo 2 - Setup MCP for developing BlazeLoader itself
    echo 3 - Setup MCP for developing BlazeLoader mods
    choice /C 123
    echo.
    if errorlevel 3 (
        echo Setting up MCP to develop BlazeLoader mods.
        echo Unmodified BlazeLoader sources will be excluded from getChangedSrc and reobfuscate scripts.
        set setupmode=mod
    ) else if errorlevel 2 (
        echo Setting up MCP to develop BlazeLoader itself.
        echo Unmodified BlazeLoader sources will be included with getChangedSrc and reobfuscate scripts.
        set setupmode=bl
    ) else (
        echo MCP setup canceled.
        pause
        exit /b -1
    )
    if not exist "%cd%/temp/setup" mkdir "%cd%\temp\setup\"
    echo.
    echo Extracting downloader script...
REM begin embedded VBScript file
    echo strURL = WScript.Arguments.Item(0^)>"%cd%/temp/setup/bl_downloader.vbs"
    echo strPath = WScript.Arguments.Item(1^)>>"%cd%/temp/setup/bl_downloader.vbs"
    echo dim xHttp: Set xHttp = createobject("MSXML2.ServerXMLHTTP.6.0"^)>>"%cd%/temp/setup/bl_downloader.vbs"
    echo dim bStrm: Set bStrm = createobject("Adodb.Stream"^)>>"%cd%/temp/setup/bl_downloader.vbs"
    echo xHttp.Open "GET", strURL, False>>"%cd%/temp/setup/bl_downloader.vbs"
    echo xHttp.Send>>"%cd%/temp/setup/bl_downloader.vbs"
    echo with bStrm>>"%cd%/temp/setup/bl_downloader.vbs"
    echo     .type = 1 1>>"%cd%/temp/setup/bl_downloader.vbs"
    echo     .open>>"%cd%/temp/setup/bl_downloader.vbs"
    echo     .write xHttp.responseBody>>"%cd%/temp/setup/bl_downloader.vbs"
    echo     .savetofile strPath, 2 1>>"%cd%/temp/setup/bl_downloader.vbs"
    echo end with>>"%cd%/temp/setup/bl_downloader.vbs"
    echo WScript.Quit>>"%cd%/temp/setup/bl_downloader.vbs"
REM end embedded VBScript file
    if exist "%cd%/temp/setup/bl_downloader.vbs" (
        echo Done.
    ) else (
        echo Unable to extract downloader script, aborting install!
        pause
        exit /b 3
    )
    echo.
    echo Downloading BlazeLoader from "http://github.com/warriordog/BlazeLoader/archive/master.zip"...
    cscript.exe //B "%cd%/temp/setup/bl_downloader.vbs" http://github.com/warriordog/BlazeLoader/archive/master.zip "%cd%/temp/setup/BlazeLoader_repo.zip"
    echo Done.
    echo.
    echo Downloading 7-Zip from "http://www.acomputerdog.net/BL_STORE/7-zip_package.exe"...
    cscript.exe //B "%cd%/temp/setup/bl_downloader.vbs" http://www.acomputerdog.net/BL_STORE/7-zip_package.exe "%cd%/temp/setup/7-zip_package.exe"
    echo Done.
    echo.
    echo Extracting 7-Zip...
    "%cd%/temp/setup/7-zip_package.exe" /q:a /t:"%cd%\temp\setup\7-zip\" /c /r:n
    if exist "%cd%/temp/setup/7-zip/7z.exe" (
        echo Done.
    ) else (
        echo 7-zip was not extracted! (you may need to disable your antivirus if the self-extracting archive was blocked^)
        echo Unable to extract BlazeLoader, aborting install!
        pause
        exit /b 1
    )
    echo.
    echo Extracting BlazeLoader...
    "%cd%/temp/setup/7-zip/7z.exe" e -o"%cd%/BlazeLoader/" -y "%cd%/temp/setup/BlazeLoader_repo.zip" mcp.ver
    "%cd%/temp/setup/7-zip/7z.exe" x -o"%cd%/temp/setup/" -y "%cd%/temp/setup/BlazeLoader_repo.zip"
    xcopy /I /Y /E /C /Q "%cd%\temp\setup\BlazeLoader-master\*" "%cd%\BlazeLoader"
    rmdir /S /Q "%cd%\temp\setup\BlazeLoader-master"
    echo Done.
    set /p mcpver=<"%cd%/BlazeLoader/version/mcp.ver"
    if not exist "%cd%/temp/setup/mcp!mcpver!.zip" (
        echo.
        echo Downloading MCP...
        cscript.exe //B "%cd%/temp/setup/bl_downloader.vbs" http://mcp.ocean-labs.de/files/archive/mcp%mcpver%.zip "%cd%/temp/setup/mcp!mcpver!.zip"
        echo Done.
    ) else (
        echo MCP already downloaded; skipping download.
    )
    echo.
    echo Extracting MCP...
    "%cd%/temp/setup/7-zip/7z.exe" x -bd -ba -o"%cd%" -y "%cd%/temp/setup/mcp!mcpver!.zip"
    if exist "%cd%/decompile.bat" (
        echo Done.
    ) else (
        echo MCP version !mcpver! was not found, provide it manually to %cd%/temp/setup/mcp!mcpver!.zip!  Aborting install!
        pause
        exit /b 2
    )
    echo.
    REM TODO: find a way to do this without hardcoding anything.  Maybe reuse Libaries.txt, or write a batch JSON parser(If I go insane)?
    echo Downloading and copying libraries...
    if not exist "%cd%/lib/" mkdir "%cd%/lib/"
    cscript.exe //B "%cd%/temp/setup/bl_downloader.vbs" "http://repo1.maven.org/maven2/org/ow2/asm/asm-debug-all/4.1/asm-debug-all-4.1.jar" "%cd%/lib/asm-debug-all-4.1.jar"
    xcopy /Y "%appdata%\.minecraft\libraries\net\minecraft\launchwrapper\1.9\*.jar" "%cd%\lib\"
    echo Done.
    echo.
    echo Applying AccessTransformer...
    if not exist "%cd%/jars/libraries/org/ow2/asm/asm-debug-all/4.1/" mkdir "%cd%/jars/libraries/org/ow2/asm/asm-debug-all/4.1/"
    xcopy /I /Y "%cd%\lib\asm-debug-all-4.1.jar" "%cd%\jars\libraries\org\ow2\asm\asm-debug-all\4.1\"
    "%cd%/BlazeLoader/apply_at.bat"
    echo Done.
    echo.
    echo Decompiling...
    "%cd%/runtime/bin/python/python_mcp.exe" "%cd%/runtime/decompile.py"
    echo Done.
    echo.
    echo Copying BlazeLoader sources...
    xcopy /I /Y /E /C /Q "%cd%\BlazeLoader\source\core\*" "%cd%\src\minecraft\"
    xcopy /I /Y /E /C /Q "%cd%\BlazeLoader\source\vanilla\*" "%cd%\src\minecraft\"
    echo Done.
    echo.
    if "!setupmode!" == "bl" (
        echo Recompiling...
        "%cd%/runtime/bin/python/python_mcp.exe" "%cd%/runtime/recompile.py"
    ) else (
        echo Updating MD5s...
        echo yes|"%cd%/runtime/bin/python/python_mcp.exe" "%cd%/runtime/updatemd5.py"
    )
    echo Done.
    echo.
    echo %date%-%time%>"%cd%/BlazeLoader/instlflg"
    echo MCP setup complete!
    echo.
	pause
) else (
    echo MCP has already been set up!
    pause
    exit /b -2
)

@echo off
REM BL-MCP version 1.4
REM @author acomputerdog 4-8-14
REM TODO:
REM * get blazeloader sources that are not the newest dev version.
REM * get libraries without hardcoding them
if not exist "%cd%/BlazeLoader/instlflg" (
    setlocal EnableDelayedExpansion
    echo --- MCP and BL setup script ---
    echo Please select an install type:
    echo 1 - Cancel install
    echo 2 - Setup MCP for developing BlazeLoader itself
    echo 3 - Setup MCP for developing BlazeLoader mods
    choice /C 123
    echo.
    if errorlevel 3 (
        echo Setting up MCP to develop BlazeLoader mods.
        echo Unmodified BlazeLoader sources will be excluded from getChangedSrc and reobfuscate scripts.
        set setupmode=mod
    ) else if errorlevel 2 (
        echo Setting up MCP to develop BlazeLoader itself.
        echo Unmodified BlazeLoader sources will be included with getChangedSrc and reobfuscate scripts.
        set setupmode=bl
    ) else (
        echo MCP setup canceled.
        pause
        exit /b -1
    )
    if not exist "%cd%/temp/setup" mkdir "%cd%\temp\setup\"
    echo.
    echo Extracting downloader script...
REM begin embedded VBScript file
    echo strURL = WScript.Arguments.Item(0^)>"%cd%/temp/setup/bl_downloader.vbs"
    echo strPath = WScript.Arguments.Item(1^)>>"%cd%/temp/setup/bl_downloader.vbs"
    echo dim xHttp: Set xHttp = createobject("MSXML2.ServerXMLHTTP.6.0"^)>>"%cd%/temp/setup/bl_downloader.vbs"
    echo dim bStrm: Set bStrm = createobject("Adodb.Stream"^)>>"%cd%/temp/setup/bl_downloader.vbs"
    echo xHttp.Open "GET", strURL, False>>"%cd%/temp/setup/bl_downloader.vbs"
    echo xHttp.Send>>"%cd%/temp/setup/bl_downloader.vbs"
    echo with bStrm>>"%cd%/temp/setup/bl_downloader.vbs"
    echo     .type = 1 1>>"%cd%/temp/setup/bl_downloader.vbs"
    echo     .open>>"%cd%/temp/setup/bl_downloader.vbs"
    echo     .write xHttp.responseBody>>"%cd%/temp/setup/bl_downloader.vbs"
    echo     .savetofile strPath, 2 1>>"%cd%/temp/setup/bl_downloader.vbs"
    echo end with>>"%cd%/temp/setup/bl_downloader.vbs"
    echo WScript.Quit>>"%cd%/temp/setup/bl_downloader.vbs"
REM end embedded VBScript file
    if exist "%cd%/temp/setup/bl_downloader.vbs" (
        echo Done.
    ) else (
        echo Unable to extract downloader script, aborting install!
        pause
        exit /b 3
    )
    echo.
    echo Downloading BlazeLoader from "http://github.com/warriordog/BlazeLoader/archive/master.zip"...
    cscript.exe //B "%cd%/temp/setup/bl_downloader.vbs" http://github.com/warriordog/BlazeLoader/archive/master.zip "%cd%/temp/setup/BlazeLoader_repo.zip"
    echo Done.
    echo.
    echo Downloading 7-Zip from "http://www.acomputerdog.net/BL_STORE/7-zip_package.exe"...
    cscript.exe //B "%cd%/temp/setup/bl_downloader.vbs" http://www.acomputerdog.net/BL_STORE/7-zip_package.exe "%cd%/temp/setup/7-zip_package.exe"
    echo Done.
    echo.
    echo Extracting 7-Zip...
    "%cd%/temp/setup/7-zip_package.exe" /q:a /t:"%cd%\temp\setup\7-zip\" /c /r:n
    if exist "%cd%/temp/setup/7-zip/7z.exe" (
        echo Done.
    ) else (
        echo 7-zip was not extracted! (you may need to disable your antivirus if the self-extracting archive was blocked^)
        echo Unable to extract BlazeLoader, aborting install!
        pause
        exit /b 1
    )
    echo.
    echo Extracting BlazeLoader...
    "%cd%/temp/setup/7-zip/7z.exe" e -o"%cd%/BlazeLoader/" -y "%cd%/temp/setup/BlazeLoader_repo.zip" mcp.ver
    "%cd%/temp/setup/7-zip/7z.exe" x -o"%cd%/temp/setup/" -y "%cd%/temp/setup/BlazeLoader_repo.zip"
    xcopy /I /Y /E /C /Q "%cd%\temp\setup\BlazeLoader-master\*" "%cd%\BlazeLoader"
    rmdir /S /Q "%cd%\temp\setup\BlazeLoader-master"
    echo Done.
    echo.
    set /p mcpver=<"%cd%/BlazeLoader/version/mcp.ver"
    if not exist "%cd%/temp/setup/mcp!mcpver!.zip" (
        echo Downloading MCP...
        cscript.exe //B "%cd%/temp/setup/bl_downloader.vbs" http://mcp.ocean-labs.de/files/archive/mcp%mcpver%.zip "%cd%/temp/setup/mcp!mcpver!.zip"
        echo Done.
    ) else (
        echo MCP already downloaded; skipping download.
    )
    echo.
    echo Extracting MCP...
    "%cd%/temp/setup/7-zip/7z.exe" x -bd -ba -o"%cd%" -y "%cd%/temp/setup/mcp!mcpver!.zip"
    if exist "%cd%/decompile.bat" (
        echo Done.
    ) else (
        echo MCP version !mcpver! was not found, provide it manually to %cd%/temp/setup/mcp!mcpver!.zip!  Aborting install!
        pause
        exit /b 2
    )
    echo.
    REM TODO: find a way to do this without hardcoding anything.  Maybe reuse Libaries.txt, or write a batch JSON parser(If I go insane)?
    echo Downloading and copying libraries...
    if not exist "%cd%/lib/" mkdir "%cd%/lib/"
    cscript.exe //B "%cd%/temp/setup/bl_downloader.vbs" "http://repo1.maven.org/maven2/org/ow2/asm/asm-debug-all/4.1/asm-debug-all-4.1.jar" "%cd%/lib/asm-debug-all-4.1.jar"
    xcopy /Y "%appdata%\.minecraft\libraries\net\minecraft\launchwrapper\1.9\*.jar" "%cd%\lib\"
    cscript.exe //B "%cd%/temp/setup/bl_downloader.vbs" http://github.com/warriordog/CompCore/archive/master.zip "%cd%/temp/setup/CompCore_repo.zip"
    if not exist "%cd%/temp/setup/CompCore_repo.zip" (
        echo CompCore was not downloaded; aborting setup!
        exit /b 3
    )
    "%cd%/temp/setup/7-zip/7z.exe" x -o"%cd%/BlazeLoader/" -y "%cd%/temp/setup/CompCore_repo.zip"
    echo Done.
    echo.
    echo Applying AccessTransformer...
    if not exist "%cd%/jars/libraries/org/ow2/asm/asm-debug-all/4.1/" mkdir "%cd%/jars/libraries/org/ow2/asm/asm-debug-all/4.1/"
    xcopy /I /Y "%cd%\lib\asm-debug-all-4.1.jar" "%cd%\jars\libraries\org\ow2\asm\asm-debug-all\4.1\"
    "%cd%/BlazeLoader/apply_at.bat"
    echo Done.
    echo.
    echo Decompiling...
    "%cd%/runtime/bin/python/python_mcp.exe" "%cd%/runtime/decompile.py"
    echo Done.
    echo.
    echo Copying BlazeLoader sources...
    xcopy /I /Y /E /C /Q "%cd%\BlazeLoader\source\core\*" "%cd%\src\minecraft\"
    xcopy /I /Y /E /C /Q "%cd%\BlazeLoader\source\vanilla\*" "%cd%\src\minecraft\"
    echo Done.
    echo.
    if "!setupmode!" == "bl" (
        echo Recompiling...
        "%cd%/runtime/bin/python/python_mcp.exe" "%cd%/runtime/recompile.py"
    ) else (
        echo Updating MD5s...
        echo yes|"%cd%/runtime/bin/python/python_mcp.exe" "%cd%/runtime/updatemd5.py"
    )
    echo Done.
    echo.
    echo %date%-%time%>"%cd%/BlazeLoader/instlflg"
    echo MCP setup complete!
    echo.
	pause
) else (
    echo MCP has already been set up!
    pause
    exit /b -2
)

Update setup script to download CompCore


@echo off
setlocal enabledelayedexpansion
::
:: Copyright (c) 2017, HarpyWar (harpywar@gmail.com)
::
@call module\config.inc.bat

echo.
echo ###############################################################################
echo #                    PvPGN Visual Studio Solution Builder                     #
echo # --------------------------------------------------------------------------- #
call %i18n% 10_0_0
call %i18n% 10_0_1
echo # --------------------------------------------------------------------------- #
echo ###############################################################################
echo.

:: redefine %PVPGN_BUILD% without a slash
set PVPGN_BUILD=build

if not exist %PVPGN_BUILD%\pvpgn.sln (
	call %i18n% 10_1
	goto :THEEND
)

call %i18n% 10_2 "%PVPGN_DEVKIT%"
choice
echo.
echo --------------------------------------------------------------------------------

if %errorlevel%==2 goto :THEEND

if not exist %PVPGN_DEVKIT% mkdir %PVPGN_DEVKIT%

:: copy config.h
copy /Y "%PVPGN_BUILD%\config.h" "%PVPGN_DEVKIT%\"

:: copy pvpgn.sln
copy /Y "%PVPGN_BUILD%\pvpgn.sln" "%PVPGN_DEVKIT%\"

:: build each project
call :build_project bnetd bnetd
call :build_project bnpass bnpass
call :build_project bnpass sha1hash
call :build_project bntrackd bntrackd
call :build_project bniutils bni2tga
call :build_project bniutils bnibuild
call :build_project bniutils bniextract
call :build_project bniutils bnilist
call :build_project bniutils tgainfo
call :build_project common common
call :build_project compat compat
call :build_project client bnbot
call :build_project client bnchat
call :build_project client bnftp
call :build_project client bnstat
call :build_project d2cs d2cs
call :build_project d2dbs d2dbs
call :build_project tinycdb tinycdb
call :build_project tinycdb bncdb
call :build_project test bigint
call :build_project test bnetsrp3_test
call :build_project test bigint
call :build_project test bigint
call :build_project win32 win32

:: remove unused projects generated by cmake
call :remove_sln_project "%PVPGN_DEVKIT%pvpgn.sln" ALL_BUILD
call :remove_sln_project "%PVPGN_DEVKIT%pvpgn.sln" RUN_TESTS
call :remove_sln_project "%PVPGN_DEVKIT%pvpgn.sln" INSTALL
call :remove_sln_project "%PVPGN_DEVKIT%pvpgn.sln" purge
call :remove_sln_project "%PVPGN_DEVKIT%pvpgn.sln" uninstall

:: create shortcut on pvpgn.sln
call :create_shortcut "%CURRENT_PATH%%PVPGN_DEVKIT%pvpgn.sln" "%CURRENT_PATH%pvpgn.sln.lnk"

echo.
echo --------------------------------------------------------------------------------
call %i18n% 10_3 "%PVPGN_DEVKIT%"
call %i18n% 10_4 pvpgn.sln "%PVPGN_DEVKIT%pvpgn.sln"
call %i18n% 10_5 "release\"
echo --------------------------------------------------------------------------------

goto :THEEND

:build_project <path> <name>
	if not exist "%PVPGN_DEVKIT%projects\%2" mkdir "%PVPGN_DEVKIT%projects\%2"
	copy /Y "%PVPGN_BUILD%\src\%1\%2.vcxproj*" "%PVPGN_DEVKIT%projects\%2"

	call :create_vcxproj_user "%PVPGN_DEVKIT%projects\%2\%2.vcxproj.user"

	rem replace paths

	:: set atlmfc and release into additional include dir section
	@call %TOOLS_PATH%replacer.bat "%PVPGN_DEVKIT%projects\%2\%2.vcxproj" "%CURRENT_PATH%%PVPGN_BUILD%;%CURRENT_PATH%source\src;" "..\..\;%PROJECT_ROOT_DIR%source\src;%PROJECT_ROOT_DIR%release;%PROJECT_ROOT_DIR%module\include\atlmfc;"
	:: replace source path
	@call %TOOLS_PATH%replacer.bat "%PVPGN_DEVKIT%projects\%2\%2.vcxproj" "%CURRENT_PATH%source" "%PROJECT_ROOT_DIR%source"
	@call %TOOLS_PATH%replacer.bat "%PVPGN_DEVKIT%projects\%2\%2.vcxproj.filters" "%CURRENT_PATH%source" "%PROJECT_ROOT_DIR%source"
	:: replace release and debug paths
	@call %TOOLS_PATH%replacer.bat "%PVPGN_DEVKIT%projects\%2\%2.vcxproj" "%CURRENT_PATH%%PVPGN_BUILD%\src\%1\Debug" "%PROJECT_ROOT_DIR%release"
	@call %TOOLS_PATH%replacer.bat "%PVPGN_DEVKIT%projects\%2\%2.vcxproj" "%CURRENT_PATH%%PVPGN_BUILD%\src\%1\Release" "%PROJECT_ROOT_DIR%release"
	:: replace unix like build path
	@call %TOOLS_PATH%replacer.bat "%PVPGN_DEVKIT%projects\%2\%2.vcxproj" "%CURRENT_PATH_BACKSLASH%%PVPGN_BUILD%/src/%1" "../%2"
	:: replace path for magic builder module
	@call %TOOLS_PATH%replacer.bat "%PVPGN_DEVKIT%projects\%2\%2.vcxproj" "%CURRENT_PATH%module" "%PROJECT_ROOT_DIR%module"
	:: replace new path in pvpgn.sln
	@call %TOOLS_PATH%replacer.bat "%PVPGN_DEVKIT%pvpgn.sln" "src\%1\%2" "projects\%2\%2"

	:: libs now build into release
	@call %TOOLS_PATH%replacer.bat "%PVPGN_DEVKIT%projects\%2\%2.vcxproj" "..\common\Debug\common.lib" "%PROJECT_ROOT_DIR%release\common.lib"
	@call %TOOLS_PATH%replacer.bat "%PVPGN_DEVKIT%projects\%2\%2.vcxproj" "..\compat\Debug\compat.lib" "%PROJECT_ROOT_DIR%release\compat.lib"
	@call %TOOLS_PATH%replacer.bat "%PVPGN_DEVKIT%projects\%2\%2.vcxproj" "..\tinycdb\Debug\tinycdb.lib" "%PROJECT_ROOT_DIR%release\tinycdb.lib"
	@call %TOOLS_PATH%replacer.bat "%PVPGN_DEVKIT%projects\%2\%2.vcxproj" "..\win32\Debug\win32.lib" "%PROJECT_ROOT_DIR%release\win32.lib"
	:: this replacement only for bncdb project
	@call %TOOLS_PATH%replacer.bat "%PVPGN_DEVKIT%projects\%2\%2.vcxproj" "Debug\tinycdb.lib" "%PROJECT_ROOT_DIR%release\tinycdb.lib"
	@call %TOOLS_PATH%replacer.bat "%PVPGN_DEVKIT%projects\%2\%2.vcxproj" "Release\tinycdb.lib" "%PROJECT_ROOT_DIR%release\tinycdb.lib"

	:: remove reduntant cmake node that executes cmake.exe on each build
	call :remove_xml_node "%PVPGN_DEVKIT%projects\%2\%2.vcxproj" Project/ItemGroup/CustomBuild

	exit /b 0

:create_vcxproj_user <filename>

	echo ^<?xml version="1.0" encoding="utf-8"?^> > %1
	echo ^<Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"^> >> %1
	echo   ^<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"^> >> %1
	echo 	^<LocalDebuggerWorkingDirectory^>%PROJECT_ROOT_DIR%release^</LocalDebuggerWorkingDirectory^> >> %1
	echo 	^<DebuggerFlavor^>WindowsLocalDebugger^</DebuggerFlavor^> >> %1
	echo   ^</PropertyGroup^> >> %1
	echo   ^<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"^> >> %1
	echo 	^<LocalDebuggerWorkingDirectory^>%PROJECT_ROOT_DIR%release^</LocalDebuggerWorkingDirectory^> >> %1
	echo 	^<DebuggerFlavor^>WindowsLocalDebugger^</DebuggerFlavor^> >> %1
	echo   ^</PropertyGroup^> >> %1
	echo ^</Project^> >> %1

	exit /b 0

:create_shortcut <source> <destination>
	set SCRIPT="%TEMP%\%RANDOM%-%RANDOM%-%RANDOM%-%RANDOM%.vbs"
	echo Set oWS = WScript.CreateObject("WScript.Shell") >> %SCRIPT%
	echo sLinkFile = %2 >> %SCRIPT%
	echo Set oLink = oWS.CreateShortcut(sLinkFile) >> %SCRIPT%
	echo oLink.TargetPath = %1 >> %SCRIPT%
	echo oLink.Save >> %SCRIPT%

	cscript /nologo %SCRIPT%
	del %SCRIPT%

	exit /b 0

:: removes given xml node from xml file
:remove_xml_node "<filename.vcxproj>" nodeName
	set SCRIPT="%TEMP%\%RANDOM%-%RANDOM%-%RANDOM%-%RANDOM%.vbs"
	echo Set objXMLDoc = Wscript.CreateObject("Microsoft.XMLDOM") >> %SCRIPT%
	echo objXMLDoc.async = False >> %SCRIPT%
	echo Dim XMLFile >> %SCRIPT%
	echo XMLFile = %1 >> %SCRIPT%
	echo objXMLDoc.load(XMLFile)  >> %SCRIPT%
	echo Set nodes = objXMLDoc.selectNodes("%2") >> %SCRIPT%
	echo For Each node In nodes >> %SCRIPT%
	echo   node.parentNode.removeChild(node) >> %SCRIPT%
	echo Next >> %SCRIPT%
	echo objXMLDoc.Save(XMLFile) >> %SCRIPT%

	cscript /nologo %SCRIPT%
	del %SCRIPT%

	exit /b 0

:: removes a project block from vs solution file
:remove_sln_project "<filename.sln>" <projectName>
	set SCRIPT="%TEMP%\%RANDOM%-%RANDOM%-%RANDOM%-%RANDOM%.vbs"

	echo Dim newText >> %SCRIPT%
	echo Dim inProject >> %SCRIPT%
	echo Dim isBadProject >> %SCRIPT%
	echo Dim line >> %SCRIPT%

	echo Set fso = CreateObject("Scripting.FileSystemObject") >> %SCRIPT%
	echo Set f = fso.OpenTextFile(%1, 1) >> %SCRIPT%

	echo Do Until f.AtEndOfStream >> %SCRIPT%
	echo 	line = f.ReadLine >> %SCRIPT%
	echo 	If InStr(1, line, "Project(") = 1 Then ' if line starts with Project( >> %SCRIPT%
	echo 		inProject = true >> %SCRIPT%
	echo 		If InStr(1, line, "%2") > 0 Then ' if line contains a given project name >> %SCRIPT%
	echo 			isBadProject = true >> %SCRIPT%
	echo 		Else >> %SCRIPT%
	echo 			isBadProject = false >> %SCRIPT%
	echo 		End If >> %SCRIPT%
	echo 	End If >> %SCRIPT%

	echo 	If Not isBadProject Or Not inProject Then  >> %SCRIPT%
	echo 		newText = newText + line ^& vbCrLf >> %SCRIPT%
	echo 	End If >> %SCRIPT%

	echo 	If line = "EndProject" Then ' if line equal EndProject >> %SCRIPT%
	echo 		inProject = false >> %SCRIPT%
	echo 	End If >> %SCRIPT%
	echo Loop >> %SCRIPT%
	echo f.Close >> %SCRIPT%

	echo Set objFile = fso.CreateTextFile(%1, True) >> %SCRIPT%
	echo objFile.Write newText >> %SCRIPT%
	echo objFile.Close >> %SCRIPT%

	cscript /nologo %SCRIPT%
	del %SCRIPT%

	exit /b 0

:THEEND
pause

@echo off
setlocal enabledelayedexpansion
::
:: Copyright (c) 2017, HarpyWar (harpywar@gmail.com)
::
@call module\config.inc.bat

echo.
echo ###############################################################################
echo #                    PvPGN Visual Studio Solution Builder                     #
echo # --------------------------------------------------------------------------- #
call %i18n% 10_0_0
call %i18n% 10_0_1
echo # --------------------------------------------------------------------------- #
echo ###############################################################################
echo.

:: redefine %PVPGN_BUILD% without a slash
set PVPGN_BUILD=build

if not exist %PVPGN_BUILD%\pvpgn.sln (
	call %i18n% 10_1
	goto :THEEND
)

call %i18n% 10_2 "%PVPGN_DEVKIT%"
choice
echo.
echo --------------------------------------------------------------------------------

if %errorlevel%==2 goto :THEEND

if not exist %PVPGN_DEVKIT% mkdir %PVPGN_DEVKIT%

:: copy config.h
copy /Y "%PVPGN_BUILD%\config.h" "%PVPGN_DEVKIT%\"

:: copy pvpgn.sln
copy /Y "%PVPGN_BUILD%\pvpgn.sln" "%PVPGN_DEVKIT%\"

:: build each project
call :build_project bnetd bnetd
call :build_project bnpass bnpass
call :build_project bnpass sha1hash
call :build_project bntrackd bntrackd
call :build_project bniutils bni2tga
call :build_project bniutils bnibuild
call :build_project bniutils bniextract
call :build_project bniutils bnilist
call :build_project bniutils tgainfo
call :build_project common common
call :build_project compat compat
call :build_project client bnbot
call :build_project client bnchat
call :build_project client bnftp
call :build_project client bnstat
call :build_project d2cs d2cs
call :build_project d2dbs d2dbs
call :build_project test bigint
call :build_project test bnetsrp3_test
call :build_project test bigint
call :build_project test bigint
call :build_project win32 win32

:: remove unused projects generated by cmake
call :remove_sln_project "%PVPGN_DEVKIT%pvpgn.sln" ALL_BUILD
call :remove_sln_project "%PVPGN_DEVKIT%pvpgn.sln" RUN_TESTS
call :remove_sln_project "%PVPGN_DEVKIT%pvpgn.sln" INSTALL
call :remove_sln_project "%PVPGN_DEVKIT%pvpgn.sln" purge
call :remove_sln_project "%PVPGN_DEVKIT%pvpgn.sln" uninstall

:: create shortcut on pvpgn.sln
call :create_shortcut "%CURRENT_PATH%%PVPGN_DEVKIT%pvpgn.sln" "%CURRENT_PATH%pvpgn.sln.lnk"

echo.
echo --------------------------------------------------------------------------------
call %i18n% 10_3 "%PVPGN_DEVKIT%"
call %i18n% 10_4 pvpgn.sln "%PVPGN_DEVKIT%pvpgn.sln"
call %i18n% 10_5 "release\"
echo --------------------------------------------------------------------------------

goto :THEEND

:build_project <path> <name>
	if not exist "%PVPGN_DEVKIT%projects\%2" mkdir "%PVPGN_DEVKIT%projects\%2"
	copy /Y "%PVPGN_BUILD%\src\%1\%2.vcxproj*" "%PVPGN_DEVKIT%projects\%2"

	call :create_vcxproj_user "%PVPGN_DEVKIT%projects\%2\%2.vcxproj.user"

	rem replace paths

	:: set atlmfc and release into additional include dir section
	@call %TOOLS_PATH%replacer.bat "%PVPGN_DEVKIT%projects\%2\%2.vcxproj" "%CURRENT_PATH%%PVPGN_BUILD%;%CURRENT_PATH%source\src;" "..\..\;%PROJECT_ROOT_DIR%source\src;%PROJECT_ROOT_DIR%release;%PROJECT_ROOT_DIR%module\include\atlmfc;"
	:: replace source path
	@call %TOOLS_PATH%replacer.bat "%PVPGN_DEVKIT%projects\%2\%2.vcxproj" "%CURRENT_PATH%source" "%PROJECT_ROOT_DIR%source"
	@call %TOOLS_PATH%replacer.bat "%PVPGN_DEVKIT%projects\%2\%2.vcxproj.filters" "%CURRENT_PATH%source" "%PROJECT_ROOT_DIR%source"
	:: replace release and debug paths
	@call %TOOLS_PATH%replacer.bat "%PVPGN_DEVKIT%projects\%2\%2.vcxproj" "%CURRENT_PATH%%PVPGN_BUILD%\src\%1\Debug" "%PROJECT_ROOT_DIR%release"
	@call %TOOLS_PATH%replacer.bat "%PVPGN_DEVKIT%projects\%2\%2.vcxproj" "%CURRENT_PATH%%PVPGN_BUILD%\src\%1\Release" "%PROJECT_ROOT_DIR%release"
	:: replace unix like build path
	@call %TOOLS_PATH%replacer.bat "%PVPGN_DEVKIT%projects\%2\%2.vcxproj" "%CURRENT_PATH_BACKSLASH%%PVPGN_BUILD%/src/%1" "../%2"
	:: replace path for magic builder module
	@call %TOOLS_PATH%replacer.bat "%PVPGN_DEVKIT%projects\%2\%2.vcxproj" "%CURRENT_PATH%module" "%PROJECT_ROOT_DIR%module"
	:: replace new path in pvpgn.sln
	@call %TOOLS_PATH%replacer.bat "%PVPGN_DEVKIT%pvpgn.sln" "src\%1\%2" "projects\%2\%2"

	:: libs now build into release
	@call %TOOLS_PATH%replacer.bat "%PVPGN_DEVKIT%projects\%2\%2.vcxproj" "..\common\Debug\common.lib" "%PROJECT_ROOT_DIR%release\common.lib"
	@call %TOOLS_PATH%replacer.bat "%PVPGN_DEVKIT%projects\%2\%2.vcxproj" "..\compat\Debug\compat.lib" "%PROJECT_ROOT_DIR%release\compat.lib"
	@call %TOOLS_PATH%replacer.bat "%PVPGN_DEVKIT%projects\%2\%2.vcxproj" "..\tinycdb\Debug\tinycdb.lib" "%PROJECT_ROOT_DIR%release\tinycdb.lib"
	@call %TOOLS_PATH%replacer.bat "%PVPGN_DEVKIT%projects\%2\%2.vcxproj" "..\win32\Debug\win32.lib" "%PROJECT_ROOT_DIR%release\win32.lib"
	:: this replacement only for bncdb project
	@call %TOOLS_PATH%replacer.bat "%PVPGN_DEVKIT%projects\%2\%2.vcxproj" "Debug\tinycdb.lib" "%PROJECT_ROOT_DIR%release\tinycdb.lib"
	@call %TOOLS_PATH%replacer.bat "%PVPGN_DEVKIT%projects\%2\%2.vcxproj" "Release\tinycdb.lib" "%PROJECT_ROOT_DIR%release\tinycdb.lib"

	:: remove reduntant cmake node that executes cmake.exe on each build
	call :remove_xml_node "%PVPGN_DEVKIT%projects\%2\%2.vcxproj" Project/ItemGroup/CustomBuild

	exit /b 0

:create_vcxproj_user <filename>

	echo ^<?xml version="1.0" encoding="utf-8"?^> > %1
	echo ^<Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"^> >> %1
	echo   ^<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"^> >> %1
	echo 	^<LocalDebuggerWorkingDirectory^>%PROJECT_ROOT_DIR%release^</LocalDebuggerWorkingDirectory^> >> %1
	echo 	^<DebuggerFlavor^>WindowsLocalDebugger^</DebuggerFlavor^> >> %1
	echo   ^</PropertyGroup^> >> %1
	echo   ^<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"^> >> %1
	echo 	^<LocalDebuggerWorkingDirectory^>%PROJECT_ROOT_DIR%release^</LocalDebuggerWorkingDirectory^> >> %1
	echo 	^<DebuggerFlavor^>WindowsLocalDebugger^</DebuggerFlavor^> >> %1
	echo   ^</PropertyGroup^> >> %1
	echo ^</Project^> >> %1

	exit /b 0

:create_shortcut <source> <destination>
	set SCRIPT="%TEMP%\%RANDOM%-%RANDOM%-%RANDOM%-%RANDOM%.vbs"
	echo Set oWS = WScript.CreateObject("WScript.Shell") >> %SCRIPT%
	echo sLinkFile = %2 >> %SCRIPT%
	echo Set oLink = oWS.CreateShortcut(sLinkFile) >> %SCRIPT%
	echo oLink.TargetPath = %1 >> %SCRIPT%
	echo oLink.Save >> %SCRIPT%

	cscript /nologo %SCRIPT%
	del %SCRIPT%

	exit /b 0

:: removes given xml node from xml file
:remove_xml_node "<filename.vcxproj>" nodeName
	set SCRIPT="%TEMP%\%RANDOM%-%RANDOM%-%RANDOM%-%RANDOM%.vbs"
	echo Set objXMLDoc = Wscript.CreateObject("Microsoft.XMLDOM") >> %SCRIPT%
	echo objXMLDoc.async = False >> %SCRIPT%
	echo Dim XMLFile >> %SCRIPT%
	echo XMLFile = %1 >> %SCRIPT%
	echo objXMLDoc.load(XMLFile)  >> %SCRIPT%
	echo Set nodes = objXMLDoc.selectNodes("%2") >> %SCRIPT%
	echo For Each node In nodes >> %SCRIPT%
	echo   node.parentNode.removeChild(node) >> %SCRIPT%
	echo Next >> %SCRIPT%
	echo objXMLDoc.Save(XMLFile) >> %SCRIPT%

	cscript /nologo %SCRIPT%
	del %SCRIPT%

	exit /b 0

:: removes a project block from vs solution file
:remove_sln_project "<filename.sln>" <projectName>
	set SCRIPT="%TEMP%\%RANDOM%-%RANDOM%-%RANDOM%-%RANDOM%.vbs"

	echo Dim newText >> %SCRIPT%
	echo Dim inProject >> %SCRIPT%
	echo Dim isBadProject >> %SCRIPT%
	echo Dim line >> %SCRIPT%

	echo Set fso = CreateObject("Scripting.FileSystemObject") >> %SCRIPT%
	echo Set f = fso.OpenTextFile(%1, 1) >> %SCRIPT%

	echo Do Until f.AtEndOfStream >> %SCRIPT%
	echo 	line = f.ReadLine >> %SCRIPT%
	echo 	If InStr(1, line, "Project(") = 1 Then ' if line starts with Project( >> %SCRIPT%
	echo 		inProject = true >> %SCRIPT%
	echo 		If InStr(1, line, "%2") > 0 Then ' if line contains a given project name >> %SCRIPT%
	echo 			isBadProject = true >> %SCRIPT%
	echo 		Else >> %SCRIPT%
	echo 			isBadProject = false >> %SCRIPT%
	echo 		End If >> %SCRIPT%
	echo 	End If >> %SCRIPT%

	echo 	If Not isBadProject Or Not inProject Then  >> %SCRIPT%
	echo 		newText = newText + line ^& vbCrLf >> %SCRIPT%
	echo 	End If >> %SCRIPT%

	echo 	If line = "EndProject" Then ' if line equal EndProject >> %SCRIPT%
	echo 		inProject = false >> %SCRIPT%
	echo 	End If >> %SCRIPT%
	echo Loop >> %SCRIPT%
	echo f.Close >> %SCRIPT%

	echo Set objFile = fso.CreateTextFile(%1, True) >> %SCRIPT%
	echo objFile.Write newText >> %SCRIPT%
	echo objFile.Close >> %SCRIPT%

	cscript /nologo %SCRIPT%
	del %SCRIPT%

	exit /b 0

:THEEND
pause

remove non-exist tinycdb from build projects


@echo off
nuget restore ..\src\Adaptive.Aeron.sln
call "C:\Program Files (x86)\MSBuild\14.0\Bin\MsBuild.exe" /p:Configuration=Release /p:Platform="x64" ..\src\Adaptive.Aeron.sln

@echo off
pushd %~dp0..
nuget restore .\src\Adaptive.Aeron.sln
call "C:\Program Files (x86)\MSBuild\14.0\Bin\MsBuild.exe" /p:Configuration=Release /p:Platform="x64" .\src\Adaptive.Aeron.sln
popd

Allow build script to be run from other dir


cd ..
node ..\node_modules\bower\bin\bower install
cd tools
call cordova create finder ru.gofinder.app Finder
rd /s /q finder\www
mkdir finder\www
copy config.xml finder\config.xml
cd finder
call cordova platform add android
call cordova plugin add org.apache.cordova.console org.apache.cordova.device org.apache.cordova.inappbrowser org.apache.cordova.geolocation
cd ..
cd ..
cd ..
call npm install
cd public
node ..\node_modules\gulp\bin\gulp build --cordova --server_url="http://spacebox.herokuapp.com" --production

mkdir tools\finder\www\lib
xcopy lib tools\finder\www\lib /s /e /y

copy tools\Finder.java tools\finder\platforms\android\src\ru\gofinder\app\Finder.java
copy index.html tools\finder\www\index.html
copy app.manifest tools\finder\www\app.manifest

mkdir tools\finder\www\src\js
copy src\js\main.js tools\finder\www\src\js\main.js

mkdir tools\finder\www\src\js\app\templates
xcopy src\js\app\templates tools\finder\www\src\js\app\templates /s /e /y

mkdir tools\finder\www\src\img
xcopy src\img tools\finder\www\src\img /s /e /y

copy dist\spacebox-mobile.js tools\finder\www\src\js\spacebox-mobile.js
copy dist\spacebox-mobile.min.js tools\finder\www\src\js\spacebox-mobile.min.js
mkdir tools\finder\www\src\css
copy dist\spacebox.css tools\finder\www\src\css\spacebox.css
copy dist\spacebox.min.css tools\finder\www\src\css\spacebox.min.css

copy tools\android\icon48.png tools\finder\platforms\android\res\drawable\icon.png
copy tools\android\icon72.png tools\finder\platforms\android\res\drawable-hdpi\icon.png
copy tools\android\icon36.png tools\finder\platforms\android\res\drawable-ldpi\icon.png
copy tools\android\icon48.png tools\finder\platforms\android\res\drawable-mdpi\icon.png
copy tools\android\icon96.png tools\finder\platforms\android\res\drawable-xhdpi\icon.png

cd tools\finder
call cordova run android
exit
call cordova build --release android
jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore ..\my-release-key.keystore platforms\android\ant-build\Finder-release-unsigned.apk alias_name
rm platforms\android\ant-build\Finder.apk
zipalign -v 4 platforms\android\ant-build\Finder-release-unsigned.apk platforms\android\ant-build\Finder.apk

cd ..
node ..\node_modules\bower\bin\bower install
cd tools
call cordova create finder ru.gofinder.app Finder
rd /s /q finder\www
mkdir finder\www
copy config.xml finder\config.xml
cd finder
call cordova platform add android
call cordova plugin add org.apache.cordova.console org.apache.cordova.device org.apache.cordova.inappbrowser org.apache.cordova.geolocation
cd ..
cd ..
cd ..
call npm install
cd public
node ..\node_modules\gulp\bin\gulp build --cordova --server_url="http://spacebox.herokuapp.com"

mkdir tools\finder\www\lib
xcopy lib tools\finder\www\lib /s /e /y

copy tools\Finder.java tools\finder\platforms\android\src\ru\gofinder\app\Finder.java
copy index.html tools\finder\www\index.html
copy app.manifest tools\finder\www\app.manifest

mkdir tools\finder\www\src\js
copy src\js\main.js tools\finder\www\src\js\main.js

mkdir tools\finder\www\src\js\app\templates
xcopy src\js\app\templates tools\finder\www\src\js\app\templates /s /e /y

mkdir tools\finder\www\src\img
xcopy src\img tools\finder\www\src\img /s /e /y

mkdir tools\finder\www\dist
copy dist\spacebox.js tools\finder\www\dist\spacebox.js
copy dist\spacebox.min.js tools\finder\www\dist\spacebox.min.js
copy dist\spacebox.css tools\finder\www\dist\spacebox.css
copy dist\spacebox.min.css tools\finder\www\dist\spacebox.min.css

copy tools\android\icon48.png tools\finder\platforms\android\res\drawable\icon.png
copy tools\android\icon72.png tools\finder\platforms\android\res\drawable-hdpi\icon.png
copy tools\android\icon36.png tools\finder\platforms\android\res\drawable-ldpi\icon.png
copy tools\android\icon48.png tools\finder\platforms\android\res\drawable-mdpi\icon.png
copy tools\android\icon96.png tools\finder\platforms\android\res\drawable-xhdpi\icon.png

cd tools\finder
call cordova run android
exit
call cordova build --release android
jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore ..\my-release-key.keystore platforms\android\ant-build\Finder-release-unsigned.apk alias_name
rm platforms\android\ant-build\Finder.apk
zipalign -v 4 platforms\android\ant-build\Finder-release-unsigned.apk platforms\android\ant-build\Finder.apk

Update android script

Update android script


Add a simple local checkin gate

Add a simple local checkin gate


::
:: Microsoft Azure SDK for Net - Generate library code
:: Copyright (C) Microsoft Corporation. All Rights Reserved.
::

@echo off
setlocal
set autoRestVersion=0.14.0-Nightly20160125
set source=-Source https://www.myget.org/F/autorest/api/v2

set resSpecFile="https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/arm-resources/resources/2016-02-01/swagger/resources.json"
set lockSpecFile="https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/arm-resources/locks/2015-01-01/swagger/locks.json"
set featureSpecFile="https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/arm-resources/features/2015-12-01/swagger/features.json"
set subscriptionSpecFile="https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/arm-resources/subscriptions/2015-11-01/swagger/subscriptions.json"
set policySpecFile="https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/arm-resources/policy/2016-04-01/swagger/policy.json"

set repoRoot=%~dp0..\..\..\..
set generateFolder=%~dp0Generated

if exist %generateFolder% rd /S /Q  %generateFolder%

call "%repoRoot%\tools\autorest.gen.cmd" %resSpecFile% Microsoft.Azure.Management.ResourceManager %autoRestVersion% %generateFolder%
call "%repoRoot%\tools\autorest.gen.cmd" %lockSpecFile% Microsoft.Azure.Management.ResourceManager %autoRestVersion% %generateFolder%
call "%repoRoot%\tools\autorest.gen.cmd" %featureSpecFile% Microsoft.Azure.Management.ResourceManager %autoRestVersion% %generateFolder%
call "%repoRoot%\tools\autorest.gen.cmd" %subscriptionSpecFile% Microsoft.Azure.Management.ResourceManager %autoRestVersion% %generateFolder%
call "%repoRoot%\tools\autorest.gen.cmd" %policySpecFile% Microsoft.Azure.Management.ResourceManager %autoRestVersion% %generateFolder%

endlocal

::
:: Microsoft Azure SDK for Net - Generate library code
:: Copyright (C) Microsoft Corporation. All Rights Reserved.
::

@echo off
setlocal
set autoRestVersion=0.17.0-Nightly20160629
set source=-Source https://www.myget.org/F/autorest/api/v2

set resSpecFile="https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/arm-resources/resources/2016-02-01/swagger/resources.json"
set lockSpecFile="https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/arm-resources/locks/2015-01-01/swagger/locks.json"
set featureSpecFile="https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/arm-resources/features/2015-12-01/swagger/features.json"
set subscriptionSpecFile="https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/arm-resources/subscriptions/2016-06-01/swagger/subscriptions.json"
set policySpecFile="https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/arm-resources/policy/2016-04-01/swagger/policy.json"

set repoRoot=%~dp0..\..\..\..
set generateFolder=%~dp0Generated

if exist %generateFolder% rd /S /Q  %generateFolder%

call "%repoRoot%\tools\autorest.gen.cmd" %resSpecFile% Microsoft.Azure.Management.ResourceManager %autoRestVersion% %generateFolder%
call "%repoRoot%\tools\autorest.gen.cmd" %lockSpecFile% Microsoft.Azure.Management.ResourceManager %autoRestVersion% %generateFolder%
call "%repoRoot%\tools\autorest.gen.cmd" %featureSpecFile% Microsoft.Azure.Management.ResourceManager %autoRestVersion% %generateFolder%
call "%repoRoot%\tools\autorest.gen.cmd" %subscriptionSpecFile% Microsoft.Azure.Management.ResourceManager %autoRestVersion% %generateFolder%
call "%repoRoot%\tools\autorest.gen.cmd" %policySpecFile% Microsoft.Azure.Management.ResourceManager %autoRestVersion% %generateFolder%

endlocal

Update generate.cmd for resources

Update generate.cmd for resources


@ECHO OFF
SETLOCAL ENABLEEXTENSIONS

REM This Windows batch file mounts a virtual hard drive, creates a file in it, removes the file, and then unmounts the hard drive.
REM
REM Setup:
REM   1.  Open _Disk Management_ through the Start menu
REM   2.  Navigate to _Action_ and select _Create VHD_
REM   3.  Select the location for the virtual hard drive file and set the size to 10MB or greater
REM   4.  Right click the new disk, select _Initialize Disk_, and click _OK_
REM   5.  Right-click on the unallocated space in the new disk and select _New Simple Volume_
REM   6.  Follow the wizard; in the screen _Assign Drive Letter or Path_, choose not to assign them
REM   7.  Open a new command line window and type MOUNTVOL
REM   8.  From the output, copy the volume name of your newly created hard drive (e.g. \\?\Volume{2f823551-0df2-11e6-96ba-806e6f6e6963}) into the configuration variable VOLUME below
REM   9.  Assign the volume an unused drive letter in the configuration variable DRIVE below
REM   10. Execute this script

ECHO [Script executed at %DATE%-%TIME%]

REM Volume: Configuration variable
REM Volume: Unique identifier for the volume; open command prompt and type MOUNTVOL to find the volume name
REM Volume: E.g. \\?\Volume{2f823551-0df2-11e6-96ba-806e6f6e6963}\
SET VOLUME=

REM Drive: Configuration variable
REM Drive: Letter to denote the mount point
REM Drive: E.g. D
SET DRIVE=

REM Flesh out configuration variables
SET DRIVE=%DRIVE%:

REM Check for empty drive
CALL :CheckUnmounted %DRIVE% RETVAL
IF %RETVAL% neq 0 (
  ECHO Error: Drive %DRIVE% is already in use.
  EXIT /B %RETVAL%
)

REM Mount and check volume
MOUNTVOL %DRIVE% %VOLUME%
CALL :CheckMounted %DRIVE% RETVAl
IF %RETVAL% neq 0 (
  ECHO Error: Failed to mount volume on drive %DRIVE%. Errorlevel %RETVAL%.
  EXIT /B %RETVAL%
)

REM Add and remove file
ECHO This file can be deleted.> %DRIVE%\tmp.txt
DEL %DRIVE%\tmp.txt

REM Unmount volume and check empty drive
MOUNTVOL %DRIVE% /P
CALL :CheckUnmounted %DRIVE% RETVAL
IF %RETVAL% neq 0 (
  ECHO Error: Failed to unmount volume from drive %DRIVE% . Errorlevel %RETVAL%.
  EXIT /B %RETVAL%
)

ECHO [Script finished at %DATE%-%TIME%]
EXIT /B 0

REM This function checks that a certain drive is mounted.
REM
REM Parameters:
REM   1: Drive letter with trailing colon (e.g. C:)
REM   2: Return value
REM     Equals 0 if the drive is mounted
REM     Equals Non-zero in any other case
:CheckMounted
SET DRIVE=%~1
MOUNTVOL %DRIVE% /L > NUL 2>&1
SET %~2=%EXITCODE%
EXIT /B %EXITCODE%

REM This function checks that a certain drive is unmounted.
REM
REM Parameters:
REM   1: Drive letter with trailing colon (e.g. C:)
REM   2: Return value
REM     Equals 0 if the drive is not mounted
REM     Equals 1 in any other case
:CheckUnmounted
SET DRIVE=%~1
SET EXITCODE=1
MOUNTVOL %DRIVE% /L > NUL 2>&1
IF %ERRORLEVEL% EQU 1 (  REM Must be immediately after MOUNTVOL
  SET EXITCODE=0
)
SET %~2=%EXITCODE%
EXIT /B %EXITCODE%

@ECHO OFF
SETLOCAL ENABLEEXTENSIONS

REM This Windows batch file mounts a virtual hard drive, creates a file in it, removes the file, and then unmounts the hard drive.
REM
REM Setup:
REM   1.  Open _Disk Management_ through the Start menu
REM   2.  Navigate to _Action_ and select _Create VHD_
REM   3.  Select the location for the virtual hard drive file and set the size to 10MB or greater
REM   4.  Right click the new disk, select _Initialize Disk_, and click _OK_
REM   5.  Right-click on the unallocated space in the new disk and select _New Simple Volume_
REM   6.  Follow the wizard; in the screen _Assign Drive Letter or Path_, choose not to assign them
REM   7.  Open a new command line window and type MOUNTVOL
REM   8.  From the output, copy the volume name of your newly created hard drive (e.g. \\?\Volume{2f823551-0df2-11e6-96ba-806e6f6e6963}) into the configuration variable VOLUME below
REM   9.  Assign the volume an unused drive letter in the configuration variable DRIVE below
REM   10. Execute this script

ECHO [Script executed at %DATE%-%TIME%]

REM Volume: Configuration variable
REM Volume: Unique identifier for the volume; open command prompt and type MOUNTVOL to find the volume name
REM Volume: E.g. \\?\Volume{2f823551-0df2-11e6-96ba-806e6f6e6963}\
SET VOLUME=

REM Drive: Configuration variable
REM Drive: Letter to denote the mount point
REM Drive: E.g. D
SET DRIVE=

REM Flesh out configuration variables
SET DRIVE=%DRIVE%:

REM Check for empty drive
CALL :CheckUnmounted %DRIVE% RETVAL
IF %RETVAL% neq 0 (
  ECHO Error: Drive %DRIVE% is already in use.
  EXIT /B %RETVAL%
)

REM Mount and check volume
MOUNTVOL %DRIVE% %VOLUME%
CALL :CheckMounted %DRIVE% RETVAL
IF %RETVAL% neq 0 (
  ECHO Error: Failed to mount volume on drive %DRIVE%. Errorlevel %RETVAL%.
  EXIT /B %RETVAL%
)

REM Add and remove file
ECHO This file can be deleted.> %DRIVE%\tmp.txt
DEL %DRIVE%\tmp.txt

REM Unmount volume and check empty drive
MOUNTVOL %DRIVE% /P
CALL :CheckUnmounted %DRIVE% RETVAL
IF %RETVAL% neq 0 (
  ECHO Error: Failed to unmount volume from drive %DRIVE% . Errorlevel %RETVAL%.
  EXIT /B %RETVAL%
)

ECHO [Script finished at %DATE%-%TIME%]
EXIT /B 0

REM This function checks that a certain drive is mounted.
REM
REM Parameters:
REM   1: Drive letter with trailing colon (e.g. C:)
REM   2: Return value
REM     Equals 0 if the drive is mounted
REM     Equals Non-zero in any other case
:CheckMounted
SET DRIVE=%~1
MOUNTVOL %DRIVE% /L > NUL 2>&1
SET %~2=%EXITCODE%
EXIT /B %EXITCODE%

REM This function checks that a certain drive is unmounted.
REM
REM Parameters:
REM   1: Drive letter with trailing colon (e.g. C:)
REM   2: Return value
REM     Equals 0 if the drive is not mounted
REM     Equals 1 in any other case
:CheckUnmounted
SET DRIVE=%~1
SET EXITCODE=1
MOUNTVOL %DRIVE% /L > NUL 2>&1
IF %ERRORLEVEL% EQU 1 (  REM Must be immediately after MOUNTVOL
  SET EXITCODE=0
)
SET %~2=%EXITCODE%
EXIT /B %EXITCODE%

Fix RETVAL variable name

[Misc] Fix RETVAL variable name