@echo off
rem ----------------------------------------------------------------------------
rem  Copyright 2018 WSO2, Inc. http://www.wso2.org
rem
rem  Licensed under the Apache License, Version 2.0 (the "License");
rem  you may not use this file except 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, software
rem  distributed under the License is distributed on an "AS IS" BASIS,
rem  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
rem  See the License for the specific language governing permissions and
rem  limitations under the License.

set userLocation=%cd%
set pathToApiManagerXML=..\repository\conf\api-manager.xml
set pathToAxis2XML=..\repository\conf\axis2\axis2.xml
set pathToAxis2XMLTemplate=..\repository\resources\conf\templates\repository\conf\axis2\axis2.xml.j2
set pathToRegistryTemplate=..\repository\resources\conf\templates\repository\conf\registry.xml.j2
set pathToRegistry=..\repository\conf\registry.xml
set pathToInboundEndpoints=..\repository\deployment\server\synapse-configs\default\inbound-endpoints
set pathToWebapps=..\repository\deployment\server\webapps
set pathToJaggeryapps=..\repository\deployment\server\jaggeryapps
set pathToSynapseConfigs=..\repository\deployment\server\synapse-configs\default
set pathToAxis2TMXml=..\repository\conf\axis2\axis2_TM.xml
set pathToAxis2TMXmlTemplate=..\repository\resources\conf\templates\repository\conf\axis2\axis2_TM.xml.j2
set pathToRegistryTM=..\repository\conf\registry_TM.xml
set pathToRegistryTMTemplate=..\repository\resources\conf\templates\repository\conf\registry_TM.xml.j2
set axis2XMLBackup=axis2backup.xml
set axis2XMLBackupTemplate=axis2.xml.j2.backup
set registryBackup=registryBackup.xml
set registryBackupTemplate=registry.xml.j2.backup
set axis2XML=axis2.xml
set axis2XMLTemplate=axis2.xml.j2
set registryXML=registry.xml
set registryXMLTemplate=registry.xml.j2

cd /d %~dp0

rem ----- Process the input commands (two args only)-------------------------------------------
if ""%1""==""-Dprofile"" (
	if ""%2""==""api-key-manager"" 	goto keyManager
	if ""%2""==""api-publisher"" 	goto publisher
	if ""%2""==""api-devportal"" 	goto devportal
	if ""%2""==""traffic-manager"" 	goto trafficManager
	if ""%2""==""gateway-worker"" 	goto gatewayWorker
)
echo Profile is not specified properly, please try again
goto end

:keyManager
echo Starting to optimize API Manager for the Key Manager profile
call :disableDataPublisher
call :disableJMSConnectionDetails
call :disablePolicyDeployer
call :disableBlockConditionRetriever
call :disableTransportSenderWS
call :disableTransportSenderWSS
call :removeWebSocketInboundEndpoint
call :removeSecureWebSocketInboundEndpoint
call :removeSynapseConfigs
rem ---removing webbapps which are not required for this profile--------
for /f %%i in ('dir %pathToWebapps% /b ^| findstr /v "client-registration#v.*war authenticationendpoint accountrecoveryendpoint oauth2.war throttle#data#v.*war api#identity#consent-mgt#v.*war"') do (
	del /f %pathToWebapps%\%%i
	call :Timestamp value
	echo %value% INFO - Removed the %%i file from %pathToWebapps%
	setlocal enableDelayedExpansion
	set folderName=%%i
	set folderName=!folderName:.war=!
	if exist %pathToWebapps%\!folderName!\ (
		rmdir /s /q %pathToWebapps%\!folderName!
		call :Timestamp value
		echo %value% INFO - Removed the !folderName! directory from %pathToWebapps%
	)
	endlocal
)
rem ---removing jaggeryapps which are not required for this profile--------
for /f %%i in ('dir "%pathToJaggeryapps%" /A:D /b') do (
	rmdir /s /q %pathToJaggeryapps%\%%i
	call :Timestamp value
	echo %value% INFO - Removed the %%i directory from %pathToJaggeryapps%
)
goto finishOptimization

:publisher
echo Starting to optimize API Manager for the API Publisher profile
call :disableJMSConnectionDetails
call :disableBlockConditionRetriever
call :disableTransportSenderWS
call :disableTransportSenderWSS
call :removeWebSocketInboundEndpoint
call :removeSecureWebSocketInboundEndpoint
rem ---removing webbapps which are not required for this profile--------
for /f %%i in ('dir %pathToWebapps% /b ^| findstr /v "api#am#publisher#v.*war api#am#publisher.war client-registration#v.*war authenticationendpoint accountrecoveryendpoint oauth2.war api#am#admin#v.*war"') do (
	del /f %pathToWebapps%\%%i
	call :Timestamp value
	echo %value% INFO - Removed the %%i file from %pathToWebapps%
	setlocal enableDelayedExpansion
	set folderName=%%i
	set folderName=!folderName:.war=!
	if exist %pathToWebapps%\!folderName!\ (
		rmdir /s /q %pathToWebapps%\!folderName!
		call :Timestamp value
		echo %value% INFO - Removed the !folderName! directory from %pathToWebapps%
	)
	endlocal
)
rem ---removing jaggeryapps which are not required for this profile--------
for /f %%i in ('dir "%pathToJaggeryapps%" /A:D /b ^| findstr /v "publisher admin"') do (
	rmdir /s /q %pathToJaggeryapps%\%%i
	call :Timestamp value
	echo %value% INFO - Removed the %%i directory from %pathToJaggeryapps%
)
goto finishOptimization

:devportal
echo Starting to optimize API Manager for the Developer Portal profile
call :disableDataPublisher
call :disableJMSConnectionDetails
call :disableBlockConditionRetriever
call :disablePolicyDeployer
call :disableTransportSenderWS
call :disableTransportSenderWSS
call :removeWebSocketInboundEndpoint
call :removeSecureWebSocketInboundEndpoint
rem ---removing webbapps which are not required for this profile--------
for /f %%i in ('dir %pathToWebapps% /b ^| findstr /v "api#am#store#v.*war api#am#store.war client-registration#v.*war authenticationendpoint accountrecoveryendpoint oauth2.war api#am#admin#v.*war"') do (
	del /f %pathToWebapps%\%%i
	call :Timestamp value
	echo %value% INFO - Removed the %%i file from %pathToWebapps%
	setlocal enableDelayedExpansion
	set folderName=%%i
	set folderName=!folderName:.war=!
	if exist %pathToWebapps%\!folderName!\ (
		rmdir /s /q %pathToWebapps%\!folderName!
		call :Timestamp value
		echo %value% INFO - Removed the !folderName! directory from %pathToWebapps%
	)
	endlocal
)
rem ---removing jaggeryapps which are not required for this profile--------
for /f %%i in ('dir "%pathToJaggeryapps%" /A:D /b ^| findstr /v "devportal"') do (
	rmdir /s /q %pathToJaggeryapps%\%%i
	call :Timestamp value
	echo %value% INFO - Removed the %%i directory from %pathToJaggeryapps%
)
goto finishOptimization

:trafficManager
echo Starting to optimize API Manager for the Traffic Manager profile
call :replaceAxis2File
call :replaceRegistryXMLFile
call :replaceAxis2TemplateFile
call :replaceRegistryXMLTemplateFile
call :removeWebSocketInboundEndpoint
call :removeSecureWebSocketInboundEndpoint
call :disableIndexingConfiguration
call :removeSynapseConfigs
rem ---removing webbapps which are not required for this profile--------
for /f %%i in ('dir %pathToWebapps% /b') do (
	del /f %pathToWebapps%\%%i
	call :Timestamp value
	echo %value% INFO - Removed the %%i file from %pathToWebapps%
	setlocal enableDelayedExpansion
	set folderName=%%i
	set folderName=!folderName:.war=!
	if exist %pathToWebapps%\!folderName!\ (
		rmdir /s /q %pathToWebapps%\!folderName!
		call :Timestamp value
		echo %value% INFO - Removed the !folderName! directory from %pathToWebapps%
	)
	endlocal
)
rem ---removing jaggeryapps which are not required for this profile--------
for /f %%i in ('dir "%pathToJaggeryapps%" /A:D /b') do (
	rmdir /s /q %pathToJaggeryapps%\%%i
	call :Timestamp value
	echo %value% INFO - Removed the %%i directory from %pathToJaggeryapps%
)
goto finishOptimization

:gatewayWorker
echo Starting to optimize API Manager for the Gateway worker profile
call :disablePolicyDeployer
call :disableIndexingConfiguration
rem ---removing webbapps which are not required for this profile--------
for /f %%i in ('dir %pathToWebapps% /b ^| findstr /v "am#sample#pizzashack#v.*war"') do (
	del /f %pathToWebapps%\%%i
	call :Timestamp value
	echo %value% INFO - Removed the %%i file from %pathToWebapps%
	setlocal enableDelayedExpansion
	set folderName=%%i
	set folderName=!folderName:.war=!
	if exist %pathToWebapps%\!folderName!\ (
		rmdir /s /q %pathToWebapps%\!folderName!
		call :Timestamp value
		echo %value% INFO - Removed the !folderName! directory from %pathToWebapps%
	)
	endlocal
)
rem ---removing jaggeryapps which are not required for this profile--------
for /f %%i in ('dir "%pathToJaggeryapps%" /A:D /b') do (
	rmdir /s /q %pathToJaggeryapps%\%%i
	call :Timestamp value
	echo %value% INFO - Removed the %%i directory from %pathToJaggeryapps%
)
goto finishOptimization

:disableDataPublisher
for /f %%i in ('powershell -Command "$xml = [xml] (Get-Content %pathToApiManagerXML%); $xml.APIManager.ThrottlingConfigurations.DataPublisher.Enabled;"') do (
	if %%i==true (
		powershell -Command "$xml = [xml] (Get-Content %pathToApiManagerXML%); $xml.APIManager.ThrottlingConfigurations.DataPublisher.Enabled='false'; $xml.Save('%pathToApiManagerXML%');"
		call :Timestamp value
		echo %value% INFO - Disabled the ^<DataPublisher^> from api-manager.xml file
	)
)
EXIT /B 0

:disableJMSConnectionDetails
for /f %%i in ('powershell -Command "$xml = [xml] (Get-Content %pathToApiManagerXML%); $xml.APIManager.ThrottlingConfigurations.JMSConnectionDetails.Enabled;"') do (
	if %%i==true (
		powershell -Command "$xml = [xml] (Get-Content %pathToApiManagerXML%); $xml.APIManager.ThrottlingConfigurations.JMSConnectionDetails.Enabled='false'; $xml.Save('%pathToApiManagerXML%');"
		call :Timestamp value
		echo %value% INFO - Disabled the ^<JMSConnectionDetails^> from api-manager.xml file
	)
)
EXIT /B 0

:disablePolicyDeployer
for /f %%i in ('powershell -Command "$xml = [xml] (Get-Content %pathToApiManagerXML%); $xml.APIManager.ThrottlingConfigurations.PolicyDeployer.Enabled;"') do (
	if %%i==true (
		powershell -Command "$xml = [xml] (Get-Content %pathToApiManagerXML%); $xml.APIManager.ThrottlingConfigurations.PolicyDeployer.Enabled='false'; $xml.Save('%pathToApiManagerXML%');"
		call :Timestamp value
		echo %value% INFO - Disabled the ^<PolicyDeployer^> from api-manager.xml file
	)
)
EXIT /B 0

:disableBlockConditionRetriever
for /f %%i in ('powershell -Command "$xml = [xml] (Get-Content %pathToApiManagerXML%); $xml.APIManager.ThrottlingConfigurations.BlockCondition.Enabled;"') do (
	if %%i==true (
		powershell -Command "$xml = [xml] (Get-Content %pathToApiManagerXML%); $xml.APIManager.ThrottlingConfigurations.BlockCondition.Enabled='false'; $xml.Save('%pathToApiManagerXML%');"
		call :Timestamp value
		echo %value% INFO - Disabled the ^<BlockCondition^> from api-manager.xml file
	)
)
EXIT /B 0

:disableTransportSenderWS
for /f %%i in ('powershell -Command "& {$xml = [xml] (Get-Content %pathToAxis2XML%); $xml.selectSingleNode('//transportSender[@name=\"ws\"]'); }" ') do (
	powershell -Command "& { $xml = [xml] (Get-Content %pathToAxis2XML%); $xml.selectNodes('//transportSender[@name=\"ws\"]') | ForEach-Object { $node = $_; $comment = $xml.CreateComment($node.OuterXml); $node=$node.ParentNode.ReplaceChild($comment, $node);}; $xml.Save('%pathToAxis2XML%');}"
	call :Timestamp value
	echo %value% INFO - Disabled the ^<transportSender name="ws" class="org.wso2.carbon.websocket.transport.WebsocketTransportSender"^> from axis2.xml file
	goto skipLoop1
)
:skipLoop1
EXIT /B 0

:disableTransportSenderWSS
for /f %%i in ('powershell -Command "& {$xml = [xml] (Get-Content %pathToAxis2XML%); $xml.SelectSingleNode('//transportSender[@name=\"wss\"]'); }" ') do (
	powershell -Command "& { $xml = [xml] (Get-Content %pathToAxis2XML%); $xml.selectNodes('//transportSender[@name=\"wss\"]') | ForEach-Object { $node = $_; $comment = $xml.CreateComment($node.OuterXml); $node=$node.ParentNode.ReplaceChild($comment, $node);}; $xml.Save('%pathToAxis2XML%');}"
	call :Timestamp value
	echo %value% INFO - Disabled the ^<transportSender name="wss" class="org.wso2.carbon.websocket.transport.WebsocketTransportSender"^> from axis2.xml file
	goto skipLoop2
	)
:skipLoop2
EXIT /B 0

:disableIndexingConfiguration
for /f %%i in ('powershell -Command "$xml = [xml] (Get-Content %pathToRegistry%); $xml.wso2registry.indexingConfiguration.startIndexing;"') do (
	if %%i==true (
		powershell -Command "$xml = [xml] (Get-Content %pathToRegistry%); $xml.wso2registry.indexingConfiguration.startIndexing='false'; $xml.Save('%pathToRegistry%');"
		call :Timestamp value
		echo %value% INFO - Disabled the ^<indexingConfiguration^> from registry.xml file
	)
)
EXIT /B 0

:removeWebSocketInboundEndpoint
if exist %pathToInboundEndpoints%\WebSocketInboundEndpoint.xml (
	del /f %pathToInboundEndpoints%\WebSocketInboundEndpoint.xml
	call :Timestamp value
	echo %value% INFO - Removed the WebSocketInboundEndpoint.xml file from %pathToInboundEndpoints%
)
EXIT /B 0

:removeSecureWebSocketInboundEndpoint
if exist %pathToInboundEndpoints%\SecureWebSocketInboundEndpoint.xml (
	del /f %pathToInboundEndpoints%\SecureWebSocketInboundEndpoint.xml
	call :Timestamp value
	echo %value% INFO - Removed the SecureWebSocketInboundEndpoint.xml file from %pathToInboundEndpoints%
)
EXIT /B 0

:removeSynapseConfigs
rem ----removing directories if exists ----
for /f %%i in ('dir "%pathToSynapseConfigs%" /A:D /b') do (
	rmdir /s /q %pathToSynapseConfigs%\%%i
	call :Timestamp value
	echo %value% INFO - Removed the %%i directory from %pathToSynapseConfigs%
)
rem ----removing the files if exists ------
for /f %%i in ('dir "%pathToSynapseConfigs%" /A:-D /b ^| find /v "synapse.xml"') do (
	del /f %pathToSynapseConfigs%\%%i
	call :Timestamp value
	echo %value% INFO - Removed the %%i file from %pathToSynapseConfigs%
)
EXIT /B 0

:replaceAxis2File
if exist %pathToAxis2XML% (
	if exist %pathToAxis2TMXml% (
		ren %pathToAxis2XML% %axis2XMLBackup%
		call :Timestamp value
		echo %value% INFO - Rename the existing %pathToAxis2XML% file as %axis2XMLBackup%
		ren %pathToAxis2TMXml% %axis2XML%
		call :Timestamp value
		echo %value% INFO - Rename the existing %pathToAxis2TMXml% file as %axis2XML%
	)
)
EXIT /B 0

:replaceRegistryXMLFile
if exist %pathToRegistry% (
	if exist %pathToRegistryTM% (
        ren %pathToRegistry% %registryBackup%
        call :Timestamp value
        echo %value% INFO - Rename the existing %pathToRegistry% file as %registryBackup%
        ren  %pathToRegistryTM% %registryXML%
        call :Timestamp value
        echo %value% INFO - Rename the existing %pathToRegistryTM% file as %registryXML%
	)
)
EXIT /B 0

:replaceAxis2TemplateFile
if exist %pathToAxis2XMLTemplate% (
	if exist %pathToAxis2TMXmlTemplate% (
		ren %pathToAxis2XMLTemplate% %axis2XMLBackupTemplate%
		call :Timestamp value
		echo %value% INFO - Rename the existing %pathToAxis2XMLTemplate% file as %axis2XMLBackupTemplate%
		ren %pathToAxis2TMXmlTemplate% %pathToAxis2XMLTemplate%
		call :Timestamp value
		echo %value% INFO - Rename the existing %pathToAxis2TMXmlTemplate% file as %axis2XMLTemplate%
	)
)
EXIT /B 0

:replaceRegistryXMLTemplateFile
if exist %pathToRegistryTemplate% (
	if exist %pathToRegistryTMTemplate% (
        ren %pathToRegistryTemplate% %registryBackupTemplate%
        call :Timestamp value
        echo %value% INFO - Rename the existing %pathToRegistryTemplate% file as %registryBackupTemplate%
        ren  %pathToRegistryTM% %registryXMLTemplate%
        call :Timestamp value
        echo %value% INFO - Rename the existing %pathToRegistryTMTemplate% file as %registryXMLTemplate%
	)
)
EXIT /B 0

:Timestamp
set "%~1=[%date:~10,14%-%date:~4,2%-%date:~7,2% %time%]"
EXIT /B 0

:finishOptimization
echo Finished the optimizations
goto end

:end
cd /d %userLocation%

@echo off
rem ----------------------------------------------------------------------------
rem  Copyright 2018 WSO2, Inc. http://www.wso2.org
rem
rem  Licensed under the Apache License, Version 2.0 (the "License");
rem  you may not use this file except 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, software
rem  distributed under the License is distributed on an "AS IS" BASIS,
rem  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
rem  See the License for the specific language governing permissions and
rem  limitations under the License.

set userLocation=%cd%
set pathToAxis2XMLTemplate=..\repository\resources\conf\templates\repository\conf\axis2\axis2.xml.j2
set pathToRegistryTemplate=..\repository\resources\conf\templates\repository\conf\registry.xml.j2
set pathToInboundEndpoints=..\repository\deployment\server\synapse-configs\default\inbound-endpoints
set pathToWebapps=..\repository\deployment\server\webapps
set pathToJaggeryapps=..\repository\deployment\server\jaggeryapps
set pathToSynapseConfigs=..\repository\deployment\server\synapse-configs\default
set pathToAxis2TMXmlTemplate=..\repository\resources\conf\templates\repository\conf\axis2\axis2_TM.xml.j2
set pathToRegistryTMTemplate=..\repository\resources\conf\templates\repository\conf\registry_TM.xml.j2
set axis2XMLBackupTemplate=axis2.xml.j2.backup
set registryBackupTemplate=registry.xml.j2.backup
set axis2XMLTemplate=axis2.xml.j2
set registryXMLTemplate=registry.xml.j2

cd /d %~dp0

rem ----- Process the input commands (two args only)-------------------------------------------
if ""%1""==""-Dprofile"" (
	if ""%2""==""api-key-manager"" 	goto keyManager
	if ""%2""==""api-publisher"" 	goto publisher
	if ""%2""==""api-devportal"" 	goto devportal
	if ""%2""==""traffic-manager"" 	goto trafficManager
	if ""%2""==""gateway-worker"" 	goto gatewayWorker
)
echo Profile is not specified properly, please try again
goto end

:keyManager
echo Starting to optimize API Manager for the Key Manager profile
call :removeWebSocketInboundEndpoint
call :removeSecureWebSocketInboundEndpoint
call :removeSynapseConfigs
rem ---removing webbapps which are not required for this profile--------
for /f %%i in ('dir %pathToWebapps% /b ^| findstr /v "client-registration#v.*war authenticationendpoint accountrecoveryendpoint oauth2.war throttle#data#v.*war api#identity#consent-mgt#v.*war"') do (
	del /f %pathToWebapps%\%%i
	call :Timestamp value
	echo %value% INFO - Removed the %%i file from %pathToWebapps%
	setlocal enableDelayedExpansion
	set folderName=%%i
	set folderName=!folderName:.war=!
	if exist %pathToWebapps%\!folderName!\ (
		rmdir /s /q %pathToWebapps%\!folderName!
		call :Timestamp value
		echo %value% INFO - Removed the !folderName! directory from %pathToWebapps%
	)
	endlocal
)
rem ---removing jaggeryapps which are not required for this profile--------
for /f %%i in ('dir "%pathToJaggeryapps%" /A:D /b') do (
	rmdir /s /q %pathToJaggeryapps%\%%i
	call :Timestamp value
	echo %value% INFO - Removed the %%i directory from %pathToJaggeryapps%
)
goto finishOptimization

:publisher
echo Starting to optimize API Manager for the API Publisher profile
call :removeWebSocketInboundEndpoint
call :removeSecureWebSocketInboundEndpoint
rem ---removing webbapps which are not required for this profile--------
for /f %%i in ('dir %pathToWebapps% /b ^| findstr /v "api#am#publisher#v.*war api#am#publisher.war client-registration#v.*war authenticationendpoint accountrecoveryendpoint oauth2.war api#am#admin#v.*war"') do (
	del /f %pathToWebapps%\%%i
	call :Timestamp value
	echo %value% INFO - Removed the %%i file from %pathToWebapps%
	setlocal enableDelayedExpansion
	set folderName=%%i
	set folderName=!folderName:.war=!
	if exist %pathToWebapps%\!folderName!\ (
		rmdir /s /q %pathToWebapps%\!folderName!
		call :Timestamp value
		echo %value% INFO - Removed the !folderName! directory from %pathToWebapps%
	)
	endlocal
)
rem ---removing jaggeryapps which are not required for this profile--------
for /f %%i in ('dir "%pathToJaggeryapps%" /A:D /b ^| findstr /v "publisher admin"') do (
	rmdir /s /q %pathToJaggeryapps%\%%i
	call :Timestamp value
	echo %value% INFO - Removed the %%i directory from %pathToJaggeryapps%
)
goto finishOptimization

:devportal
echo Starting to optimize API Manager for the Developer Portal profile
call :removeWebSocketInboundEndpoint
call :removeSecureWebSocketInboundEndpoint
rem ---removing webbapps which are not required for this profile--------
for /f %%i in ('dir %pathToWebapps% /b ^| findstr /v "api#am#store#v.*war api#am#store.war client-registration#v.*war authenticationendpoint accountrecoveryendpoint oauth2.war api#am#admin#v.*war"') do (
	del /f %pathToWebapps%\%%i
	call :Timestamp value
	echo %value% INFO - Removed the %%i file from %pathToWebapps%
	setlocal enableDelayedExpansion
	set folderName=%%i
	set folderName=!folderName:.war=!
	if exist %pathToWebapps%\!folderName!\ (
		rmdir /s /q %pathToWebapps%\!folderName!
		call :Timestamp value
		echo %value% INFO - Removed the !folderName! directory from %pathToWebapps%
	)
	endlocal
)
rem ---removing jaggeryapps which are not required for this profile--------
for /f %%i in ('dir "%pathToJaggeryapps%" /A:D /b ^| findstr /v "devportal"') do (
	rmdir /s /q %pathToJaggeryapps%\%%i
	call :Timestamp value
	echo %value% INFO - Removed the %%i directory from %pathToJaggeryapps%
)
goto finishOptimization

:trafficManager
echo Starting to optimize API Manager for the Traffic Manager profile
call :replaceAxis2TemplateFile
call :replaceRegistryXMLTemplateFile
call :removeWebSocketInboundEndpoint
call :removeSecureWebSocketInboundEndpoint
call :removeSynapseConfigs
rem ---removing webbapps which are not required for this profile--------
for /f %%i in ('dir %pathToWebapps% /b') do (
	del /f %pathToWebapps%\%%i
	call :Timestamp value
	echo %value% INFO - Removed the %%i file from %pathToWebapps%
	setlocal enableDelayedExpansion
	set folderName=%%i
	set folderName=!folderName:.war=!
	if exist %pathToWebapps%\!folderName!\ (
		rmdir /s /q %pathToWebapps%\!folderName!
		call :Timestamp value
		echo %value% INFO - Removed the !folderName! directory from %pathToWebapps%
	)
	endlocal
)
rem ---removing jaggeryapps which are not required for this profile--------
for /f %%i in ('dir "%pathToJaggeryapps%" /A:D /b') do (
	rmdir /s /q %pathToJaggeryapps%\%%i
	call :Timestamp value
	echo %value% INFO - Removed the %%i directory from %pathToJaggeryapps%
)
goto finishOptimization

:gatewayWorker
echo Starting to optimize API Manager for the Gateway worker profile
rem ---removing webbapps which are not required for this profile--------
for /f %%i in ('dir %pathToWebapps% /b ^| findstr /v "am#sample#pizzashack#v.*war"') do (
	del /f %pathToWebapps%\%%i
	call :Timestamp value
	echo %value% INFO - Removed the %%i file from %pathToWebapps%
	setlocal enableDelayedExpansion
	set folderName=%%i
	set folderName=!folderName:.war=!
	if exist %pathToWebapps%\!folderName!\ (
		rmdir /s /q %pathToWebapps%\!folderName!
		call :Timestamp value
		echo %value% INFO - Removed the !folderName! directory from %pathToWebapps%
	)
	endlocal
)
rem ---removing jaggeryapps which are not required for this profile--------
for /f %%i in ('dir "%pathToJaggeryapps%" /A:D /b') do (
	rmdir /s /q %pathToJaggeryapps%\%%i
	call :Timestamp value
	echo %value% INFO - Removed the %%i directory from %pathToJaggeryapps%
)
goto finishOptimization

:removeWebSocketInboundEndpoint
if exist %pathToInboundEndpoints%\WebSocketInboundEndpoint.xml (
	del /f %pathToInboundEndpoints%\WebSocketInboundEndpoint.xml
	call :Timestamp value
	echo %value% INFO - Removed the WebSocketInboundEndpoint.xml file from %pathToInboundEndpoints%
)
EXIT /B 0

:removeSecureWebSocketInboundEndpoint
if exist %pathToInboundEndpoints%\SecureWebSocketInboundEndpoint.xml (
	del /f %pathToInboundEndpoints%\SecureWebSocketInboundEndpoint.xml
	call :Timestamp value
	echo %value% INFO - Removed the SecureWebSocketInboundEndpoint.xml file from %pathToInboundEndpoints%
)
EXIT /B 0

:removeSynapseConfigs
rem ----removing directories if exists ----
for /f %%i in ('dir "%pathToSynapseConfigs%" /A:D /b') do (
	rmdir /s /q %pathToSynapseConfigs%\%%i
	call :Timestamp value
	echo %value% INFO - Removed the %%i directory from %pathToSynapseConfigs%
)
rem ----removing the files if exists ------
for /f %%i in ('dir "%pathToSynapseConfigs%" /A:-D /b ^| find /v "synapse.xml"') do (
	del /f %pathToSynapseConfigs%\%%i
	call :Timestamp value
	echo %value% INFO - Removed the %%i file from %pathToSynapseConfigs%
)
EXIT /B 0

:replaceAxis2TemplateFile
if exist %pathToAxis2XMLTemplate% (
	if exist %pathToAxis2TMXmlTemplate% (
		ren %pathToAxis2XMLTemplate% %axis2XMLBackupTemplate%
		call :Timestamp value
		echo %value% INFO - Rename the existing %pathToAxis2XMLTemplate% file as %axis2XMLBackupTemplate%
		ren %pathToAxis2TMXmlTemplate% %pathToAxis2XMLTemplate%
		call :Timestamp value
		echo %value% INFO - Rename the existing %pathToAxis2TMXmlTemplate% file as %axis2XMLTemplate%
	)
)
EXIT /B 0

:replaceRegistryXMLTemplateFile
if exist %pathToRegistryTemplate% (
	if exist %pathToRegistryTMTemplate% (
        ren %pathToRegistryTemplate% %registryBackupTemplate%
        call :Timestamp value
        echo %value% INFO - Rename the existing %pathToRegistryTemplate% file as %registryBackupTemplate%
        ren  %pathToRegistryTMTemplate% %registryXMLTemplate%
        call :Timestamp value
        echo %value% INFO - Rename the existing %pathToRegistryTMTemplate% file as %registryXMLTemplate%
	)
)
EXIT /B 0

:Timestamp
set "%~1=[%date:~10,14%-%date:~4,2%-%date:~7,2% %time%]"
EXIT /B 0

:finishOptimization
echo Finished the optimizations
goto end

:end
cd /d %userLocation%

Remove redundant config file changes and replacements in profile optimization bat


@rem Copyright 2018 gRPC authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except 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, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.

@echo "Starting Windows build"

cd /d %~dp0
cd ..

call npm install -g npm@5 || goto :error

call npm install || goto :error
call npm run test || goto :error

goto :EOF

:error
exit /b 1

@rem Copyright 2018 Google LLC. All rights reserved.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except 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, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.

@echo "Starting Windows build"

cd /d %~dp0
cd ..

call npm install -g npm@latest || goto :error
call npm install || goto :error
call npm run test || goto :error

goto :EOF

:error
exit /b 1

use latest npm on Windows (#239)

chore: use latest npm on Windows (#239)


@rem Copyright 2018 Google LLC. All rights reserved.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except 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, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.

@echo "Starting Windows build"

cd /d %~dp0
cd ..

@rem The image we're currently running has a broken version of Node.js enabled
@rem by nvm (v10.15.3), which has no npm bin. This hack uses the functional
@rem Node v8.9.1 to install npm@latest, it then uses this version of npm to
@rem install npm for v10.15.3.
call nvm use v8.9.1 || goto :error
call node C:\Users\kbuilder\AppData\Roaming\nvm-ps\versions\v8.9.1\node_modules\npm-bootstrap\bin\npm-cli.js i npm -g || goto :error
call nvm use v10.15.3 || goto :error
call node C:\Users\kbuilder\AppData\Roaming\nvm-ps\versions\v8.9.1\node_modules\npm\bin\npm-cli.js i npm -g || goto :error

call npm install || goto :error
call npm run test || goto :error

goto :EOF

:error
exit /b 1

@rem Copyright 2018 Google LLC. All rights reserved.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except 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, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.

@echo "Starting Windows build"

cd /d %~dp0
cd ..

@rem npm path is not currently set in our image, we should fix this next time
@rem we upgrade Node.js in the image:
SET PATH=%PATH%;/cygdrive/c/Program Files/nodejs/npm

call nvm use v12.14.1
call which node

call npm install || goto :error
call npm run test || goto :error

goto :EOF

:error
exit /b 1

build: update windows configuration to match new vm


@REM
call bat_get_kam_folder.bat

@SET KMR_EXEs_ARCH=%kam_folder%_exes
@SET KMR_EXEs_ARCH_7Z=%KMR_EXEs_ARCH%.7z

@REM Recreate special KMR_EXEs_ARCH folder
rmdir /S /Q "%KMR_EXEs_ARCH%"
mkdir "%KMR_EXEs_ARCH%"

@REM rename and copy all exe's into KMR_EXEs_ARCH folder
@echo off
for /R "%kam_folder%" %%G in (*.exe) do (
	xcopy "%kam_folder%"\"%%~nG.exe" "%KMR_EXEs_ARCH%\%%~nG_r%kam_revision%.exe*" /y /r /s
)

REM ============================================================
REM Erase previous archive to make sure new one is made from scratch
REM ============================================================
erase /F /Q /S "%KMR_EXEs_ARCH_7Z%"

REM ============================================================
REM Create archive with all exe's
REM ============================================================
"C:\Program Files\7-Zip\7z.exe" a "%KMR_EXEs_ARCH_7Z%" "%KMR_EXEs_ARCH%"/*.exe

rmdir /S /Q "%KMR_EXEs_ARCH%"

add bat_7z_exe.bat

add bat_7z_exe.bat


@echo off

echo Copy Nitrogen WWW files into .\content\wwwroot\nitrogen
rmdir /s /q .\wwwroot\nitrogen
mkdir .\wwwroot\nitrogen
copy ..\www\* .\wwwroot\nitrogen

echo Starting Nitrogen on Inets...
erl -make
erl -name nitrogen@127.0.0.1 -pa apps ebin include -pa ..\ebin ..\include -eval "application:start(quickstart_inets)"

@echo off

echo Copy Nitrogen WWW files into .\content\wwwroot\nitrogen
rmdir /s /q .\wwwroot\nitrogen
mkdir .\wwwroot\nitrogen
copy ..\apps\nitrogen\www\* .\wwwroot\nitrogen

echo Compile dependencies...
cd ..\apps\nitrogen
erl -make
cd ..\simple_bridge
erl -make
cd ..\..\Quickstart

echo Starting Nitrogen on Inets...
erl -make
erl -name nitrogen@127.0.0.1 -pa apps ebin include ..\apps\nitrogen\ebin ..\apps\nitrogen\include ..\apps\simple_bridge\ebin ..\apps\simple_bridge\include -eval "application:start(quickstart_inets)"

Update quickstart.bat for new paths. I don't have a windows machine, so fingers crossed that this works!


REM Add other things if could be automated, RUN THIS AS ADMIN
REM Everything is added, including PowerShell command execution and "wget" lol
REM Admin checking...
@echo off
echo Checking if script contains Administrative rights...
net sessions
if %errorlevel%==0 (
echo Success!
) else (
echo No admin, please run with Administrative rights...
pause
exit
)
:MENU
echo Choose An option:
echo 1. Windows Defender Scan
echo 2. List Processes
echo 3. Changing Password Policies
echo 4. Enable UAC
echo 5. Disable Remote Desktop
echo 6. Enable Auto-Update
echo 7. Disable Weak services
echo 8. System Integrity Scan
echo 9. Powershell rootkit detection
echo 10. Check startup processes

CHOICE /C 123456789 /M "Enter your choice:"
if ERRORLEVEL 10 goto Ten
if ERRORLEVEL 9 goto Nine
if ERRORLEVEL 8 goto Eight
if ERRORLEVEL 7 goto Seven
if ERRORLEVEL 6 goto Six
if ERRORLEVEL 5 goto Five
if ERRORLEVEL 4 goto Four
if ERRORLEVEL 3 goto Three
if ERRORLEVEL 2 goto Two
if ERRORLEVEL 1 goto One
:One
REM Windows Defender scan
echo "SCANNING WITH DEFAULT WINDOWS DEFENDER!"
cd C:\Program Files\Windows Defender\
MpCmdRun.exe -Scan 2
cd C:\
goto MENU
:Two
REM Listing possible penetrations
cd C:\
echo "STARTING TO OUTPUT PROCESS FILES DIRECTLY TO THE C:\ DRIVE!"
wmic process list brief > BriefProcesses.txt
if %errorlevel%==1 echo Brief Processes failed to write
wmic process list full >FullProcesses.txt
if %errorlevel%==1 echo Full Processes failed to write
wmic startup list full > StartupLists.txt
if %errorlevel%==1 echo Startup Processes failed to write
net start > StartedProcesses.txt
if %errorlevel%==1 echo Started processes failed to write
reg export HKLM\Software\Microsoft\Windows\CurrentVersion\Run  Run.reg
if %errorlevel%==1 echo Run processes failed to write
goto MENU
:Three
echo "OUTPUT DONE, CHANGING PASSWORD POLICIES!"
REM Passwords must be 10 digits
net accounts /minpwlen:10
REM Passwords must be changed every 30 days
net accounts /maxpwage:30
REM Passwords can only be changed after 1 day has passed
net accounts /minpwage:1
REM Display current password policy
echo "CURRENT POLICY"
PAUSE
net accounts
goto MENU
:Four
REM Turn on UAC
echo "TURNING ON UAC"
reg add HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System /v EnableLUA /t REG_DWORD /d 1 /f
goto MENU
:Five
REM No Remote Desktop
echo "DISABLING REMOTE DESKTOP"
reg add "HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server" /v fDenyTSConnections /t REG_DWORD /d 1 /f
reg add "HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp" /v UserAuthentication /t REG_DWORD /d 0 /f
goto MENU
:Six
REM Windows auomatic updates
echo "ENABLING AUTO-UPDATES"
reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update" /v AUOptions /t REG_DWORD /d 3 /f
goto MENU
:Seven
REM Removing good ol' insecure stuff
echo "DISABLING WEAK SERVICES"
dism /online /disable-feature /featurename:IIS-WebServerRole >NUL
dism /online /disable-feature /featurename:IIS-WebServer >NUL
dism /online /disable-feature /featurename:IIS-CommonHttpFeatures >NUL
dism /online /disable-feature /featurename:IIS-HttpErrors >NUL
dism /online /disable-feature /featurename:IIS-HttpRedirect >NUL
dism /online /disable-feature /featurename:IIS-ApplicationDevelopment >NUL
dism /online /disable-feature /featurename:IIS-NetFxExtensibility >NUL
dism /online /disable-feature /featurename:IIS-NetFxExtensibility45 >NUL
dism /online /disable-feature /featurename:IIS-HealthAndDiagnostics >NUL
dism /online /disable-feature /featurename:IIS-HttpLogging >NUL
dism /online /disable-feature /featurename:IIS-LoggingLibraries >NUL
dism /online /disable-feature /featurename:IIS-RequestMonitor >NUL
dism /online /disable-feature /featurename:IIS-HttpTracing >NUL
dism /online /disable-feature /featurename:IIS-Security >NUL
dism /online /disable-feature /featurename:IIS-URLAuthorization >NUL
dism /online /disable-feature /featurename:IIS-RequestFiltering >NUL
dism /online /disable-feature /featurename:IIS-IPSecurity >NUL
dism /online /disable-feature /featurename:IIS-Performance >NUL
dism /online /disable-feature /featurename:IIS-HttpCompressionDynamic >NUL
dism /online /disable-feature /featurename:IIS-WebServerManagementTools >NUL
dism /online /disable-feature /featurename:IIS-ManagementScriptingTools >NUL
dism /online /disable-feature /featurename:IIS-IIS6ManagementCompatibility >NUL
dism /online /disable-feature /featurename:IIS-Metabase >NUL
dism /online /disable-feature /featurename:IIS-HostableWebCore >NUL
dism /online /disable-feature /featurename:IIS-StaticContent >NUL
dism /online /disable-feature /featurename:IIS-DefaultDocument >NUL
dism /online /disable-feature /featurename:IIS-DirectoryBrowsing >NUL
dism /online /disable-feature /featurename:IIS-WebDAV >NUL
dism /online /disable-feature /featurename:IIS-WebSockets >NUL
dism /online /disable-feature /featurename:IIS-ApplicationInit >NUL
dism /online /disable-feature /featurename:IIS-ASPNET >NUL
dism /online /disable-feature /featurename:IIS-ASPNET45 >NUL
dism /online /disable-feature /featurename:IIS-ASP >NUL
dism /online /disable-feature /featurename:IIS-CGI >NUL
dism /online /disable-feature /featurename:IIS-ISAPIExtensions >NUL
dism /online /disable-feature /featurename:IIS-ISAPIFilter >NUL
dism /online /disable-feature /featurename:IIS-ServerSideIncludes >NUL
dism /online /disable-feature /featurename:IIS-CustomLogging >NUL
dism /online /disable-feature /featurename:IIS-BasicAuthentication >NUL
dism /online /disable-feature /featurename:IIS-HttpCompressionStatic >NUL
dism /online /disable-feature /featurename:IIS-ManagementConsole >NUL
dism /online /disable-feature /featurename:IIS-ManagementService >NUL
dism /online /disable-feature /featurename:IIS-WMICompatibility >NUL
dism /online /disable-feature /featurename:IIS-LegacyScripts >NUL
dism /online /disable-feature /featurename:IIS-LegacySnapIn >NUL
dism /online /disable-feature /featurename:IIS-FTPServer >NUL
dism /online /disable-feature /featurename:IIS-FTPSvc >NUL
dism /online /disable-feature /featurename:IIS-FTPExtensibility >NUL
dism /online /disable-feature /featurename:TFTP >NUL
dism /online /disable-feature /featurename:TelnetClient >NUL
dism /online /disable-feature /featurename:TelnetServer >NUL
goto MENU
:Eight
REM START SYS INTEG SCAN!
echo "STARTING SYSTEM INTERGRITY SCAN"
Sfc.exe /scannow
goto MENU
:Nine
REM PowerShell RootKit detection start
echo "POWERSHELL ROOTKIT DETECTION WITH MALWAREBYTES ROOTKIT BETA"
powershell Invoke-WebRequest -OutFile MBRTKit.exe https://data-cdn.mbamupdates.com/web/mbar-1.09.3.1001.exe
MBRTKit.exe
goto MENU
:Ten
powershell Get-CimInstance Win32_StartupCommand | Select-Object Name, command, Location, User | Format-List
pause
goto MENU
PAUSE

REM Add other things if could be automated, RUN THIS AS ADMIN
REM Everything is added, including PowerShell command execution and "wget" lol
REM Admin checking...
@echo off
echo Checking if script contains Administrative rights...
net sessions
if %errorlevel%==0 (
echo Success!
) else (
echo No admin, please run with Administrative rights...
pause
exit
)
:MENU
echo Choose An option:
echo 1. Windows Defender Scan
echo 2. List Processes
echo 3. Changing Password Policies
echo 4. Enable UAC
echo 5. Disable Remote Desktop
echo 6. Enable Auto-Update
echo 7. Disable Weak services
echo 8. System Integrity Scan
echo 9. Powershell rootkit detection
echo 10. Check startup processes

CHOICE /C 123456789 /M "Enter your choice:"
if ERRORLEVEL 10 goto Ten
if ERRORLEVEL 9 goto Nine
if ERRORLEVEL 8 goto Eight
if ERRORLEVEL 7 goto Seven
if ERRORLEVEL 6 goto Six
if ERRORLEVEL 5 goto Five
if ERRORLEVEL 4 goto Four
if ERRORLEVEL 3 goto Three
if ERRORLEVEL 2 goto Two
if ERRORLEVEL 1 goto One
:One
REM Windows Defender scan
echo "SCANNING WITH DEFAULT WINDOWS DEFENDER!"
cd C:\Program Files\Windows Defender\
MpCmdRun.exe -Scan 2
cd C:\
goto MENU
:Two
REM Listing possible penetrations
cd C:\
echo "STARTING TO OUTPUT PROCESS FILES DIRECTLY TO THE C:\ DRIVE!"
wmic process list brief > BriefProcesses.txt
if %errorlevel%==1 echo Brief Processes failed to write
wmic process list full >FullProcesses.txt
if %errorlevel%==1 echo Full Processes failed to write
wmic startup list full > StartupLists.txt
if %errorlevel%==1 echo Startup Processes failed to write
net start > StartedProcesses.txt
if %errorlevel%==1 echo Started processes failed to write
reg export HKLM\Software\Microsoft\Windows\CurrentVersion\Run  Run.reg
if %errorlevel%==1 echo Run processes failed to write
goto MENU
:Three
echo "OUTPUT DONE, CHANGING PASSWORD POLICIES!"
REM Passwords must be 10 digits
net accounts /minpwlen:10
REM Passwords must be changed every 30 days
net accounts /maxpwage:30
REM Passwords can only be changed after 1 day has passed
net accounts /minpwage:1
REM Display current password policy
echo "CURRENT POLICY"
PAUSE
net accounts
goto MENU
:Four
REM Turn on UAC
echo "TURNING ON UAC"
reg add HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System /v EnableLUA /t REG_DWORD /d 1 /f
goto MENU
:Five
REM No Remote Desktop
echo "DISABLING REMOTE DESKTOP"
reg add "HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server" /v fDenyTSConnections /t REG_DWORD /d 1 /f
reg add "HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp" /v UserAuthentication /t REG_DWORD /d 0 /f
goto MENU
:Six
REM Windows auomatic updates
echo "ENABLING AUTO-UPDATES"
reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update" /v AUOptions /t REG_DWORD /d 3 /f
goto MENU
:Seven
REM Removing good ol' insecure stuff
echo "DISABLING WEAK SERVICES"
dism /online /disable-feature /featurename:IIS-WebServerRole
dism /online /disable-feature /featurename:IIS-WebServer
dism /online /disable-feature /featurename:IIS-CommonHttpFeatures
dism /online /disable-feature /featurename:IIS-HttpErrors
dism /online /disable-feature /featurename:IIS-HttpRedirect
dism /online /disable-feature /featurename:IIS-ApplicationDevelopment
dism /online /disable-feature /featurename:IIS-NetFxExtensibility
dism /online /disable-feature /featurename:IIS-NetFxExtensibility45
dism /online /disable-feature /featurename:IIS-HealthAndDiagnostics
dism /online /disable-feature /featurename:IIS-HttpLogging
dism /online /disable-feature /featurename:IIS-LoggingLibraries
dism /online /disable-feature /featurename:IIS-RequestMonitor
dism /online /disable-feature /featurename:IIS-HttpTracing
dism /online /disable-feature /featurename:IIS-Security
dism /online /disable-feature /featurename:IIS-URLAuthorization
dism /online /disable-feature /featurename:IIS-RequestFiltering
dism /online /disable-feature /featurename:IIS-IPSecurity
dism /online /disable-feature /featurename:IIS-Performance
dism /online /disable-feature /featurename:IIS-HttpCompressionDynamic
dism /online /disable-feature /featurename:IIS-WebServerManagementTools
dism /online /disable-feature /featurename:IIS-ManagementScriptingTools
dism /online /disable-feature /featurename:IIS-IIS6ManagementCompatibility
dism /online /disable-feature /featurename:IIS-Metabase
dism /online /disable-feature /featurename:IIS-HostableWebCore
dism /online /disable-feature /featurename:IIS-StaticContent
dism /online /disable-feature /featurename:IIS-DefaultDocument
dism /online /disable-feature /featurename:IIS-DirectoryBrowsing
dism /online /disable-feature /featurename:IIS-WebDAV
dism /online /disable-feature /featurename:IIS-WebSockets
dism /online /disable-feature /featurename:IIS-ApplicationInit
dism /online /disable-feature /featurename:IIS-ASPNET
dism /online /disable-feature /featurename:IIS-ASPNET45
dism /online /disable-feature /featurename:IIS-ASP
dism /online /disable-feature /featurename:IIS-CGI
dism /online /disable-feature /featurename:IIS-ISAPIExtensions
dism /online /disable-feature /featurename:IIS-ISAPIFilter
dism /online /disable-feature /featurename:IIS-ServerSideIncludes
dism /online /disable-feature /featurename:IIS-CustomLogging
dism /online /disable-feature /featurename:IIS-BasicAuthentication
dism /online /disable-feature /featurename:IIS-HttpCompressionStatic
dism /online /disable-feature /featurename:IIS-ManagementConsole
dism /online /disable-feature /featurename:IIS-ManagementService
dism /online /disable-feature /featurename:IIS-WMICompatibility
dism /online /disable-feature /featurename:IIS-LegacyScripts
dism /online /disable-feature /featurename:IIS-LegacySnapIn
dism /online /disable-feature /featurename:IIS-FTPServer
dism /online /disable-feature /featurename:IIS-FTPSvc
dism /online /disable-feature /featurename:IIS-FTPExtensibility
dism /online /disable-feature /featurename:TFTP
dism /online /disable-feature /featurename:TelnetClient
dism /online /disable-feature /featurename:TelnetServer
goto MENU
:Eight
REM START SYS INTEG SCAN!
echo "STARTING SYSTEM INTERGRITY SCAN"
Sfc.exe /scannow
goto MENU
:Nine
REM PowerShell RootKit detection start
echo "POWERSHELL ROOTKIT DETECTION WITH MALWAREBYTES ROOTKIT BETA"
powershell Invoke-WebRequest -OutFile MBRTKit.exe https://data-cdn.mbamupdates.com/web/mbar-1.09.3.1001.exe
MBRTKit.exe
goto MENU
:Ten
powershell Get-CimInstance Win32_StartupCommand | Select-Object Name, command, Location, User | Format-List
pause
goto MENU
PAUSE

Update Main.bat

Update Main.bat


@echo off
cls
:start
echo Starting server...

"Nomad Server\NomadServer.exe" -name "My Oxide Server" -port 5127 -slots 10 -clientVersion "0.607" -password "" -tcpLobby "149.202.51.185" 25565

echo.
echo Restarting server...
echo.
goto start

@echo off
cls
:start
echo Starting server...

"Nomad Server\NomadServer.exe" -name "My Oxide Server" -port 5127 -slots 10 -clientVersion "0.608" -password "" -tcpLobby "149.202.51.185" 25565

echo.
echo Restarting server...
echo.
goto start

Patch for version 0.608 update

[Nomad] Patch for version 0.608 update


REM This script is for getting and building the 3rd party libraries that the MEGA SDK uses (some are optional, and some are only needed only by MEGA apps too)
REM
REM Your 3rdParty library builds should be outside the SDK repo.  We are moving to use vcpkg to build most of them. You can start it like this:
REM
REM mkdir 3rdParty
REM cd 3rdParty
REM git clone https://github.com/Microsoft/vcpkg.git
REM cd vcpkg
REM .\bootstrap-vcpkg.bat
REM
REM Note that our current toolset for XP compatibility (which we had but we are deprecating), is VS2015 with v140 or v140_xp.
REM The triplet files ending -mega set v140, please adjust to your requirements.
REM
REM Another thing you might want to consider for developing, is turning off checked iterators in MSVC builds, since those extra tests can cause big delays
REM in debug (eg. deleting the node tree on logout etc).  You can do that by setting set(VCPKG_CXX_FLAGS "${VCPKG_CXX_FLAGS} -D_ITERATOR_DEBUG_LEVEL=0")
REM in your triplet file, though every library used must have that same setting.
REM
REM Another way is to edit the STL headers first, which can ensure that nested builds get the right flag.
REM
REM Copy the folders in contrib/cmake/vcpkg_extra_ports to your 3rdParty/vcpkg/ports folder.
REM Copy the folders in contrib/cmake/vcpkg_extra_triplets to your 3rdParty/vcpkg/triplets folder.
REM
REM Comment out any libraries that you won't use.
REM If using pdfium, follow the instructions below to get the source code
REM
REM Copy this script to your 3rdParty/vcpkg folder, and run it with the desired triplet as the parameter.  (usually x64-windows-mega or x86-windows-mega)

set TRIPLET=%1%

CALL :build_one zlib
CALL :build_one cryptopp
CALL :build_one libsodium
CALL :build_one sqlite3
CALL :build_one openssl
CALL :build_one c-ares
CALL :build_one curl
CALL :build_one libevent
CALL :build_one libzen
CALL :build_one libmediainfo
CALL :build_one ffmpeg
CALL :build_one gtest

REM freeimage is not needed for MEGASync (but might be for other projects)
REM CALL :build_one freeimage

REM MEGASync needs libuv and libraw
CALL :build_one libuv
CALL :build_one libraw

REM MEGASync needs pdfium, and building it is quite tricky - we can build it statically though with its own CMakeLists.txt after getting the code per their instructions.
REM It in turn depends on these libs which are easier to build with vcpkg as part of our compatible static library set than as part of its own third_party dependencies
CALL :build_one icu
CALL :build_one lcms
CALL :build_one libjpeg-turbo
CALL :build_one openjpeg

REM If building something that depends on MEGAchat you will also need libwebsockets:
CALL :build_one libwebsockets

REM ------ building pdifum - this one needs some manual steps - these can be done before calling the script ---------------
REM - Set up your Depot Tools (this can be one time, reuse it for other builds etc)
REM      Follow these instructions to get the depot_tools (download .zip, extract all, set variable, run gclient): https://chromium.googlesource.com/chromium/src/+/master/docs/windows_build_instructions.md#install
REM - Then in your 3rdParty/vcpkg folder (make sure it is not a long path, or subst V: to it), and run these commands in it to get the pdfium source:
REM      set DEPOT_TOOLS=<<<<your depot_tools path>>>>
REM      set PATH=%DEPOT_TOOLS%;%PATH%
REM      set DEPOT_TOOLS_WIN_TOOLCHAIN=0
REM      mkdir pdfium
REM      cd pdfium
REM      gclient config --unmanaged https://pdfium.googlesource.com/pdfium.git
REM      gclient sync
REM      REM branch 3710 is compatibile with the VS 2015 compiler and v140 toolset  (or if you want to use the latest, see below)
REM      cd pdfium
REM      git checkout chromium/3710
REM      cd ..
REM      gclient sync --force
REM - If using VS2015 compiler, find span.h and remove 'constexpr' from all the forwarding constructors.
REM - If using the latest Pdfium, use at least VS2017 and skip the branch checkout above, and substitute the pdfium-masterbranch-CMakeLists.txt in vcpkg/ports/pdfium and make this one small patch (other changes may be needed if the master branch has changed):
REM      in pdfium\core\fxcrt\fx_memory_wrappers.h(26)   comment out the static_assert (uint8_t counts as an arithmentic type)

CALL :build_one pdfium
CALL :build_one pdfium-freetype

exit /b 0

:build_one
.\vcpkg.exe install --triplet %TRIPLET% %1%
echo %errorlevel% %1% %TRIPLET% >> buildlog
exit /b 0

REM This script is for getting and building the 3rd party libraries that the MEGA SDK uses (some are optional, and some are only needed only by MEGA apps too)
REM
REM Your 3rdParty library builds should be outside the SDK repo.  We are moving to use vcpkg to build most of them. You can start it like this:
REM
REM mkdir 3rdParty
REM cd 3rdParty
REM git clone https://github.com/Microsoft/vcpkg.git
REM cd vcpkg
REM .\bootstrap-vcpkg.bat
REM
REM Note that our current toolset for XP compatibility (which we had but we are deprecating), is VS2015 with v140 or v140_xp.
REM The triplet files ending -mega set v140, please adjust to your requirements.
REM
REM Another thing you might want to consider for developing, is turning off checked iterators in MSVC builds, since those extra tests can cause big delays
REM in debug (eg. deleting the node tree on logout etc).  You can do that by setting set(VCPKG_CXX_FLAGS "${VCPKG_CXX_FLAGS} -D_ITERATOR_DEBUG_LEVEL=0")
REM in your triplet file, though every library used must have that same setting.
REM
REM Another way is to edit the STL headers first, which can ensure that nested builds get the right flag.
REM
REM Copy the folders in contrib/cmake/vcpkg_extra_ports to your 3rdParty/vcpkg/ports folder.
REM Copy the folders in contrib/cmake/vcpkg_extra_triplets to your 3rdParty/vcpkg/triplets folder.
REM
REM Comment out any libraries that you won't use.
REM If using pdfium, follow the instructions below to get the source code
REM
REM Copy this script to your 3rdParty/vcpkg folder, and run it with the desired triplet as the parameter.  (usually x64-windows-mega or x86-windows-mega)
REM
REM Once built, optionally capture just the headers and build products with:
REM vcpkg  export --triplet <YOUR_TRIPLET> --zip zlib cryptopp libsodium sqlite3 openssl c-ares curl libevent libzen libmediainfo ffmpeg gtest libuv libraw icu lcms libjpeg-turbo openjpeg libwebsockets pdfium pdfium-freetype

set TRIPLET=%1%

CALL :build_one zlib
CALL :build_one cryptopp
CALL :build_one libsodium
CALL :build_one sqlite3
CALL :build_one openssl
CALL :build_one c-ares
CALL :build_one curl
CALL :build_one libevent
CALL :build_one libzen
CALL :build_one libmediainfo
CALL :build_one ffmpeg
CALL :build_one gtest

REM freeimage is not needed for MEGASync (but might be for other projects)
REM CALL :build_one freeimage

REM MEGASync needs libuv and libraw
CALL :build_one libuv
CALL :build_one libraw

REM MEGASync needs pdfium, and building it is quite tricky - we can build it statically though with its own CMakeLists.txt after getting the code per their instructions.
REM It in turn depends on these libs which are easier to build with vcpkg as part of our compatible static library set than as part of its own third_party dependencies
CALL :build_one icu
CALL :build_one lcms
CALL :build_one libjpeg-turbo
CALL :build_one openjpeg

REM If building something that depends on MEGAchat you will also need libwebsockets:
CALL :build_one libwebsockets

REM ------ building pdifum - this one needs some manual steps - these can be done before calling the script ---------------
REM - Set up your Depot Tools (this can be one time, reuse it for other builds etc)
REM      Follow these instructions to get the depot_tools (download .zip, extract all, set variable, run gclient): https://chromium.googlesource.com/chromium/src/+/master/docs/windows_build_instructions.md#install
REM - Then in your 3rdParty/vcpkg folder (make sure it is not a long path, or subst V: to it), and run these commands in it to get the pdfium source:
REM      set DEPOT_TOOLS=<<<<your depot_tools path>>>>
REM      set PATH=%DEPOT_TOOLS%;%PATH%
REM      set DEPOT_TOOLS_WIN_TOOLCHAIN=0
REM      mkdir pdfium
REM      cd pdfium
REM      gclient config --unmanaged https://pdfium.googlesource.com/pdfium.git
REM      gclient sync
REM      REM branch 3710 is compatibile with the VS 2015 compiler and v140 toolset  (or if you want to use the latest, see below)
REM      cd pdfium
REM      git checkout chromium/3710
REM      cd ..
REM      gclient sync --force
REM - If using VS2015 compiler, find span.h and remove 'constexpr' from all the forwarding constructors.
REM - If using the latest Pdfium, use at least VS2017 and skip the branch checkout above, and substitute the pdfium-masterbranch-CMakeLists.txt in vcpkg/ports/pdfium and make this one small patch (other changes may be needed if the master branch has changed):
REM      in pdfium\core\fxcrt\fx_memory_wrappers.h(26)   comment out the static_assert (uint8_t counts as an arithmentic type)

CALL :build_one pdfium
CALL :build_one pdfium-freetype

exit /b 0

:build_one
.\vcpkg.exe install --triplet %TRIPLET% %1%
echo %errorlevel% %1% %TRIPLET% >> buildlog
exit /b 0

Add an export command example in comments

Which can be used to wrap up the minimal file set to build against, just the headers, libs, pdbs, DLLs etc.


# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements.  See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License.  You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

apache-incubator-servicecomb-service-center.exe

:: Licensed to the Apache Software Foundation (ASF) under one or more
:: contributor license agreements.  See the NOTICE file distributed with
:: this work for additional information regarding copyright ownership.
:: The ASF licenses this file to You under the Apache License, Version 2.0
:: (the "License"); you may not use this file except in compliance with
:: the License.  You may obtain a copy of the License at
::
::     http://www.apache.org/licenses/LICENSE-2.0
::
:: Unless required by applicable law or agreed to in writing, software
:: distributed under the License is distributed on an "AS IS" BASIS,
:: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
:: See the License for the specific language governing permissions and
:: limitations under the License.

apache-incubator-servicecomb-service-center.exe

Update Start Scripts

Update Start Scripts


@echo off
PATH=%PATH%;c:\Python27;c:\Python26

mkdir tmp

echo Generating APL...
python util/build_apl.py src\presentation_layer.json > tmp\apl.build

echo Generating docs...
python util/build_doc.py src\presentation_layer.json > OPTIONS.md

echo Assembling template...
python util\build_tmpl.py "%cd%" "%1"

del tmp\apl.build
del tmp\asm.build
rmdir tmp

@echo off
PATH=%PATH%;c:\Python27;c:\Python26

mkdir tmp

echo Generating APL...
python util/build_apl.py src\presentation_layer.json > tmp\apl.build

echo Generating docs...
python util/build_doc.py src\presentation_layer.json > OPTIONS.md

echo Assembling template...
python util\build_tmpl.py "%cd%" "%1"

del tmp\apl.build
del tmp\asm.build
del tmp\irules.build

rmdir tmp

Update build.bat

Update build.bat

Small fix to remove temp file


@echo off
cls
if not exist tools\FAKE\tools\Fake.exe (
  src\.nuget\nuget.exe install FAKE -OutputDirectory tools -ExcludeVersion -Prerelease
)
tools\FAKE\tools\Fake.exe build.fsx %* "logfile=build-log.xml"
pause

Create build.bat

Create build.bat


@echo off
setlocal EnableDelayedExpansion
set R2_BASE=""
if %PLATFORM% == x64 (set frida_os_arch=x86_64) else (set frida_os_arch=x86)
for /f %%i in ('radare2 -H R2_USER_PLUGINS') do set R2_PLUGDIR=%%i
for /f %%i in ('where radare2') do set R2_BASE=%%i\..\..
set DEBUG=/O2
set INSTALL=

if not exist %R2_BASE% (
	echo radare2 not found
	set /p R2_BASE="Please enter full path of radare2 installation: "
	set /p R2_PLUGDIR="Please enter full path of radare2 plugin dir (radare2 -H): "
)

set R2_INC=/I"%R2_BASE%\include" /I"%R2_BASE%\include\libr"

for %%i in (%*) do (
	if "%%i"=="debug" (set DEBUG=/Z7)
	if "%%i"=="install" (set INSTALL=1)
)

call npm install
cd src
cat .\_agent.js | xxd -i > .\_agent.h || (echo "xxd not in path?" & exit /b 1)

mkdir frida > nul 2>&1
cd frida

set frida_version=12.10.0
set FRIDA_SDK_URL="https://github.com/frida/frida/releases/download/%frida_version%/frida-core-devkit-%frida_version%-windows-%frida_os_arch%.exe"

if not exist ".\frida-core-sdk-%frida_version%-%frida_os_arch%.exe" (
	echo Downloading Frida Core Sdk

	powershell -command "(New-Object System.Net.WebClient).DownloadFile($env:FRIDA_SDK_URL, ""frida-core-sdk.exe-%frida_version%-%frida_os_arch%"")" ^
	|| wget -q --show-progress %FRIDA_SDK_URL% .\frida-core-sdk.exe -O .\frida-core-sdk-%frida_version%-%frida_os_arch%.exe

	echo Extracting...
	.\frida-core-sdk-%frida_version%-%frida_os_arch%.exe || (echo Failed to extract & exit /b 1)
)
cd ..

echo Compiling...
cl %DEBUG% /MT /nologo /LD /Gy /D_USRDLL /D_WINDLL /DWITH_CYLANG=0 io_frida.c %R2_INC% /I"%cd%" /I"%cd%\frida" "%cd%\frida\frida-core.lib" "%R2_BASE%\lib\*.lib" || (echo Compilation Failed & exit /b 1)

if not "%INSTALL%"=="" (
	echo Installing...
	mkdir "%R2_PLUGDIR%" > nul 2>&1
	echo Copying 'io_frida.dll' to %R2_PLUGDIR%
	cp io_frida.dll "%R2_PLUGDIR%\io_frida.dll"
	if not "%DEBUG%"=="/O2" (
		echo Copying 'io_frida.pdb' to %R2_PLUGDIR%
		cp io_frida.pdb "%R2_PLUGDIR%\io_frida.pdb"
	)
)

@echo off
setlocal EnableDelayedExpansion
set R2_BASE=""
if "%PLATFORM%" == "x64" (set frida_os_arch=x86_64) else (set frida_os_arch=x86)
for /f %%i in ('radare2 -H R2_USER_PLUGINS') do set R2_PLUGDIR=%%i
for /f %%i in ('where radare2') do set R2_BASE=%%i\..\..
set DEBUG=/O2
set INSTALL=

if not exist %R2_BASE% (
	echo radare2 not found
	set /p R2_BASE="Please enter full path of radare2 installation: "
	set /p R2_PLUGDIR="Please enter full path of radare2 plugin dir (radare2 -H): "
)

set R2_INC=/I"%R2_BASE%\include" /I"%R2_BASE%\include\libr"

for %%i in (%*) do (
	if "%%i"=="debug" (set DEBUG=/Z7)
	if "%%i"=="install" (set INSTALL=1)
)

call npm install
cd src
cat .\_agent.js | xxd -i > .\_agent.h || (echo "xxd not in path?" & exit /b 1)

mkdir frida > nul 2>&1
cd frida

set frida_version=12.10.0
set FRIDA_SDK_URL="https://github.com/frida/frida/releases/download/%frida_version%/frida-core-devkit-%frida_version%-windows-%frida_os_arch%.exe"

if not exist ".\frida-core-sdk-%frida_version%-%frida_os_arch%.exe" (
	echo Downloading Frida Core Sdk

	powershell -command "(New-Object System.Net.WebClient).DownloadFile($env:FRIDA_SDK_URL, ""frida-core-sdk.exe-%frida_version%-%frida_os_arch%"")" ^
	|| wget -q --show-progress %FRIDA_SDK_URL% .\frida-core-sdk.exe -O .\frida-core-sdk-%frida_version%-%frida_os_arch%.exe

	echo Extracting...
	.\frida-core-sdk-%frida_version%-%frida_os_arch%.exe || (echo Failed to extract & exit /b 1)
)
cd ..

echo Compiling...
cl %DEBUG% /MT /nologo /LD /Gy /D_USRDLL /D_WINDLL /DWITH_CYLANG=0 io_frida.c %R2_INC% /I"%cd%" /I"%cd%\frida" "%cd%\frida\frida-core.lib" "%R2_BASE%\lib\*.lib" || (echo Compilation Failed & exit /b 1)

if not "%INSTALL%"=="" (
	echo Installing...
	mkdir "%R2_PLUGDIR%" > nul 2>&1
	echo Copying 'io_frida.dll' to %R2_PLUGDIR%
	cp io_frida.dll "%R2_PLUGDIR%\io_frida.dll"
	if not "%DEBUG%"=="/O2" (
		echo Copying 'io_frida.pdb' to %R2_PLUGDIR%
		cp io_frida.pdb "%R2_PLUGDIR%\io_frida.pdb"
	)
)

Fix "(set was unexpected at this time." error


@echo off

setlocal

call project.bat

if exist %PROJECT%\bin rd /s /q %PROJECT%\bin
if errorlevel 1 goto error

nuget restore
if errorlevel 1 goto error

msbuild %PROJECT%.sln /target:Clean,Rebuild /p:Configuration=Debug
if errorlevel 1 goto error

set TESTDLL=%PROJECT%.Tests\bin\Debug\%PROJECT%.Tests.dll
if exist "%TESTDLL%" nunit3-console "%TESTDLL%"
if errorlevel 1 goto error

exit /B 0

:error
exit /B 1

@echo off

setlocal

set CONFIGURATION=Debug
if not "%1" == "" set CONFIGURATION=%1

call project.bat

if exist %PROJECT%\bin rd /s /q %PROJECT%\bin
if errorlevel 1 goto error

nuget restore
if errorlevel 1 goto error

msbuild %PROJECT%.sln /target:Clean,Rebuild /p:Configuration=%CONFIGURATION%
if errorlevel 1 goto error

set TESTDLL=%PROJECT%.Tests\bin\%CONFIGURATION%\%PROJECT%.Tests.dll
if exist "%TESTDLL%" nunit3-console "%TESTDLL%"
if errorlevel 1 goto error

exit /B 0

:error
exit /B 1

Build batch file now accepts parameter to build Release target


@ECHO OFF
IF "%1"=="" (SET TARGET_DOTNET=35) ELSE (SET TARGET_DOTNET=%1)

IF NOT EXIST gen MKDIR gen
IF NOT EXIST bin MKDIR bin
DEL /Q bin\*.*
DEL /Q gen\*.*

ECHO Generating resources...
tools\ResGen.exe resources\Help.resx gen\HFMCmd.Resource.Help.resources /str:cs,HFMCmd.Resource,Help,gen\HelpResource.cs
tools\ResGen.exe resources\CommandLine.resx gen\CommandLine.Resource.resources /str:cs,CommandLine,Resource,gen\CommandLineResource.cs
IF ERRORLEVEL 1 EXIT /B %ERRORLEVEL%

IF %TARGET_DOTNET%==35 GOTO DOTNET35
IF %TARGET_DOTNET%==40 GOTO DOTNET40

ECHO Usage: build.bat *Version*, where *Version* is one of: 35 or 40 (default is 35)
EXIT /B 99

:DOTNET35
ECHO Targeting .NET Framework 3.5...
SET DOTNET=C:\WINDOWS\Microsoft.NET\Framework\v3.5
SET HFM_LIB=lib\hfm-11.1.2.2
SET LOG4NET_LIB=lib\log4net-1.2.11\bin\net\3.5\release

ECHO Compiling HFMCmd...
%DOTNET%\csc.exe /nologo /target:exe /main:HFMCmd.Launcher /out:gen\HFMCmd.exe /debug /optimize+ /lib:%LOG4NET_LIB% /reference:log4net.dll /lib:%HFM_LIB% /reference:Interop.HFMCONSTANTSLib.dll /reference:Interop.HFMSLICECOMLib.dll /reference:Interop.HSVCALCULATELib.dll /reference:Interop.HSVCDATALOADLib.dll /reference:Interop.HSVDATALib.dll /reference:Interop.HSVJOURNALSLib.dll /reference:Interop.HSVJOURNALLOADACVLib.dll /reference:Interop.HSVMETADATALib.dll /reference:Interop.HSVMETADATALOADACVLib.dll /reference:Interop.HSVRESOURCEMANAGERLib.dll /reference:Interop.HSVRULESLOADACVLib.dll /reference:Interop.HSVSECURITYACCESSLib.dll /reference:Interop.HSVSECURITYLOADACVLib.dll /reference:Interop.HSVSESSIONLib.dll /reference:Interop.HSVSTARSCHEMAACMLib.dll /reference:Interop.HSVSYSTEMINFOLib.dll /reference:Interop.HSXCLIENTLib.dll /reference:Interop.HSXSERVERLib.dll /resource:gen\HFMCmd.Resource.Help.resources /resource:gen\CommandLine.Resource.resources src\*.cs src\command\*.cs src\hfm\*.cs gen\*.cs properties\*.cs
IF ERRORLEVEL 1 EXIT /B %ERRORLEVEL%

ECHO Bundling HFMCmd and libraries into HFMCmd.exe...
tools\ILMerge\ILMerge.exe /wildcards /lib:%DOTNET% /out:bin\HFMCmd.exe gen\HFMCmd.exe %HFM_LIB%\*.dll %LOG4NET_LIB%\log4net.dll

GOTO END

:DOTNET40
ECHO Targeting .NET Framework 4.0...
SET DOTNET=C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319
SET HFM_LIB=lib\hfm-11.1.2.2
SET LOG4NET_LIB=lib\log4net-1.2.11\bin\net\4.0\release

ECHO Compiling HFMCmd...
%DOTNET%\csc.exe /nologo /target:exe /main:HFMCmd.Launcher /out:gen\HFMCmd.exe /debug /optimize+ /lib:%LOG4NET_LIB% /reference:log4net.dll /lib:%HFM_LIB% /link:Interop.HFMCONSTANTSLib.dll /link:Interop.HFMSLICECOMLib.dll /link:Interop.HSVCALCULATELib.dll /link:Interop.HSVCDATALOADLib.dll /link:Interop.HSVDATALib.dll /link:Interop.HSVJOURNALSLib.dll /link:Interop.HSVJOURNALLOADACVLib.dll /link:Interop.HSVMETADATALib.dll /link:Interop.HSVMETADATALOADACVLib.dll /link:Interop.HSVRESOURCEMANAGERLib.dll /link:Interop.HSVRULESLOADACVLib.dll /link:Interop.HSVSECURITYACCESSLib.dll /link:Interop.HSVSECURITYLOADACVLib.dll /link:Interop.HSVSESSIONLib.dll /link:Interop.HSVSTARSCHEMAACMLib.dll /link:Interop.HSVSYSTEMINFOLib.dll /link:Interop.HSXCLIENTLib.dll /link:Interop.HSXSERVERLib.dll /resource:gen\HFMCmd.Resource.Help.resources /resource:gen\CommandLine.Resource.resources src\*.cs src\command\*.cs src\hfm\*.cs gen\*.cs properties\*.cs
IF ERRORLEVEL 1 EXIT /B %ERRORLEVEL%

ECHO Bundling HFMCmd and libraries into HFMCmd.exe...
tools\ILMerge\ILMerge.exe /targetplatform:v4,%DOTNET% /wildcards /out:bin\HFMCmd.exe gen\HFMCmd.exe %LOG4NET_LIB%\log4net.dll

GOTO END

:END
ECHO Build complete!

@ECHO OFF
IF "%1"=="" (SET TARGET_DOTNET=35) ELSE (SET TARGET_DOTNET=%1)

IF NOT EXIST gen MKDIR gen
IF NOT EXIST bin MKDIR bin
DEL /Q bin\*.*
DEL /Q gen\*.*

ECHO Generating resources...
tools\ResGen.exe resources\Help.resx gen\HFMCmd.Resource.Help.resources /str:cs,HFMCmd.Resource,Help,gen\HelpResource.cs
tools\ResGen.exe resources\CommandLine.resx gen\CommandLine.Resource.resources /str:cs,CommandLine,Resource,gen\CommandLineResource.cs
IF ERRORLEVEL 1 EXIT /B %ERRORLEVEL%

IF %TARGET_DOTNET%==35 GOTO DOTNET35
IF %TARGET_DOTNET%==40 GOTO DOTNET40

ECHO Usage: build.bat *Version*, where *Version* is one of: 35 or 40 (default is 35)
EXIT /B 99

:DOTNET35
ECHO Targeting .NET Framework 3.5...
SET DOTNET=C:\WINDOWS\Microsoft.NET\Framework\v3.5
SET HFM_LIB=lib\hfm-11.1.2.2
SET LOG4NET_LIB=lib\log4net-1.2.11\bin\net\3.5\release

ECHO Compiling HFMCmd...
%DOTNET%\csc.exe /nologo /target:exe /main:HFMCmd.Launcher /out:gen\HFMCmd.exe /debug /optimize+ /lib:%LOG4NET_LIB% /reference:log4net.dll /lib:%HFM_LIB% /reference:Interop.HFMCONSTANTSLib.dll /reference:Interop.HFMSLICECOMLib.dll /reference:Interop.HSVCALCULATELib.dll /reference:Interop.HSVCDATALOADLib.dll /reference:Interop.HSVDATALib.dll /reference:Interop.HSVJOURNALSLib.dll /reference:Interop.HSVJOURNALLOADACVLib.dll /reference:Interop.HSVMETADATALib.dll /reference:Interop.HSVMETADATALOADACVLib.dll /reference:Interop.HSVRESOURCEMANAGERLib.dll /reference:Interop.HSVRULESLOADACVLib.dll /reference:Interop.HSVSECURITYACCESSLib.dll /reference:Interop.HSVSECURITYLOADACVLib.dll /reference:Interop.HSVSESSIONLib.dll /reference:Interop.HSVSTARSCHEMAACMLib.dll /reference:Interop.HSVSYSTEMINFOLib.dll /reference:Interop.HSXCLIENTLib.dll /reference:Interop.HSXSERVERLib.dll /reference:Interop.HFMWDOCUMENTSLib.dll /resource:gen\HFMCmd.Resource.Help.resources /resource:gen\CommandLine.Resource.resources src\*.cs src\command\*.cs src\hfm\*.cs gen\*.cs properties\*.cs
IF ERRORLEVEL 1 EXIT /B %ERRORLEVEL%

ECHO Bundling HFMCmd and libraries into HFMCmd.exe...
tools\ILMerge\ILMerge.exe /wildcards /lib:%DOTNET% /out:bin\HFMCmd.exe gen\HFMCmd.exe %HFM_LIB%\*.dll %LOG4NET_LIB%\log4net.dll

GOTO END

:DOTNET40
ECHO Targeting .NET Framework 4.0...
SET DOTNET=C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319
SET HFM_LIB=lib\hfm-11.1.2.2
SET LOG4NET_LIB=lib\log4net-1.2.11\bin\net\4.0\release

ECHO Compiling HFMCmd...
%DOTNET%\csc.exe /nologo /target:exe /main:HFMCmd.Launcher /out:gen\HFMCmd.exe /debug /optimize+ /lib:%LOG4NET_LIB% /reference:log4net.dll /lib:%HFM_LIB% /link:Interop.HFMCONSTANTSLib.dll /link:Interop.HFMSLICECOMLib.dll /link:Interop.HSVCALCULATELib.dll /link:Interop.HSVCDATALOADLib.dll /link:Interop.HSVDATALib.dll /link:Interop.HSVJOURNALSLib.dll /link:Interop.HSVJOURNALLOADACVLib.dll /link:Interop.HSVMETADATALib.dll /link:Interop.HSVMETADATALOADACVLib.dll /link:Interop.HSVRESOURCEMANAGERLib.dll /link:Interop.HSVRULESLOADACVLib.dll /link:Interop.HSVSECURITYACCESSLib.dll /link:Interop.HSVSECURITYLOADACVLib.dll /link:Interop.HSVSESSIONLib.dll /link:Interop.HSVSTARSCHEMAACMLib.dll /link:Interop.HSVSYSTEMINFOLib.dll /link:Interop.HSXCLIENTLib.dll /link:Interop.HSXSERVERLib.dll /reference:Interop.HFMWDOCUMENTSLib.dll /resource:gen\HFMCmd.Resource.Help.resources /resource:gen\CommandLine.Resource.resources src\*.cs src\command\*.cs src\hfm\*.cs gen\*.cs properties\*.cs
IF ERRORLEVEL 1 EXIT /B %ERRORLEVEL%

ECHO Bundling HFMCmd and libraries into HFMCmd.exe...
tools\ILMerge\ILMerge.exe /targetplatform:v4,%DOTNET% /wildcards /out:bin\HFMCmd.exe gen\HFMCmd.exe %LOG4NET_LIB%\log4net.dll

GOTO END

:END
ECHO Build complete!

Add reference to HFMWDOCUMENTSLib to build script


@echo off
cls
if not exist "tools\FAKE\tools\Fake.exe" (
    ".nuget\nuget.exe" "install" "FAKE" "-OutputDirectory" "tools" "-ExcludeVersion" "-Version 3.17.13"
)
"tools\FAKE\tools\Fake.exe" "build.fsx"

@echo off
cls
if not exist "tools\FAKE\tools\Fake.exe" (
    ".nuget\nuget.exe" "install" "FAKE" "-OutputDirectory" "tools" "-ExcludeVersion"
)
"tools\FAKE\tools\Fake.exe" "build.fsx"

remove version in fake

remove version in fake


@if "%SCM_TRACE_LEVEL%" NEQ "4" @echo off

:: ----------------------
:: KUDU Deployment Script
:: Version: 1.0.15
:: ----------------------

:: Prerequisites
:: -------------

:: Verify node.js installed
where node 2>nul >nul
IF %ERRORLEVEL% NEQ 0 (
  echo Missing node.js executable, please install node.js, if already installed make sure it can be reached from current environment.
  goto error
)

:: Verify yarn installed
which yarn 2>nul >nul
IF %ERRORLEVEL% NEQ 0 (
  echo "Missing yarn, installing via npm"
  call npm install yarn -g --silent
  IF !ERRORLEVEL! NEQ 0 goto error
  echo "Finished installing Yarn."
)

echo "Yarn installed, continuing to deployment"

:: Setup
:: -----

setlocal enabledelayedexpansion

SET ARTIFACTS=%~dp0%..\artifacts

IF NOT DEFINED DEPLOYMENT_SOURCE (
  SET DEPLOYMENT_SOURCE=%~dp0%.
)

IF NOT DEFINED DEPLOYMENT_TARGET (
  SET DEPLOYMENT_TARGET=%ARTIFACTS%\wwwroot
)

IF NOT DEFINED NEXT_MANIFEST_PATH (
  SET NEXT_MANIFEST_PATH=%ARTIFACTS%\manifest

  IF NOT DEFINED PREVIOUS_MANIFEST_PATH (
    SET PREVIOUS_MANIFEST_PATH=%ARTIFACTS%\manifest
  )
)

IF NOT DEFINED KUDU_SYNC_CMD (
  :: Install kudu sync
  echo Installing Kudu Sync
  call npm install kudusync -g --silent
  IF !ERRORLEVEL! NEQ 0 goto error

  :: Locally just running "kuduSync" would also work
  SET KUDU_SYNC_CMD=%appdata%\npm\kuduSync.cmd
)
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: Deployment
:: ----------
echo Handling function App deployment with custom build.cmd script.
echo "build.cmd running in directory %cd%"

:: Restore dotnet packages and build dotnet projects
dotnet restore
dotnet build -c Release

:: Restore node packages and build node projects
yarn install
yarn build

:: 3. KuduSync
IF /I "%IN_PLACE_DEPLOYMENT%" NEQ "1" (
  call :ExecuteCmd "%KUDU_SYNC_CMD%" -v 50 -f ./ -t "%DEPLOYMENT_TARGET%" -n "%NEXT_MANIFEST_PATH%" -p "%PREVIOUS_MANIFEST_PATH%" -i ".git;.hg;.deployment;deploy.cmd;node_modules;"
  IF !ERRORLEVEL! NEQ 0 goto error
)

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
goto end

:: Execute command routine that will echo out when error
:ExecuteCmd
setlocal
set _CMD_=%*
call %_CMD_%
if "%ERRORLEVEL%" NEQ "0" echo Failed exitCode=%ERRORLEVEL%, command=%_CMD_%
exit /b %ERRORLEVEL%

:error
endlocal
echo An error has occurred during web site deployment.
call :exitSetErrorLevel
call :exitFromFunction 2>nul

:exitSetErrorLevel
exit /b 1

:exitFromFunction
()

:end
endlocal
echo Finished successfully.

REM @echo off
REM cls

REM echo "build.cmd running in directory %cd%"

REM dotnet restore std-artist-tally-tool
REM dotnet build -c Release std-artist-tally-tool

REM REM .paket\paket.bootstrapper.exe
REM REM if errorlevel 1 (
REM REM   exit /b %errorlevel%
REM REM )

REM REM .paket\paket.exe restore --force
REM REM if errorlevel 1 (
REM REM   exit /b %errorlevel%
REM REM )

REM call :ExecuteCmd "%KUDU_SYNC_CMD%" -v 50 -f "%DEPLOYMENT_TEMP%" -t "%DEPLOYMENT_TARGET%" -n "%NEXT_MANIFEST_PATH%" -p "%PREVIOUS_MANIFEST_PATH%" -i ".git;.hg;.deployment;deploy.cmd"
REM IF !ERRORLEVEL! NEQ 0 goto error

@if "%SCM_TRACE_LEVEL%" NEQ "4" @echo off

:: ----------------------
:: KUDU Deployment Script
:: Version: 1.0.15
:: ----------------------

:: Prerequisites
:: -------------

:: Verify node.js installed
where node 2>nul >nul
IF %ERRORLEVEL% NEQ 0 (
  echo Missing node.js executable, please install node.js, if already installed make sure it can be reached from current environment.
  goto error
)

:: Verify yarn installed
which yarn 2>nul >nul
IF %ERRORLEVEL% NEQ 0 (
  echo "Missing yarn, installing via npm"
  call npm install yarn -g --silent
  IF !ERRORLEVEL! NEQ 0 goto error
  echo "Finished installing Yarn."
)

echo "Yarn installed, continuing to deployment"

:: Setup
:: -----

setlocal enabledelayedexpansion

SET ARTIFACTS=%~dp0%..\artifacts

IF NOT DEFINED DEPLOYMENT_SOURCE (
  SET DEPLOYMENT_SOURCE=%~dp0%.
)

IF NOT DEFINED DEPLOYMENT_TARGET (
  SET DEPLOYMENT_TARGET=%ARTIFACTS%\wwwroot
)

IF NOT DEFINED NEXT_MANIFEST_PATH (
  SET NEXT_MANIFEST_PATH=%ARTIFACTS%\manifest

  IF NOT DEFINED PREVIOUS_MANIFEST_PATH (
    SET PREVIOUS_MANIFEST_PATH=%ARTIFACTS%\manifest
  )
)

IF NOT DEFINED KUDU_SYNC_CMD (
  :: Install kudu sync
  echo Installing Kudu Sync
  call npm install kudusync -g --silent
  IF !ERRORLEVEL! NEQ 0 goto error

  :: Locally just running "kuduSync" would also work
  SET KUDU_SYNC_CMD=%appdata%\npm\kuduSync.cmd
)
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: Deployment
:: ----------
echo Handling function App deployment with custom build.cmd script.
echo "build.cmd running in directory %cd%"

:: Restore dotnet packages and build dotnet projects
call dotnet restore
call dotnet build -c Release
IF !ERRORLEVEL! NEQ 0 goto error

:: Restore node packages and build node projects
call yarn install
call yarn build
IF !ERRORLEVEL! NEQ 0 goto error

:: 3. KuduSync
IF /I "%IN_PLACE_DEPLOYMENT%" NEQ "1" (
  call :ExecuteCmd "%KUDU_SYNC_CMD%" -v 50 -f ./ -t "%DEPLOYMENT_TARGET%" -n "%NEXT_MANIFEST_PATH%" -p "%PREVIOUS_MANIFEST_PATH%" -i ".git;.hg;.deployment;deploy.cmd;node_modules;"
  IF !ERRORLEVEL! NEQ 0 goto error
)

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
goto end

:: Execute command routine that will echo out when error
:ExecuteCmd
setlocal
set _CMD_=%*
call %_CMD_%
if "%ERRORLEVEL%" NEQ "0" echo Failed exitCode=%ERRORLEVEL%, command=%_CMD_%
exit /b %ERRORLEVEL%

:error
endlocal
echo An error has occurred during web site deployment.
call :exitSetErrorLevel
call :exitFromFunction 2>nul

:exitSetErrorLevel
exit /b 1

:exitFromFunction
()

:end
endlocal
echo Finished successfully.

REM @echo off
REM cls

REM echo "build.cmd running in directory %cd%"

REM dotnet restore std-artist-tally-tool
REM dotnet build -c Release std-artist-tally-tool

REM REM .paket\paket.bootstrapper.exe
REM REM if errorlevel 1 (
REM REM   exit /b %errorlevel%
REM REM )

REM REM .paket\paket.exe restore --force
REM REM if errorlevel 1 (
REM REM   exit /b %errorlevel%
REM REM )

REM call :ExecuteCmd "%KUDU_SYNC_CMD%" -v 50 -f "%DEPLOYMENT_TEMP%" -t "%DEPLOYMENT_TARGET%" -n "%NEXT_MANIFEST_PATH%" -p "%PREVIOUS_MANIFEST_PATH%" -i ".git;.hg;.deployment;deploy.cmd"
REM IF !ERRORLEVEL! NEQ 0 goto error

Use call commands to catch errors

Use call commands to catch errors


set msbuild="%ProgramFiles%\MSBuild\14.0\Bin\MSBuild.exe"
@if not exist %msbuild% @set msbuild="%ProgramFiles%\MSBuild\12.0\Bin\MSBuild.exe"
@if not exist %msbuild% @set msbuild="%ProgramFiles%\MSBuild\15.0\Bin\MSBuild.exe"

%msbuild% "/v:m" SharpSSH.sln

build batch

build batch


@echo off
cd %~dp0

SETLOCAL
SET NUGET_VERSION=latest
SET CACHED_NUGET=%LocalAppData%\NuGet\nuget.%NUGET_VERSION%.exe
SET BUILDCMD_KOREBUILD_VERSION=""
SET BUILDCMD_DNX_VERSION=""

IF EXIST %CACHED_NUGET% goto copynuget
echo Downloading latest version of NuGet.exe...
IF NOT EXIST %LocalAppData%\NuGet md %LocalAppData%\NuGet
@powershell -NoProfile -ExecutionPolicy unrestricted -Command "$ProgressPreference = 'SilentlyContinue'; Invoke-WebRequest 'https://dist.nuget.org/win-x86-commandline/%NUGET_VERSION%/nuget.exe' -OutFile '%CACHED_NUGET%'"

:copynuget
IF EXIST .nuget\nuget.exe goto restore
md .nuget
copy %CACHED_NUGET% .nuget\nuget.exe > nul

:restore
IF EXIST packages\Sake goto getdnx
IF %BUILDCMD_KOREBUILD_VERSION%=="" (
    .nuget\nuget.exe install KoreBuild -ExcludeVersion -o packages -nocache -pre
) ELSE (
    .nuget\nuget.exe install KoreBuild -version %BUILDCMD_KOREBUILD_VERSION% -ExcludeVersion -o packages -nocache -pre
)
.nuget\NuGet.exe install Sake -ExcludeVersion -Source https://www.nuget.org/api/v2/ -Out packages

:getdnx
IF "%SKIP_DNX_INSTALL%"=="" (
    IF "%BUILDCMD_DNX_VERSION%"=="" (
        BUILDCMD_DNX_VERSION=latest
    )
    CALL packages\KoreBuild\build\dnvm install %BUILDCMD_DNX_VERSION% -runtime CoreCLR -arch x86 -alias default
    CALL packages\KoreBuild\build\dnvm install default -runtime CLR -arch x86 -alias default
) ELSE (
    CALL packages\KoreBuild\build\dnvm use default -runtime CLR -arch x86
)

packages\Sake\tools\Sake.exe -I packages\KoreBuild\build -f makefile.shade %*

@echo off
cd %~dp0

SETLOCAL
SET NUGET_VERSION=latest
SET CACHED_NUGET=%LocalAppData%\NuGet\nuget.%NUGET_VERSION%.exe
SET BUILDCMD_KOREBUILD_VERSION=
SET BUILDCMD_DNX_VERSION=

IF EXIST %CACHED_NUGET% goto copynuget
echo Downloading latest version of NuGet.exe...
IF NOT EXIST %LocalAppData%\NuGet md %LocalAppData%\NuGet
@powershell -NoProfile -ExecutionPolicy unrestricted -Command "$ProgressPreference = 'SilentlyContinue'; Invoke-WebRequest 'https://dist.nuget.org/win-x86-commandline/%NUGET_VERSION%/nuget.exe' -OutFile '%CACHED_NUGET%'"

:copynuget
IF EXIST .nuget\nuget.exe goto restore
md .nuget
copy %CACHED_NUGET% .nuget\nuget.exe > nul

:restore
IF EXIST packages\Sake goto getdnx
IF "%BUILDCMD_KOREBUILD_VERSION%"=="" (
    .nuget\nuget.exe install KoreBuild -ExcludeVersion -o packages -nocache -pre
) ELSE (
    .nuget\nuget.exe install KoreBuild -version %BUILDCMD_KOREBUILD_VERSION% -ExcludeVersion -o packages -nocache -pre
)
.nuget\NuGet.exe install Sake -ExcludeVersion -Source https://www.nuget.org/api/v2/ -Out packages

:getdnx
IF "%BUILDCMD_DNX_VERSION%"=="" (
    SET BUILDCMD_DNX_VERSION=latest
)
IF "%SKIP_DNX_INSTALL%"=="" (
    CALL packages\KoreBuild\build\dnvm install %BUILDCMD_DNX_VERSION% -runtime CoreCLR -arch x86 -alias default
    CALL packages\KoreBuild\build\dnvm install default -runtime CLR -arch x86 -alias default
) ELSE (
    CALL packages\KoreBuild\build\dnvm use default -runtime CLR -arch x86
)

packages\Sake\tools\Sake.exe -I packages\KoreBuild\build -f makefile.shade %*

Fix local build break

Fix local build break


md include
md include\google
md include\google\protobuf
md include\google\protobuf\stubs
md include\google\protobuf\io
md include\google\protobuf\compiler
md include\google\protobuf\compiler\cpp
md include\google\protobuf\compiler\java
md include\google\protobuf\compiler\python
copy ..\src\google\protobuf\stubs\common.h include\google\protobuf\stubs\common.h
copy ..\src\google\protobuf\stubs\once.h include\google\protobuf\stubs\once.h
copy ..\src\google\protobuf\descriptor.h include\google\protobuf\descriptor.h
copy ..\src\google\protobuf\descriptor.pb.h include\google\protobuf\descriptor.pb.h
copy ..\src\google\protobuf\descriptor_database.h include\google\protobuf\descriptor_database.h
copy ..\src\google\protobuf\dynamic_message.h include\google\protobuf\dynamic_message.h
copy ..\src\google\protobuf\extension_set.h include\google\protobuf\extension_set.h
copy ..\src\google\protobuf\generated_message_util.h include\google\protobuf\generated_message_util.h
copy ..\src\google\protobuf\generated_message_reflection.h include\google\protobuf\generated_message_reflection.h
copy ..\src\google\protobuf\message.h include\google\protobuf\message.h
copy ..\src\google\protobuf\message_lite.h include\google\protobuf\message_lite.h
copy ..\src\google\protobuf\reflection_ops.h include\google\protobuf\reflection_ops.h
copy ..\src\google\protobuf\repeated_field.h include\google\protobuf\repeated_field.h
copy ..\src\google\protobuf\service.h include\google\protobuf\service.h
copy ..\src\google\protobuf\text_format.h include\google\protobuf\text_format.h
copy ..\src\google\protobuf\unknown_field_set.h include\google\protobuf\unknown_field_set.h
copy ..\src\google\protobuf\wire_format.h include\google\protobuf\wire_format.h
copy ..\src\google\protobuf\wire_format_lite.h include\google\protobuf\wire_format_lite.h
copy ..\src\google\protobuf\wire_format_lite_inl.h include\google\protobuf\wire_format_lite_inl.h
copy ..\src\google\protobuf\io\coded_stream.h include\google\protobuf\io\coded_stream.h
copy ..\src\google\protobuf\io\gzip_stream.h include\google\protobuf\io\gzip_stream.h
copy ..\src\google\protobuf\io\printer.h include\google\protobuf\io\printer.h
copy ..\src\google\protobuf\io\tokenizer.h include\google\protobuf\io\tokenizer.h
copy ..\src\google\protobuf\io\zero_copy_stream.h include\google\protobuf\io\zero_copy_stream.h
copy ..\src\google\protobuf\io\zero_copy_stream_impl.h include\google\protobuf\io\zero_copy_stream_impl.h
copy ..\src\google\protobuf\io\zero_copy_stream_impl_lite.h include\google\protobuf\io\zero_copy_stream_impl_lite.h
copy ..\src\google\protobuf\compiler\code_generator.h include\google\protobuf\compiler\code_generator.h
copy ..\src\google\protobuf\compiler\command_line_interface.h include\google\protobuf\compiler\command_line_interface.h
copy ..\src\google\protobuf\compiler\importer.h include\google\protobuf\compiler\importer.h
copy ..\src\google\protobuf\compiler\parser.h include\google\protobuf\compiler\parser.h
copy ..\src\google\protobuf\compiler\cpp\cpp_generator.h include\google\protobuf\compiler\cpp\cpp_generator.h
copy ..\src\google\protobuf\compiler\java\java_generator.h include\google\protobuf\compiler\java\java_generator.h
copy ..\src\google\protobuf\compiler\python\python_generator.h include\google\protobuf\compiler\python\python_generator.h
copy ..\src\google\protobuf\compiler\plugin.h include\google\protobuf\compiler\plugin.h

Add missing plugin.h into extract_includes.bat script.


@echo off

:: Init Script for cmd.exe
:: Created as part of cmder project

:: !!! THIS FILE IS OVERWRITTEN WHEN CMDER IS UPDATED
:: !!! Use "%CMDER_ROOT%\config\user-profile.cmd" to add your own startup commands

:: Set to > 0 for verbose output to aid in debugging.
if not defined verbose-output ( set verbose-output=0 )

:: Find root dir
if not defined CMDER_ROOT (
    for /f "delims=" %%i in ("%ConEmuDir%\..\..") do set "CMDER_ROOT=%%~fi"
)

:: Remove trailing '\'
if "%CMDER_ROOT:~-1%" == "\" SET "CMDER_ROOT=%CMDER_ROOT:~0,-1%"

:: Pick right version of clink
if "%PROCESSOR_ARCHITECTURE%"=="x86" (
    set architecture=86
) else (
    set architecture=64
)

:: Tell the user about the clink config files...
if not exist "%CMDER_ROOT%\config\settings" (
    echo Generating clink initial settings in "%CMDER_ROOT%\config\settings"
    echo Additional *.lua files in "%CMDER_ROOT%\config" are loaded on startup.
)

:: Run clink
"%CMDER_ROOT%\vendor\clink\clink_x%architecture%.exe" inject --quiet --profile "%CMDER_ROOT%\config" --scripts "%CMDER_ROOT%\vendor"

:: Prepare for git-for-windows

:: I do not even know, copypasted from their .bat
set PLINK_PROTOCOL=ssh
if not defined TERM set TERM=cygwin

:: The idea:
:: * if the users points as to a specific git, use that
:: * test if a git is in path and if yes, use that
:: * last, use our vendored git
:: also check that we have a recent enough version of git (e.g. test for GIT\cmd\git.exe)
if defined GIT_INSTALL_ROOT (
    if exist "%GIT_INSTALL_ROOT%\cmd\git.exe" (goto :FOUND_GIT)
)

:: check if git is in path...
setlocal enabledelayedexpansion
for /F "delims=" %%F in ('where git.exe 2^>nul') do @(
    pushd %%~dpF
    cd ..
    set "test_dir=!CD!"
    popd
    if exist "!test_dir!\cmd\git.exe" (
        set "GIT_INSTALL_ROOT=!test_dir!"
        set test_dir=
        goto :FOUND_GIT
    ) else (
        echo Found old git version in "!test_dir!", but not using...
        set test_dir=
    )
)

:: our last hope: our own git...
:VENDORED_GIT
if exist "%CMDER_ROOT%\vendor\git-for-windows" (
    set "GIT_INSTALL_ROOT=%CMDER_ROOT%\vendor\git-for-windows"
    call :verbose-output Add the minimal git commands to the front of the path
    set "PATH=!GIT_INSTALL_ROOT!\cmd;%PATH%"
) else (
    goto :NO_GIT
)

:FOUND_GIT
:: Add git to the path
if defined GIT_INSTALL_ROOT (
    rem add the unix commands at the end to not shadow windows commands like more
    call :verbose-output Enhancing PATH with unix commands from git in "%GIT_INSTALL_ROOT%\usr\bin"
    set "PATH=%PATH%;%GIT_INSTALL_ROOT%\usr\bin;%GIT_INSTALL_ROOT%\usr\share\vim\vim74"
    :: define SVN_SSH so we can use git svn with ssh svn repositories
    if not defined SVN_SSH set "SVN_SSH=%GIT_INSTALL_ROOT:\=\\%\\bin\\ssh.exe"
)

:NO_GIT
endlocal & set "PATH=%PATH%" & set "SVN_SSH=%SVN_SSH%" & set "GIT_INSTALL_ROOT=%GIT_INSTALL_ROOT%"

:: Enhance Path
set "PATH=%CMDER_ROOT%\bin;%PATH%;%CMDER_ROOT%\"

:: Drop *.bat and *.cmd files into "%CMDER_ROOT%\config\profile.d"
:: to run them at startup.
if not exist "%CMDER_ROOT%\config\profile.d" (
  mkdir "%CMDER_ROOT%\config\profile.d"
)

pushd "%CMDER_ROOT%\config\profile.d"
for /f "usebackq" %%x in ( `dir /b *.bat *.cmd 2^>nul` ) do (
  call :verbose-output Calling "%CMDER_ROOT%\config\profile.d\%%x"...
  call "%CMDER_ROOT%\config\profile.d\%%x"
)
popd

:: Allows user to override default aliases store using profile.d
:: scripts run above by setting the 'aliases' env variable.
::
:: Note: If overriding default aliases store file the aliases
:: must also be self executing, see '.\user-aliases.cmd.example',
:: and be in profile.d folder.
set "user-aliases=%CMDER_ROOT%\config\user-aliases.cmd"

:: The aliases environment variable is used by alias.bat to id
:: the default file to store new aliases in.
if not defined aliases (
  set "aliases=%user-aliases%"
)

:: Make sure we have a self-extracting user-aliases.cmd file
setlocal enabledelayedexpansion
if not exist "%user-aliases%" (
    echo Creating initial user-aliases store in "%user-aliases%"...
    copy "%CMDER_ROOT%\vendor\user-aliases.cmd.example" "%user-aliases%"
) else (
    type "%user-aliases%" | findstr /i ";= Add aliases below here" >nul
    if "!errorlevel!" == "1" (
        echo Creating initial user-aliases store in "%user-aliases%"...
        copy "%CMDER_ROOT%\%user-aliases%" "%user-aliases%.old_format"
        copy "%CMDER_ROOT%\vendor\user-aliases.cmd.example" "%user-aliases%"
    )
)

:: Update old 'user-aliases' to new self executing 'user-aliases.cmd'
if exist "%CMDER_ROOT%\config\aliases" (
  echo Updating old "%CMDER_ROOT%\config\aliases" to new format...
  type "%CMDER_ROOT%\config\aliases" >> "%user-aliases%" && del "%CMDER_ROOT%\config\aliases"
) else if exist "%user-aliases%.old_format" (
  echo Updating old "%user-aliases%" to new format...
  type "%user-aliases%.old_format" >> "%user-aliases%" && del "%user-aliases%.old_format"
)
endlocal
:: Add aliases to the environment
call "%user-aliases%"

:: See vendor\git-for-windows\README.portable for why we do this
:: Basically we need to execute this post-install.bat because we are
:: manually extracting the archive rather than executing the 7z sfx
if exist "%CMDER_ROOT%\vendor\git-for-windows\post-install.bat" (
    call :verbose-output Running Git for Windows one time Post Install....
    pushd "%CMDER_ROOT%\vendor\git-for-windows\"
    "%CMDER_ROOT%\vendor\git-for-windows\git-bash.exe" --no-needs-console --hide --no-cd --command=post-install.bat
    pushd "%USERPROFILE%"
)

:: Set home path
if not defined HOME set "HOME=%USERPROFILE%"

:: This is either a env variable set by the user or the result of
:: cmder.exe setting this variable due to a commandline argument or a "cmder here"
setlocal enabledelayedexpansion
if defined CMDER_START (
    if "%CMDER_START:~-1%" neq "\" (
        SET "CMDER_START=%CMDER_START%\"
    )

    pushd "!CMDER_START!"
)
endlocal

if exist "%CMDER_ROOT%\config\user-profile.cmd" (
    REM Create this file and place your own command in there
    call "%CMDER_ROOT%\config\user-profile.cmd"
) else (
    echo Creating user startup file: "%CMDER_ROOT%\config\user-profile.cmd"
    (
    echo :: use this file to run your own startup commands
    echo :: use  in front of the command to prevent printing the command
    echo.
    echo :: uncomment this to have the ssh agent load when cmder starts
    echo :: call "%%GIT_INSTALL_ROOT%%/cmd/start-ssh-agent.cmd"
    echo.
    echo :: uncomment this next two lines to use pageant as the ssh authentication agent
    echo :: SET SSH_AUTH_SOCK=/tmp/.ssh-pageant-auth-sock
    echo :: call "%%GIT_INSTALL_ROOT%%/cmd/start-ssh-pageant.cmd"
    echo.
    echo :: you can add your plugins to the cmder path like so
    echo :: set "PATH=%%CMDER_ROOT%%\vendor\whatever;%%PATH%%"
    echo.
    ) > "%CMDER_ROOT%\config\user-profile.cmd"
)

exit /b

::
:: sub-routines below here
::
:verbose-output
    if %verbose-output% gtr 0 echo %*
    exit /b

@echo off

:: Init Script for cmd.exe
:: Created as part of cmder project

:: !!! THIS FILE IS OVERWRITTEN WHEN CMDER IS UPDATED
:: !!! Use "%CMDER_ROOT%\config\user-profile.cmd" to add your own startup commands

:: Set to > 0 for verbose output to aid in debugging.
if not defined verbose-output ( set verbose-output=0 )

:: Find root dir
if not defined CMDER_ROOT (
    for /f "delims=" %%i in ("%ConEmuDir%\..\..") do set "CMDER_ROOT=%%~fi"
)

:: Remove trailing '\'
if "%CMDER_ROOT:~-1%" == "\" SET "CMDER_ROOT=%CMDER_ROOT:~0,-1%"

:: Pick right version of clink
if "%PROCESSOR_ARCHITECTURE%"=="x86" (
    set architecture=86
) else (
    set architecture=64
)

:: Tell the user about the clink config files...
if not exist "%CMDER_ROOT%\config\settings" (
    echo Generating clink initial settings in "%CMDER_ROOT%\config\settings"
    echo Additional *.lua files in "%CMDER_ROOT%\config" are loaded on startup.
)

:: Run clink
"%CMDER_ROOT%\vendor\clink\clink_x%architecture%.exe" inject --quiet --profile "%CMDER_ROOT%\config" --scripts "%CMDER_ROOT%\vendor"

:: Prepare for git-for-windows

:: I do not even know, copypasted from their .bat
set PLINK_PROTOCOL=ssh
if not defined TERM set TERM=cygwin

:: The idea:
:: * if the users points as to a specific git, use that
:: * test if a git is in path and if yes, use that
:: * last, use our vendored git
:: also check that we have a recent enough version of git (e.g. test for GIT\cmd\git.exe)
if defined GIT_INSTALL_ROOT (
    if exist "%GIT_INSTALL_ROOT%\cmd\git.exe" (goto :FOUND_GIT)
)

:: check if git is in path...
setlocal enabledelayedexpansion
for /F "delims=" %%F in ('where git.exe 2^>nul') do @(
    pushd %%~dpF
    cd ..
    set "test_dir=!CD!"
    popd
    if exist "!test_dir!\cmd\git.exe" (
        set "GIT_INSTALL_ROOT=!test_dir!"
        set test_dir=
        goto :FOUND_GIT
    ) else (
        echo Found old git version in "!test_dir!", but not using...
        set test_dir=
    )
)

:: our last hope: our own git...
:VENDORED_GIT
if exist "%CMDER_ROOT%\vendor\git-for-windows" (
    set "GIT_INSTALL_ROOT=%CMDER_ROOT%\vendor\git-for-windows"
    call :verbose-output Add the minimal git commands to the front of the path
    set "PATH=!GIT_INSTALL_ROOT!\cmd;%PATH%"
) else (
    goto :NO_GIT
)

:FOUND_GIT
:: Add git to the path
if defined GIT_INSTALL_ROOT (
    rem add the unix commands at the end to not shadow windows commands like more
    call :verbose-output Enhancing PATH with unix commands from git in "%GIT_INSTALL_ROOT%\usr\bin"
    set "PATH=%PATH%;%GIT_INSTALL_ROOT%\usr\bin;%GIT_INSTALL_ROOT%\usr\share\vim\vim74"
    :: define SVN_SSH so we can use git svn with ssh svn repositories
    if not defined SVN_SSH set "SVN_SSH=%GIT_INSTALL_ROOT:\=\\%\\bin\\ssh.exe"
)

:NO_GIT
endlocal & set "PATH=%PATH%" & set "SVN_SSH=%SVN_SSH%" & set "GIT_INSTALL_ROOT=%GIT_INSTALL_ROOT%"

:: Enhance Path
set "PATH=%CMDER_ROOT%\bin;%PATH%;%CMDER_ROOT%\"

:: Drop *.bat and *.cmd files into "%CMDER_ROOT%\config\profile.d"
:: to run them at startup.
if not exist "%CMDER_ROOT%\config\profile.d" (
  mkdir "%CMDER_ROOT%\config\profile.d"
)

pushd "%CMDER_ROOT%\config\profile.d"
for /f "usebackq" %%x in ( `dir /b *.bat *.cmd 2^>nul` ) do (
  call :verbose-output Calling "%CMDER_ROOT%\config\profile.d\%%x"...
  call "%CMDER_ROOT%\config\profile.d\%%x"
)
popd

:: Allows user to override default aliases store using profile.d
:: scripts run above by setting the 'aliases' env variable.
::
:: Note: If overriding default aliases store file the aliases
:: must also be self executing, see '.\user-aliases.cmd.example',
:: and be in profile.d folder.
set "user-aliases=%CMDER_ROOT%\config\user-aliases.cmd"

:: The aliases environment variable is used by alias.bat to id
:: the default file to store new aliases in.
if not defined aliases (
  set "aliases=%user-aliases%"
)

:: Make sure we have a self-extracting user-aliases.cmd file
setlocal enabledelayedexpansion
if not exist "%user-aliases%" (
    echo Creating initial user-aliases store in "%user-aliases%"...
    copy "%CMDER_ROOT%\vendor\user-aliases.cmd.example" "%user-aliases%"
) else (
    type "%user-aliases%" | findstr /i ";= Add aliases below here" >nul
    if "!errorlevel!" == "1" (
        echo Creating initial user-aliases store in "%user-aliases%"...
        copy "%CMDER_ROOT%\%user-aliases%" "%user-aliases%.old_format"
        copy "%CMDER_ROOT%\vendor\user-aliases.cmd.example" "%user-aliases%"
    )
)

:: Update old 'user-aliases' to new self executing 'user-aliases.cmd'
if exist "%CMDER_ROOT%\config\aliases" (
  echo Updating old "%CMDER_ROOT%\config\aliases" to new format...
  type "%CMDER_ROOT%\config\aliases" >> "%user-aliases%" && del "%CMDER_ROOT%\config\aliases"
) else if exist "%user-aliases%.old_format" (
  echo Updating old "%user-aliases%" to new format...
  type "%user-aliases%.old_format" >> "%user-aliases%" && del "%user-aliases%.old_format"
)
endlocal
:: Add aliases to the environment
call "%user-aliases%"

:: See vendor\git-for-windows\README.portable for why we do this
:: Basically we need to execute this post-install.bat because we are
:: manually extracting the archive rather than executing the 7z sfx
if exist "%CMDER_ROOT%\vendor\git-for-windows\post-install.bat" (
    call :verbose-output Running Git for Windows one time Post Install....
    pushd "%CMDER_ROOT%\vendor\git-for-windows\"
    "%CMDER_ROOT%\vendor\git-for-windows\git-bash.exe" --no-needs-console --hide --no-cd --command=post-install.bat
    pushd "%USERPROFILE%"
)

:: Set home path
if not defined HOME set "HOME=%USERPROFILE%"

:: This is either a env variable set by the user or the result of
:: cmder.exe setting this variable due to a commandline argument or a "cmder here"
if defined CMDER_START (
    pushd "%CMDER_START%"
)

if exist "%CMDER_ROOT%\config\user-profile.cmd" (
    REM Create this file and place your own command in there
    call "%CMDER_ROOT%\config\user-profile.cmd"
) else (
    echo Creating user startup file: "%CMDER_ROOT%\config\user-profile.cmd"
    (
    echo :: use this file to run your own startup commands
    echo :: use  in front of the command to prevent printing the command
    echo.
    echo :: uncomment this to have the ssh agent load when cmder starts
    echo :: call "%%GIT_INSTALL_ROOT%%/cmd/start-ssh-agent.cmd"
    echo.
    echo :: uncomment this next two lines to use pageant as the ssh authentication agent
    echo :: SET SSH_AUTH_SOCK=/tmp/.ssh-pageant-auth-sock
    echo :: call "%%GIT_INSTALL_ROOT%%/cmd/start-ssh-pageant.cmd"
    echo.
    echo :: you can add your plugins to the cmder path like so
    echo :: set "PATH=%%CMDER_ROOT%%\vendor\whatever;%%PATH%%"
    echo.
    ) > "%CMDER_ROOT%\config\user-profile.cmd"
)

exit /b

::
:: sub-routines below here
::
:verbose-output
    if %verbose-output% gtr 0 echo %*
    exit /b

Update init.bat

Update init.bat