@ECHO OFF
SETLOCAL EnableDelayedExpansion

>nul 2>&1 cacls "%SYSTEMROOT%\system32\config\system"

if %ERRORLEVEL% NEQ 0 (
  GOTO :UAC_REQUEST
) else (
  GOTO :UAC_ACCEPTED
)

:UAC_ACCEPTED
ECHO ---------------------------------------------------------------------------
ECHO Automated Cygwin, VirtualBox and Vagrant setup
ECHO ---------------------------------------------------------------------------

reg Query "HKLM\Hardware\Description\System\CentralProcessor\0" | find /i "x86" > NUL && SET ARCH=32 || SET ARCH=64
REM -- Save PowerShell version into variable with exit code.
powershell -command "exit $PSVersionTable.PSVersion.Major"

REM -- PowerShell 3 or better must be installed.
REM -- https://github.com/BR0kEN-/cikit#windows
if %ERRORLEVEL% LSS 3 (
  ECHO [INFO] Installing PowerShell 3
  CALL :download PowerShell https://download.microsoft.com/download/E/7/6/E76850B8-DA6E-4FF5-8CCE-A24FC513FD16/Windows6.1-KB2506143-x64.msu %TEMP%\KB2506143-x64.msu
  START /B /wait %TEMP%\KB2506143-x64.msu /quiet /norestart
  REM -- Schedule re-run of this script with current set of arguments after system reboot.
  reg Add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce" /v CIKit /t Reg_SZ /d "%~dpf0 %*" /f
  REM -- Wait some time until reboot to let script return an exit code.
  shutdown -r -t 2
  REM -- Check for specific exit code and let CI server to assume that script will be continued after reboot.
  REM -- https://serverfault.com/a/539247
  EXIT /B 6660
)

REM ----------------------------------------------------------------------------
SET CYGWIN_SITE=http://cygwin.mirrors.pair.com
SET CYGWIN_ROOTDIR=%SystemDrive%\cygwin%ARCH%
SET CYGWIN_FILENAME=setup-x86

REM -- "setup-x86.exe" or "setup-x86_64.exe".
if 64 == %ARCH% (
  SET CYGWIN_FILENAME=%CYGWIN_FILENAME%_%ARCH%
)

SET CYGWIN_FILENAME=%CYGWIN_FILENAME%.exe
SET CYGWIN_INSTALLER=%TEMP%\%CYGWIN_FILENAME%

REM -- Read packages from the file.
FOR /F %%L IN (%~dp0\packages.txt) DO SET CYGWIN_PACKAGES=!CYGWIN_PACKAGES!%%L,

if not exist %CYGWIN_ROOTDIR% (
  MKDIR %CYGWIN_ROOTDIR%
)

CALL :download Cygwin https://www.cygwin.com/%CYGWIN_FILENAME% %CYGWIN_INSTALLER%

REM -- https://cygwin.com/faq/faq.html#faq.setup.cli
SET CYGWIN_INSTALLER=%CYGWIN_INSTALLER% --quiet-mode --no-shortcuts --download --local-install --no-verify --site %CYGWIN_SITE% --local-package-dir %TEMP% --root %CYGWIN_ROOTDIR%

ECHO [INFO] Installing default Cygwin packages
START /B /wait %CYGWIN_INSTALLER%

ECHO [INFO] Installing custom Cygwin packages
START /B /wait %CYGWIN_INSTALLER% --packages %CYGWIN_PACKAGES:~0,-1%

REM -- Update PATH variable to have Cygwin available.
SET PATH=%CYGWIN_ROOTDIR%\bin;%PATH%

REM -- Compute path to CWD in Unix style.
FOR /F %%D IN ('cygpath -u %~dp0') DO SET CWD=%%D

REM -- Set path to sources for tests.
SET TESTSDIR=%CWD%/..

REM ----------------------------------------------------------------------------
REM -- 7-Zip will be used for unpacking ISO image, containing VirtualBox Guest Additions.
ECHO [INFO] Installing 7-Zip
SET SEVENZIP_FILENAME=7z1604

REM -- "7z1604.msi" or "7z1604-x64.msi".
if 64 == %ARCH% (
  SET SEVENZIP_FILENAME=%SEVENZIP_FILENAME%-x%ARCH%
)

SET SEVENZIP_FILENAME=%SEVENZIP_FILENAME%.msi

CALL :download 7-Zip http://7-zip.org/a/%SEVENZIP_FILENAME% %TEMP%\%SEVENZIP_FILENAME%
CALL :install 7-Zip %TEMP%\%SEVENZIP_FILENAME%

REM -- Update PATH variable to have 7-Zip available.
SET PATH=%PROGRAMFILES%\7-Zip;%PATH%

REM ----------------------------------------------------------------------------
ECHO [INFO] Installing Ansible
bash --login %TESTSDIR%/ansible.sh

REM ----------------------------------------------------------------------------
ECHO [INFO] Installing VirtualBox
CALL :install_variables virtualbox

SET VBOXGUEST_FILENAME=VBoxGuestAdditions_%VERSION%.iso
SET VBOXGUEST_MOUNTDIR=%TEMP%\vbox-guest-additions

CALL :download VirtualBoxGuestAdditions %URL%/%VBOXGUEST_FILENAME% %TEMP%\%VBOXGUEST_FILENAME%

7z e -o%VBOXGUEST_MOUNTDIR% %TEMP%\%VBOXGUEST_FILENAME% -y
REM -- Ensure Oracle certificate added for unattended VirtualBox installation.
certutil -addstore -f "TrustedPublisher" %VBOXGUEST_MOUNTDIR%\vbox-sha1.cer

START /B /wait %VBOXGUEST_MOUNTDIR%\VboxWindowsAdditions.exe /S
START /B /wait %TEMP%\%EXE% --path %TEMP% --extract --silent
CALL :install VirtualBox %TEMP%\%MSI%

REM ----------------------------------------------------------------------------
ECHO [INFO] Installing Vagrant
CALL :install_variables vagrant
CALL :install Vagrant %TEMP%\%MSI%

REM ----------------------------------------------------------------------------
if /I "test-vm" == "%1" (
  REM -- "php-version" -- "nodejs-version" -- "solr-version" -- "ruby-version".
  bash --login %TESTSDIR%/cikit.sh "%2" "%3" "%4" "%5"

  if "%ERRORLEVEL%" NEQ "0" (
    ECHO [ERROR] Unable to boot VM.
    EXIT /B 1
  )
)

ENDLOCAL
EXIT /B 0

REM ----------------------------------------------------------------------------
:UAC_REQUEST
SET SCRIPT=%TEMP%\cikit.vbs

if exist %SCRIPT% (
  DEL %SCRIPT%
)

ECHO Set UAC = CreateObject^("Shell.Application"^) > %SCRIPT%
ECHO UAC.ShellExecute "cmd", "/c %~s0 %*", "", "runas", 1 >> %SCRIPT%

START /B /wait %SCRIPT%
EXIT /B 0

REM ----------------------------------------------------------------------------
:download
if not exist %3 (
  ECHO [INFO] Downloading %1
  bitsadmin /transfer "Downloading %1" "%2" "%3"
)

if not exist %3 (
  ECHO [ERROR] %1 downloading failed
  EXIT /B 1
)

EXIT /B 0

REM ----------------------------------------------------------------------------
:install_variables
FOR /F "tokens=1-4 delims=|" %%a IN ('bash --login %TESTSDIR%/%1/install.sh "windows" "%ARCH%" "%TEMP%"') DO SET "EXE=%%a" & SET "MSI=%%b" & SET "VERSION=%%c" & SET "URL=%%d"
EXIT /B

REM ----------------------------------------------------------------------------
:install
START /B /wait msiexec /i %2 TARGETDIR=%SystemDrive%\%1%ARCH% /L*vx %1-install.log /norestart /QB
EXIT /B 0

@ECHO OFF
SETLOCAL EnableDelayedExpansion

>nul 2>&1 cacls "%SYSTEMROOT%\system32\config\system"

if %ERRORLEVEL% NEQ 0 (
  GOTO :UAC_REQUEST
) else (
  GOTO :UAC_ACCEPTED
)

:UAC_ACCEPTED
ECHO ---------------------------------------------------------------------------
ECHO Automated Cygwin, VirtualBox and Vagrant setup
ECHO ---------------------------------------------------------------------------

reg Query "HKLM\Hardware\Description\System\CentralProcessor\0" | find /i "x86" > NUL && SET ARCH=32 || SET ARCH=64

REM ----------------------------------------------------------------------------
REM -- 7-Zip will be used for unpacking ISO image with VBox Guest Additions and Streams ZIP archive.
ECHO [INFO] Installing 7-Zip
SET SEVENZIP_FILENAME=7z1604

REM -- "7z1604.msi" or "7z1604-x64.msi".
if 64 == %ARCH% (
  SET SEVENZIP_FILENAME=%SEVENZIP_FILENAME%-x%ARCH%
)

SET SEVENZIP_FILENAME=%SEVENZIP_FILENAME%.msi

CALL :download 7-Zip http://7-zip.org/a/%SEVENZIP_FILENAME% %TEMP%\%SEVENZIP_FILENAME%
CALL :install 7-Zip %TEMP%\%SEVENZIP_FILENAME%

REM -- Update PATH variable to have 7-Zip available.
SET PATH=%PROGRAMFILES%\7-Zip;%PATH%

REM ----------------------------------------------------------------------------
REM -- Save PowerShell version into variable with exit code.
powershell -command "exit $PSVersionTable.PSVersion.Major"

REM -- PowerShell 3 or better must be installed (Windows 7 has PowerShell 2.x).
REM -- https://github.com/BR0kEN-/cikit#windows
if %ERRORLEVEL% LSS 3 (
  CALL :download PowerShell https://download.microsoft.com/download/E/7/6/E76850B8-DA6E-4FF5-8CCE-A24FC513FD16/Windows6.1-KB2506143-x64.msu %TEMP%\KB2506143-x64.msu
  ECHO [INFO] Installing PowerShell 3
  START /B /wait %TEMP%\KB2506143-x64.msu /quiet /norestart
  REM -- Download Streams utility to remove Alternate Data Stream from this file to unblock its unattended execution after system reboot.
  REM -- Note, that we can't use "Unblock-File" or "Remove-Item" PowerShell cmdlets since they are available since version 3 and above.
  REM -- https://technet.microsoft.com/en-us/sysinternals/bb897440.aspx
  CALL :download Streams https://download.sysinternals.com/files/Streams.zip %TEMP%\Streams.zip
  REM -- Unarchive Streams.
  7z e -o%TEMP%\Streams %TEMP%\Streams.zip
  REM -- Remove all ADS (needed to not have "Zone.Identifier" with "ZoneTransfer" and "ZoneId=3").
  REM -- https://support.microsoft.com/en-us/kb/182569
  %TEMP%\Streams\streams.exe -accepteula -d %~dpf0
  REM -- Schedule re-run of this script with current set of arguments after system reboot.
  reg Add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce" /v CIKit /t Reg_SZ /d "%~dpf0 %*" /f
  REM -- Wait some time until reboot to let script return an exit code.
  shutdown -r -t 2
  REM -- Check for specific exit code and let CI server to assume that script will be continued after reboot.
  REM -- https://serverfault.com/a/539247
  EXIT /B 6660
)

REM ----------------------------------------------------------------------------
SET CYGWIN_SITE=http://cygwin.mirrors.pair.com
SET CYGWIN_ROOTDIR=%SystemDrive%\cygwin%ARCH%
SET CYGWIN_FILENAME=setup-x86

REM -- "setup-x86.exe" or "setup-x86_64.exe".
if 64 == %ARCH% (
  SET CYGWIN_FILENAME=%CYGWIN_FILENAME%_%ARCH%
)

SET CYGWIN_FILENAME=%CYGWIN_FILENAME%.exe
SET CYGWIN_INSTALLER=%TEMP%\%CYGWIN_FILENAME%

REM -- Read packages from the file.
FOR /F %%L IN (%~dp0\packages.txt) DO SET CYGWIN_PACKAGES=!CYGWIN_PACKAGES!%%L,

if not exist %CYGWIN_ROOTDIR% (
  MKDIR %CYGWIN_ROOTDIR%
)

CALL :download Cygwin https://www.cygwin.com/%CYGWIN_FILENAME% %CYGWIN_INSTALLER%

REM -- https://cygwin.com/faq/faq.html#faq.setup.cli
SET CYGWIN_INSTALLER=%CYGWIN_INSTALLER% --quiet-mode --no-shortcuts --download --local-install --no-verify --site %CYGWIN_SITE% --local-package-dir %TEMP% --root %CYGWIN_ROOTDIR%

ECHO [INFO] Installing default Cygwin packages
START /B /wait %CYGWIN_INSTALLER%

ECHO [INFO] Installing custom Cygwin packages
START /B /wait %CYGWIN_INSTALLER% --packages %CYGWIN_PACKAGES:~0,-1%

REM -- Update PATH variable to have Cygwin available.
SET PATH=%CYGWIN_ROOTDIR%\bin;%PATH%

REM -- Compute path to CWD in Unix style.
FOR /F %%D IN ('cygpath -u %~dp0') DO SET CWD=%%D

REM -- Set path to sources for tests.
SET TESTSDIR=%CWD%/..

REM ----------------------------------------------------------------------------
ECHO [INFO] Installing Ansible
bash --login %TESTSDIR%/ansible.sh

REM ----------------------------------------------------------------------------
ECHO [INFO] Installing VirtualBox
CALL :install_variables virtualbox

SET VBOXGUEST_FILENAME=VBoxGuestAdditions_%VERSION%.iso
SET VBOXGUEST_MOUNTDIR=%TEMP%\vbox-guest-additions

CALL :download VirtualBoxGuestAdditions %URL%/%VBOXGUEST_FILENAME% %TEMP%\%VBOXGUEST_FILENAME%

7z e -o%VBOXGUEST_MOUNTDIR% %TEMP%\%VBOXGUEST_FILENAME% -y
REM -- Ensure Oracle certificate added for unattended VirtualBox installation.
certutil -addstore -f "TrustedPublisher" %VBOXGUEST_MOUNTDIR%\vbox-sha1.cer

START /B /wait %VBOXGUEST_MOUNTDIR%\VboxWindowsAdditions.exe /S
START /B /wait %TEMP%\%EXE% --path %TEMP% --extract --silent
CALL :install VirtualBox %TEMP%\%MSI%

REM ----------------------------------------------------------------------------
ECHO [INFO] Installing Vagrant
CALL :install_variables vagrant
CALL :install Vagrant %TEMP%\%MSI%

REM ----------------------------------------------------------------------------
if /I "test-vm" == "%1" (
  REM -- "php-version" -- "nodejs-version" -- "solr-version" -- "ruby-version".
  bash --login %TESTSDIR%/cikit.sh "%2" "%3" "%4" "%5"

  if "%ERRORLEVEL%" NEQ "0" (
    ECHO [ERROR] Unable to boot VM.
    EXIT /B 1
  )
)

ENDLOCAL
EXIT /B 0

REM ----------------------------------------------------------------------------
:UAC_REQUEST
SET SCRIPT=%TEMP%\cikit.vbs

if exist %SCRIPT% (
  DEL %SCRIPT%
)

ECHO Set UAC = CreateObject^("Shell.Application"^) > %SCRIPT%
ECHO UAC.ShellExecute "cmd", "/c %~s0 %*", "", "runas", 1 >> %SCRIPT%

START /B /wait %SCRIPT%
EXIT /B 0

REM ----------------------------------------------------------------------------
:download
if not exist %3 (
  ECHO [INFO] Downloading %1
  bitsadmin /transfer "Downloading %1" "%2" "%3"
)

if not exist %3 (
  ECHO [ERROR] %1 downloading failed
  EXIT /B 1
)

EXIT /B 0

REM ----------------------------------------------------------------------------
:install_variables
FOR /F "tokens=1-4 delims=|" %%a IN ('bash --login %TESTSDIR%/%1/install.sh "windows" "%ARCH%" "%TEMP%"') DO SET "EXE=%%a" & SET "MSI=%%b" & SET "VERSION=%%c" & SET "URL=%%d"
EXIT /B

REM ----------------------------------------------------------------------------
:install
START /B /wait msiexec /i %2 TARGETDIR=%SystemDrive%\%1%ARCH% /L*vx %1-install.log /norestart /QB
EXIT /B 0

Fix PowerShell 3 installation

[CIKit][Tests] Fix PowerShell 3 installation


@echo off
chcp 65001 > NUL

set PIPENV_VENV_IN_PROJECT=1

python --version > NUL 2>&1
if %ERRORLEVEL% neq 0 (
    echo Cannot find Python executable, make sure it is installed and added to your PATH.
    pause
    exit /B 0
)

python -c "import pipenv" > NUL 2>&1
if %ERRORLEVEL% neq 0 (
    python -m pip install --user pipenv
)

pipenv --version > NUL 2>&1
if %ERRORLEVEL% neq 0 (
    echo Adding pipenv to PATH...
    for /F %%p IN ('python -m site --user-site') do set path_pipenv=%%p
    set PATH=%PATH%;%path_pipenv:site-packages=Scripts%
)

if not exist ".venv" ( pipenv --bare install )

pipenv run python3 -c "exit(__import__('discord').opus.is_loaded())" > NUL 2>&1
if %ERRORLEVEL% equ 0 (
    echo Cannot find libopus on your system, make sure it is installed.
    pause
    exit /B 0
)

del /Q panda.log
pipenv run python panda.py
pause

@echo off
SETLOCAL EnableDelayedExpansion
chcp 65001 > NUL

set PIPENV_VENV_IN_PROJECT=1

python --version > NUL 2>&1
if %ERRORLEVEL% neq 0 (
    echo Cannot find Python executable, make sure it is installed and added to your PATH.
    pause
    exit /B 0
)

python -c "import pipenv" > NUL 2>&1
if %ERRORLEVEL% neq 0 (
    python -m pip install --user pipenv
)

pipenv --version > NUL 2>&1
if %ERRORLEVEL% neq 0 (
    echo Adding pipenv to PATH...
    for /F %%p IN ('python -m site --user-site') do set path_pipenv=%%p
    set PATH=!PATH!;!path_pipenv:site-packages=Scripts!
)

if not exist ".venv" ( pipenv --bare install )

pipenv run python3 -c "exit(__import__('discord').opus.is_loaded())" > NUL 2>&1
if %ERRORLEVEL% equ 0 (
    echo Cannot find libopus on your system, make sure it is installed.
    pause
    exit /B 0
)

del /Q panda.log
pipenv run python panda.py
pause

Fix pipenv addition to PATH when PATH contains parenthsis.


@setlocal EnableDelayedExpansion EnableExtensions
@for %%i in (%~dp0\_packer_config*.cmd) do @call "%%~i"
@if defined PACKER_DEBUG (@echo on) else (@echo off)

title Enabling Windows Remote Management. Please wait...

echo ==^> Turning off User Account Control (UAC)
:: see http://www.howtogeek.com/howto/windows-vista/enable-or-disable-uac-from-the-windows-vista-command-line/
reg ADD HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System /v EnableLUA /t REG_DWORD /d 0 /f
@if errorlevel 1 echo ==^> WARNING: Error %ERRORLEVEL% was returned by: reg ADD HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System /v EnableLUA /t REG_DWORD /d 0 /f

title Enabling Windows Remote Management. Please wait...

echo ==^> Setting the PowerShell ExecutionPolicy to RemoteSigned (64 bit)
powershell -Command "Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Force" <NUL
@if errorlevel 1 echo ==^> WARNING: Error %ERRORLEVEL% was returned by: powershell -Command "Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Force"

if exist %SystemRoot%\SysWOW64\cmd.exe (
  echo ==^> Setting the PowerShell ExecutionPolicy to RemoteSigned (32 bit)
  %SystemRoot%\SysWOW64\cmd.exe /c powershell -Command "Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Force" <NUL
  @if errorlevel 1 echo ==^> WARNING: Error %ERRORLEVEL% was returned by: powershell -Command "Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Force"
)

:: systeminfo 2>nul | findstr /b /c:"OS Name" | findstr /c:"Windows 7" >nul
:: if errorlevel 1 goto skip_fixnetwork

if not exist a:\fixnetwork.ps1 echo ==^> ERROR: File not found: a:\fixnetwork.ps1

echo ==^> Setting the Network Location to private
:: see http://blogs.msdn.com/b/powershell/archive/2009/04/03/setting-network-location-to-private.aspx
powershell -File a:\fixnetwork.ps1 <NUL
@if errorlevel 1 echo ==^> WARNING: Error %ERRORLEVEL% was returned by: powershell -File a:\fixnetwork.ps1

:skip_fixnetwork

echo ==^> Changing remote UAC account policy
reg add HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\system /v LocalAccountTokenFilterPolicy /t REG_DWORD /d 1 /f
@if errorlevel 1 echo ==^> WARNING: Error %ERRORLEVEL% was returned by: reg add HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\system /v LocalAccountTokenFilterPolicy /t REG_DWORD /d 1 /f

echo ==^> Blocking WinRM port 5985 on the firewall
netsh advfirewall firewall add rule name="winrm"  dir=in action=block protocol=TCP localport=5985
@if errorlevel 1 echo ==^> WARNING: Error %ERRORLEVEL% was returned by: netsh advfirewall firewall add rule name="winrm"  dir=in action=block protocol=TCP localport=5985

echo ==^> Configuring Windows Remote Management (WinRM) service

call winrm quickconfig -q
@if errorlevel 1 echo ==^> WARNING: Error %ERRORLEVEL% was returned by: winrm quickconfig -q

call winrm quickconfig -transport:http
@if errorlevel 1 echo ==^> WARNING: Error %ERRORLEVEL% was returned by: winrm quickconfig -transport:http

call winrm set winrm/config @{MaxTimeoutms="1800000"}
@if errorlevel 1 echo ==^> WARNING: Error %ERRORLEVEL% was returned by: winrm set winrm/config @{MaxTimeoutms="1800000"}

call winrm set winrm/config/winrs @{MaxMemoryPerShellMB="800"}
@if errorlevel 1 echo ==^> WARNING: Error %ERRORLEVEL% was returned by: winrm set winrm/config/winrs @{MaxMemoryPerShellMB="1024"}

call winrm set winrm/config/service @{AllowUnencrypted="true"}
@if errorlevel 1 echo ==^> WARNING: Error %ERRORLEVEL% was returned by: winrm set winrm/config/service @{AllowUnencrypted="true"}

call winrm set winrm/config/service/auth @{Basic="true"}
@if errorlevel 1 echo ==^> WARNING: Error %ERRORLEVEL% was returned by: winrm set winrm/config/service/auth @{Basic="true"}

call winrm set winrm/config/client/auth @{Basic="true"}
@if errorlevel 1 echo ==^> WARNING: Error %ERRORLEVEL% was returned by: winrm set winrm/config/client/auth @{Basic="true"}

call winrm set winrm/config/listener?Address=*+Transport=HTTP @{Port="5985"}
@if errorlevel 1 echo ==^> WARNING: Error %ERRORLEVEL% was returned by: winrm set winrm/config/listener?Address=*+Transport=HTTP @{Port="5985"}

sc config winrm start= auto
@if errorlevel 1 echo ==^> WARNING: Error %ERRORLEVEL% was returned by: sc config winrm start= auto

:: wait for winrm service to finish starting
timeout 5

sc query winrm | findstr "RUNNING" >nul
if errorlevel 1 goto winrm_not_running

echo ==^> Stopping winrm service

sc stop winrm

:is_winrm_running

timeout 1

sc query winrm | findstr "STOPPED" >nul
if errorlevel 1 goto is_winrm_running

:winrm_not_running

echo ==^> Unblocking WinRM port 5985 on the firewall
netsh advfirewall firewall delete rule name="winrm"
@if errorlevel 1 echo ==^> WARNING: Error %ERRORLEVEL% was returned by: netsh advfirewall firewall delete rule name="winrm"

echo ==^> Enable firewall groups
:: see http://social.technet.microsoft.com/Forums/windowsserver/en-US/a1e65f0f-2550-49ae-aee2-56a9bdcfb8fb/windows-7-remote-administration-firewall-group?forum=winserverManagement
ver | findstr /i "6\.[2-9]\."
if errorlevel 1 (
  echo ==^> Enabling Remote Administration firewall group
  :: pre win 8/server 2012
  netsh advfirewall firewall set rule group="remote administration" new enable=yes
  @if errorlevel 1 echo ==^> WARNING: Error %ERRORLEVEL% was returned by: netsh advfirewall firewall set rule group="remote administration" new enable=yes
) else (
  echo ==^> Enabling Windows Remote Management firewall group
  :: win 8+/server 2012+
  netsh advfirewall firewall set rule group="Windows Remote Management" new enable=yes
  @if errorlevel 1 echo ==^> WARNING: Error %ERRORLEVEL% was returned by: netsh advfirewall firewall set rule group="Windows Remote Management" new enable=yes
)

netsh advfirewall firewall add rule name="winrm" dir=in action=allow protocol=TCP localport=5985
@if errorlevel 1 echo ==^> WARNING: Error %ERRORLEVEL% was returned by: netsh advfirewall firewall add rule name="winrm"  dir=in action=allow protocol=TCP localport=5985

:: wait for firewall groups to enable
timeout 5

:exit0

ver>nul

goto :exit

:exit1

verify other 2>nul

:exit

make fixnetwork run permanent

make fixnetwork run permanent


@echo off
rem
rem Install or update Cygwin.
rem
rem Features of this batch file:
rem   * Mostly hands-free, except for stopping of running Cygwin
rem     processes and configuration of newly installed services.
rem   * Stops and starts Cygwin services.
rem   * Lists running Cygwin processes (setup.exe informs you that
rem     they are running, but does not list them).
rem   * Fetches latest setup.exe from cygwin.com.
rem   * Installs standard set of packages.
rem   * Updates all installed packages.
rem   * Runs rebaseall.
rem   * Installs standard services (syslogd, sshd).
rem   * Installs cyglsa.
rem
rem Copyright (c) 2012-2012 Tom Schutter
rem All rights reserved.
rem
rem Redistribution and use in source and binary forms, with or without
rem modification, are permitted provided that the following conditions
rem are met:
rem
rem    - Redistributions of source code must retain the above copyright
rem      notice, this list of conditions and the following disclaimer.
rem    - Redistributions in binary form must reproduce the above
rem      copyright notice, this list of conditions and the following
rem      disclaimer in the documentation and/or other materials provided
rem      with the distribution.
rem
rem THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
rem "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
rem LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
rem FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
rem COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
rem INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
rem BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
rem LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
rem CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
rem LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
rem ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
rem POSSIBILITY OF SUCH DAMAGE.
rem

setlocal
goto :main

:load_config
    set _CONFFILE=%~dp0\cygwin_setup_config.bat
    if exist "%_CONFFILE%" goto :endif_check_conffile
        echo %_PREFIX% ERROR: Configuration file "%_CONFFILE%" not found.
        exit /b 1
    :endif_check_conffile
    set _PACKAGES=
    set _ROOTDIR=
    set _SITE=
    set _CONFIG_SYSLOGD=
    set _CONFIG_SSHD=
    set _CONFIG_LSA=
    call "%_CONFFILE%"
    if "%_PACKAGES%" == "" (
        echo %_PREFIX% ERROR: _PACKAGES not defined in "%_CONFFILE%"
        exit /b 1
    )
    if "%_ROOTDIR%" == "" (
        echo %_PREFIX% ERROR: _ROOTDIR not defined in "%_CONFFILE%"
        exit /b 1
    )
    if "%_SITE%" == "" (
        echo %_PREFIX% ERROR: _SITE not defined in "%_CONFFILE%"
        exit /b 1
    )
    if "%_CONFIG_SYSLOGD%" == "" (
        echo %_PREFIX% ERROR: _CONFIG_SYSLOGD not defined in "%_CONFFILE%"
        exit /b 1
    )
    if "%_CONFIG_SSHD%" == "" (
        echo %_PREFIX% ERROR: _CONFIG_SSHD not defined in "%_CONFFILE%"
        exit /b 1
    )
    if "%_CONFIG_LSA%" == "" (
        echo %_PREFIX% ERROR: _CONFIG_LSA not defined in "%_CONFFILE%"
        exit /b 1
    )
exit /b 0

:check_admin
    rem Check for ADMIN privileges
    rem https://sites.google.com/site/eneerge/home/BatchGotAdmin

    echo %_PREFIX% Checking for Administrator privileges
    "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system" >nul 2>&1
    if not ERRORLEVEL 1 goto :endif_check_admin
        echo %_PREFIX% ERROR: You do not have Administrator privileges
        echo %_PREFIX% Rerun from a "Run as Administrator" command prompt
        exit /b 1
    :endif_check_admin
exit /b 0

:stop_services
    rem Stop all Cygwin services.
    if not exist "%_ROOTDIR%\bin\cygrunsrv.exe" goto :eof
    for /f "usebackq" %%s in (`"%_ROOTDIR%\bin\cygrunsrv.exe" --list`) do (
        echo %_PREFIX% Stopping %%s
        "%_ROOTDIR%\bin\cygrunsrv.exe" --stop %%s
    )
goto :eof

:start_service
    rem Start a single Cygwin service.
    echo %_PREFIX% Starting %1
    "%_ROOTDIR%\bin\cygrunsrv.exe" --start %1
goto :eof

:start_services
    rem Start all Cygwin services.

    rem Start syslogd first.
    for /f "usebackq" %%s in (`"%_ROOTDIR%\bin\cygrunsrv.exe" --list`) do (
        if "%%s" == "syslogd" call :start_service %%s
    )
    rem Start rest of services.
    for /f "usebackq" %%s in (`"%_ROOTDIR%\bin\cygrunsrv.exe" --list`) do (
        if not "%%s" == "syslogd" call :start_service %%s
    )
goto :eof

:check_for_cygwin_proc
    rem Check for any Cygwin processes.
    echo %_PREFIX% Checking for running Cygwin processes
    if not exist "%_ROOTDIR%\bin\ps.exe" exit /b 0
    set _TEMPFILE=%TEMP%\cygwin_setup.txt
    :retry
        "%_ROOTDIR%\bin\ps.exe" -l | findstr /v /c:"/usr/bin/ps" > "%_TEMPFILE%"
        findstr /v /r /c:"PID.*COMMAND" "%_TEMPFILE%" | findstr /r /c:"^..*" > NUL:
        if ERRORLEVEL 1 goto :ignore
        echo %_PREFIX% Found running Cygwin processes
        type "%_TEMPFILE%"
        del "%_TEMPFILE%"
        :ask_abort_retry_ignore
            set /p _ANSWER=Abort, Retry, or Ignore?
            set _ANSWER=%_ANSWER:~0,1%
            if "%_ANSWER%" == "a" exit /b 1
            if "%_ANSWER%" == "A" exit /b 1
            if "%_ANSWER%" == "r" goto :retry
            if "%_ANSWER%" == "R" goto :retry
            if "%_ANSWER%" == "i" goto :ignore
            if "%_ANSWER%" == "I" goto :ignore
        goto :ask_abort_retry_ignore
    :ignore
exit /b 0

:get_setup_exe
    rem Download latest setup.exe.
    if not exist %_ROOTDIR% (
        echo %_PREFIX% Creating %_ROOTDIR%
        mkdir "%_ROOTDIR%"
    )
    echo %_PREFIX% Fetching latest setup.exe from cygwin.com
    wget --quiet -O "%_ROOTDIR%\setup.exe" http://cygwin.com/setup.exe
goto :eof

:setup
    rem Run setup.exe.
    echo %_PREFIX% Running setup.exe for updates
    "%_ROOTDIR%\setup.exe" --site %_SITE% --quiet-mode --no-shortcuts --root "%_ROOTDIR%" --local-package-dir "%_ROOTDIR%\LocalPackageDir"
    echo %_PREFIX% Running setup.exe to install standard package set
    "%_ROOTDIR%\setup.exe" --site %_SITE% --quiet-mode --no-shortcuts --root "%_ROOTDIR%" --local-package-dir "%_ROOTDIR%\LocalPackageDir" --packages %_PACKAGES%
goto :eof

:rebaseall
    rem Run rebaseall.
    rem See http://cygwin.com/ml/cygwin/2012-08/msg00320.html
    echo %_PREFIX% Running rebaseall
    "%_ROOTDIR%\bin\dash.exe" -c 'cd /usr/bin; PATH=. ; rebaseall'
goto :eof

:create_passwd
    rem Create local passwd and group files.
    if not exist "%_ROOTDIR%\etc\passwd" (
        echo %_PREFIX% Creating /etc/passwd
        "%_ROOTDIR%\bin\bash.exe" --login -i -c '/usr/bin/mkpasswd --local > /etc/passwd'
    )
    if not exist "%_ROOTDIR%\etc\group" (
        echo %_PREFIX% Creating /etc/group
        "%_ROOTDIR%\bin\bash.exe" --login -i -c '/usr/bin/mkgroup --local > /etc/group'
    )
goto :eof

:config_syslogd
    sc query syslogd | findstr "service does not exist" > NUL:
    if ERRORLEVEL 1 goto :eof

    echo %_PREFIX% Configuring syslogd
    if not exist "%_ROOTDIR%\bin\syslogd-config" (
        echo %_PREFIX% ERROR: inetutils not installed
        goto :eof
    )
    "%_ROOTDIR%\bin\bash.exe" --login -i -c "/usr/bin/syslogd-config"
goto :eof

:config_sshd
    sc query sshd | findstr "service does not exist" > NUL:
    if ERRORLEVEL 1 goto :eof

    echo %_PREFIX% Configuring sshd
    if not exist "%_ROOTDIR%\bin\ssh-host-config" (
        echo %_PREFIX% ERROR: opensshd not installed
        goto :eof
    )
    findstr /r "^sshd:" "%_ROOTDIR%\etc\passwd"
    if not ERRORLEVEL 1 (
        echo %_PREFIX% ERROR: sshd account found in /etc/passwd
        goto :eof
    )
    "%_ROOTDIR%\bin\bash.exe" --login -i -c "/usr/bin/ssh-host-config"
    echo %_PREFIX% Disabling reverse DNS lookup by sshd
    "%_ROOTDIR%\bin\bash.exe" --login -i -c "/usr/bin/sed -i -e 's/#UseDNS yes/UseDNS no/' /etc/sshd_config"
goto :eof

:config_lsa
    reg query HKLM\SYSTEM\CurrentControlSet\Control\Lsa /v "Authentication Packages" | findstr cyglsa > NUL:
    if not ERRORLEVEL 1 goto :eof

    echo %_PREFIX% Configuring cyglsa
    "%_ROOTDIR%\bin\bash.exe" --login -i -c "/usr/bin/cyglsa-config"
goto :eof

:main
    rem Global constants.
    set _PREFIX=CYGWIN_SETUP:

    call :load_config ||exit /b 1
    call :check_admin ||exit /b 1
    call :stop_services
    call :check_for_cygwin_proc ||exit /b 1
    call :get_setup_exe
    call :setup
    call :rebaseall
    call :create_passwd
    if "%_CONFIG_SYSLOGD%" == "True" call :config_syslogd
    if "%_CONFIG_SSHD%" == "True" call :config_sshd
    call :start_services
    rem Do config_lsa last so that reboot message is last
    if "%_CONFIG_LSA%" == "True" call :config_lsa
:exit

@echo off
rem
rem Install or update Cygwin.
rem
rem Features of this batch file:
rem   * Mostly hands-free, except for stopping of running Cygwin
rem     processes and configuration of newly installed services.
rem   * Stops and starts Cygwin services.
rem   * Lists running Cygwin processes (setup.exe informs you that
rem     they are running, but does not list them).
rem   * Fetches latest setup.exe from cygwin.com.
rem   * Installs standard set of packages.
rem   * Updates all installed packages.
rem   * Runs rebaseall.
rem   * Installs standard services (syslogd, sshd).
rem   * Installs cyglsa.
rem
rem Copyright (c) 2012-2012 Tom Schutter
rem All rights reserved.
rem
rem Redistribution and use in source and binary forms, with or without
rem modification, are permitted provided that the following conditions
rem are met:
rem
rem    - Redistributions of source code must retain the above copyright
rem      notice, this list of conditions and the following disclaimer.
rem    - Redistributions in binary form must reproduce the above
rem      copyright notice, this list of conditions and the following
rem      disclaimer in the documentation and/or other materials provided
rem      with the distribution.
rem
rem THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
rem "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
rem LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
rem FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
rem COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
rem INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
rem BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
rem LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
rem CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
rem LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
rem ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
rem POSSIBILITY OF SUCH DAMAGE.
rem

setlocal
goto :main

:load_config
    set _CONFFILE=%~dp0\cygwin_setup_config.bat
    if exist "%_CONFFILE%" goto :endif_check_conffile
        echo %_PREFIX% ERROR: Configuration file "%_CONFFILE%" not found.
        exit /b 1
    :endif_check_conffile
    set _PACKAGES=
    set _ROOTDIR=
    set _SITE=
    set _CONFIG_SYSLOGD=
    set _CONFIG_SSHD=
    set _CONFIG_LSA=
    call "%_CONFFILE%"
    if "%_PACKAGES%" == "" (
        echo %_PREFIX% ERROR: _PACKAGES not defined in "%_CONFFILE%"
        exit /b 1
    )
    if "%_ROOTDIR%" == "" (
        echo %_PREFIX% ERROR: _ROOTDIR not defined in "%_CONFFILE%"
        exit /b 1
    )
    if "%_SITE%" == "" (
        echo %_PREFIX% ERROR: _SITE not defined in "%_CONFFILE%"
        exit /b 1
    )
    if "%_CONFIG_SYSLOGD%" == "" (
        echo %_PREFIX% ERROR: _CONFIG_SYSLOGD not defined in "%_CONFFILE%"
        exit /b 1
    )
    if "%_CONFIG_SSHD%" == "" (
        echo %_PREFIX% ERROR: _CONFIG_SSHD not defined in "%_CONFFILE%"
        exit /b 1
    )
    if "%_CONFIG_LSA%" == "" (
        echo %_PREFIX% ERROR: _CONFIG_LSA not defined in "%_CONFFILE%"
        exit /b 1
    )
exit /b 0

:check_admin
    rem Check for ADMIN privileges
    rem https://sites.google.com/site/eneerge/home/BatchGotAdmin

    echo %_PREFIX% Checking for Administrator privileges
    "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system" >nul 2>&1
    if not ERRORLEVEL 1 goto :endif_check_admin
        echo %_PREFIX% ERROR: You do not have Administrator privileges
        echo %_PREFIX% Rerun from a "Run as Administrator" command prompt
        exit /b 1
    :endif_check_admin
exit /b 0

:stop_services
    rem Stop all Cygwin services.
    if not exist "%_ROOTDIR%\bin\cygrunsrv.exe" goto :eof
    for /f "usebackq" %%s in (`"%_ROOTDIR%\bin\cygrunsrv.exe" --list`) do (
        echo %_PREFIX% Stopping %%s
        "%_ROOTDIR%\bin\cygrunsrv.exe" --stop %%s
    )
goto :eof

:start_service
    rem Start a single Cygwin service.
    echo %_PREFIX% Starting %1
    "%_ROOTDIR%\bin\cygrunsrv.exe" --start %1
goto :eof

:start_services
    rem Start all Cygwin services.

    rem Start syslogd first.
    for /f "usebackq" %%s in (`"%_ROOTDIR%\bin\cygrunsrv.exe" --list`) do (
        if "%%s" == "syslogd" call :start_service %%s
    )
    rem Start rest of services.
    for /f "usebackq" %%s in (`"%_ROOTDIR%\bin\cygrunsrv.exe" --list`) do (
        if not "%%s" == "syslogd" call :start_service %%s
    )
goto :eof

:check_for_cygwin_proc
    rem Check for any Cygwin processes.
    echo %_PREFIX% Checking for running Cygwin processes
    if not exist "%_ROOTDIR%\bin\ps.exe" exit /b 0
    set _TEMPFILE=%TEMP%\cygwin_setup.txt
    :retry
        "%_ROOTDIR%\bin\ps.exe" -l | findstr /v /c:"/usr/bin/ps" > "%_TEMPFILE%"
        findstr /v /r /c:"PID.*COMMAND" "%_TEMPFILE%" | findstr /r /c:"^..*" > NUL:
        if ERRORLEVEL 1 goto :ignore
        echo %_PREFIX% Found running Cygwin processes
        type "%_TEMPFILE%"
        del "%_TEMPFILE%"
        :ask_abort_retry_ignore
            set /p _ANSWER=Abort, Retry, or Ignore?
            set _ANSWER=%_ANSWER:~0,1%
            if "%_ANSWER%" == "a" exit /b 1
            if "%_ANSWER%" == "A" exit /b 1
            if "%_ANSWER%" == "r" goto :retry
            if "%_ANSWER%" == "R" goto :retry
            if "%_ANSWER%" == "i" goto :ignore
            if "%_ANSWER%" == "I" goto :ignore
        goto :ask_abort_retry_ignore
    :ignore
exit /b 0

:get_setup_exe
    rem Download latest setup.exe.
    if not exist %_ROOTDIR% (
        echo %_PREFIX% Creating %_ROOTDIR%
        mkdir "%_ROOTDIR%"
    )
    echo %_PREFIX% Fetching latest setup.exe from cygwin.com
    wget --quiet -O "%_ROOTDIR%\setup.exe" http://cygwin.com/setup.exe
goto :eof

:setup
    rem Run setup.exe.
    echo %_PREFIX% Running setup.exe for updates
    "%_ROOTDIR%\setup.exe" --site %_SITE% --quiet-mode --no-shortcuts --root "%_ROOTDIR%" --local-package-dir "%_ROOTDIR%\LocalPackageDir"
    echo %_PREFIX% Running setup.exe to install standard package set
    "%_ROOTDIR%\setup.exe" --site %_SITE% --quiet-mode --no-shortcuts --root "%_ROOTDIR%" --local-package-dir "%_ROOTDIR%\LocalPackageDir" --packages %_PACKAGES%
goto :eof

:rebaseall
    rem Run rebaseall.
    rem This should be handled by setup.exe, but at this time
    rem setup.exe does not handle all cases.  And running rebaseall
    rem unnecessarily should cause no harm.
    rem See http://cygwin.com/ml/cygwin/2012-08/msg00320.html
    echo %_PREFIX% Running rebaseall
    "%_ROOTDIR%\bin\dash.exe" -c 'cd /usr/bin; PATH=. ; rebaseall'
goto :eof

:create_passwd
    rem Create local passwd and group files.
    if not exist "%_ROOTDIR%\etc\passwd" (
        echo %_PREFIX% Creating /etc/passwd
        "%_ROOTDIR%\bin\bash.exe" --login -i -c '/usr/bin/mkpasswd --local > /etc/passwd'
    )
    if not exist "%_ROOTDIR%\etc\group" (
        echo %_PREFIX% Creating /etc/group
        "%_ROOTDIR%\bin\bash.exe" --login -i -c '/usr/bin/mkgroup --local > /etc/group'
    )
goto :eof

:config_syslogd
    sc query syslogd | findstr "service does not exist" > NUL:
    if ERRORLEVEL 1 goto :eof

    echo %_PREFIX% Configuring syslogd
    if not exist "%_ROOTDIR%\bin\syslogd-config" (
        echo %_PREFIX% ERROR: inetutils not installed
        goto :eof
    )
    "%_ROOTDIR%\bin\bash.exe" --login -i -c "/usr/bin/syslogd-config"
goto :eof

:config_sshd
    sc query sshd | findstr "service does not exist" > NUL:
    if ERRORLEVEL 1 goto :eof

    echo %_PREFIX% Configuring sshd
    if not exist "%_ROOTDIR%\bin\ssh-host-config" (
        echo %_PREFIX% ERROR: opensshd not installed
        goto :eof
    )
    findstr /r "^sshd:" "%_ROOTDIR%\etc\passwd"
    if not ERRORLEVEL 1 (
        echo %_PREFIX% ERROR: sshd account found in /etc/passwd
        goto :eof
    )
    "%_ROOTDIR%\bin\bash.exe" --login -i -c "/usr/bin/ssh-host-config"
    echo %_PREFIX% Disabling reverse DNS lookup by sshd
    "%_ROOTDIR%\bin\bash.exe" --login -i -c "/usr/bin/sed -i -e 's/#UseDNS yes/UseDNS no/' /etc/sshd_config"
goto :eof

:config_lsa
    reg query HKLM\SYSTEM\CurrentControlSet\Control\Lsa /v "Authentication Packages" | findstr cyglsa > NUL:
    if not ERRORLEVEL 1 goto :eof

    echo %_PREFIX% Configuring cyglsa
    "%_ROOTDIR%\bin\bash.exe" --login -i -c "/usr/bin/cyglsa-config"
goto :eof

:main
    rem Global constants.
    set _PREFIX=CYGWIN_SETUP:

    call :load_config ||exit /b 1
    call :check_admin ||exit /b 1
    call :stop_services
    call :check_for_cygwin_proc ||exit /b 1
    call :get_setup_exe
    call :setup
    call :rebaseall
    call :create_passwd
    if "%_CONFIG_SYSLOGD%" == "True" call :config_syslogd
    if "%_CONFIG_SSHD%" == "True" call :config_sshd
    call :start_services
    rem Do config_lsa last so that reboot message is last
    if "%_CONFIG_LSA%" == "True" call :config_lsa
:exit

add rebaseall comment

cygwin_setup.bat: add rebaseall comment


@echo off

rem
rem Licensed to the Apache Software Foundation (ASF) under one or more
rem contributor license agreements.  See the NOTICE file distributed with
rem this work for additional information regarding copyright ownership.
rem The ASF licenses this file to You under the Apache License, Version 2.0
rem (the "License"); you may not use this file except in compliance with
rem the License.  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.
rem

rem Figure out where the Spark framework is installed
call "%~dp0find-spark-home.cmd"

call "%SPARK_HOME%\bin\load-spark-env.cmd"

rem Test that an argument was given
if "x%1"=="x" (
  echo Usage: spark-class ^<class^> [^<args^>]
  exit /b 1
)

rem Find Spark jars.
if exist "%SPARK_HOME%\jars" (
  set SPARK_JARS_DIR="%SPARK_HOME%\jars"
) else (
  set SPARK_JARS_DIR="%SPARK_HOME%\assembly\target\scala-%SPARK_SCALA_VERSION%\jars"
)

if not exist "%SPARK_JARS_DIR%"\ (
  echo Failed to find Spark jars directory.
  echo You need to build Spark before running this program.
  exit /b 1
)

set LAUNCH_CLASSPATH=%SPARK_JARS_DIR%\*

rem Add the launcher build dir to the classpath if requested.
if not "x%SPARK_PREPEND_CLASSES%"=="x" (
  set LAUNCH_CLASSPATH="%SPARK_HOME%\launcher\target\scala-%SPARK_SCALA_VERSION%\classes;%LAUNCH_CLASSPATH%"
)

rem Figure out where java is.
set RUNNER=java
if not "x%JAVA_HOME%"=="x" (
  set RUNNER=%JAVA_HOME%\bin\java
) else (
  where /q "%RUNNER%"
  if ERRORLEVEL 1 (
    echo Java not found and JAVA_HOME environment variable is not set.
    echo Install Java and set JAVA_HOME to point to the Java installation directory.
    exit /b 1
  )
)

rem The launcher library prints the command to be executed in a single line suitable for being
rem executed by the batch interpreter. So read all the output of the launcher into a variable.
set LAUNCHER_OUTPUT=%temp%\spark-class-launcher-output-%RANDOM%.txt
"%RUNNER%" -Xmx128m -cp "%LAUNCH_CLASSPATH%" org.apache.spark.launcher.Main %* > %LAUNCHER_OUTPUT%
for /f "tokens=*" %%i in (%LAUNCHER_OUTPUT%) do (
  set SPARK_CMD=%%i
)
del %LAUNCHER_OUTPUT%
%SPARK_CMD%

@echo off

rem
rem Licensed to the Apache Software Foundation (ASF) under one or more
rem contributor license agreements.  See the NOTICE file distributed with
rem this work for additional information regarding copyright ownership.
rem The ASF licenses this file to You under the Apache License, Version 2.0
rem (the "License"); you may not use this file except in compliance with
rem the License.  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.
rem

rem Figure out where the Spark framework is installed
call "%~dp0find-spark-home.cmd"

call "%SPARK_HOME%\bin\load-spark-env.cmd"

rem Test that an argument was given
if "x%1"=="x" (
  echo Usage: spark-class ^<class^> [^<args^>]
  exit /b 1
)

rem Find Spark jars.
if exist "%SPARK_HOME%\jars" (
  set SPARK_JARS_DIR="%SPARK_HOME%\jars"
) else (
  set SPARK_JARS_DIR="%SPARK_HOME%\assembly\target\scala-%SPARK_SCALA_VERSION%\jars"
)

if not exist "%SPARK_JARS_DIR%"\ (
  echo Failed to find Spark jars directory.
  echo You need to build Spark before running this program.
  exit /b 1
)

set LAUNCH_CLASSPATH=%SPARK_JARS_DIR%\*

rem Add the launcher build dir to the classpath if requested.
if not "x%SPARK_PREPEND_CLASSES%"=="x" (
  set LAUNCH_CLASSPATH="%SPARK_HOME%\launcher\target\scala-%SPARK_SCALA_VERSION%\classes;%LAUNCH_CLASSPATH%"
)

rem Figure out where java is.
set RUNNER=java
if not "x%JAVA_HOME%"=="x" (
  set RUNNER=%JAVA_HOME%\bin\java
) else (
  where /q "%RUNNER%"
  if ERRORLEVEL 1 (
    echo Java not found and JAVA_HOME environment variable is not set.
    echo Install Java and set JAVA_HOME to point to the Java installation directory.
    exit /b 1
  )
)

rem The launcher library prints the command to be executed in a single line suitable for being
rem executed by the batch interpreter. So read all the output of the launcher into a variable.
:gen
set LAUNCHER_OUTPUT=%temp%\spark-class-launcher-output-%RANDOM%.txt
rem SPARK-28302: %RANDOM% would return the same number if we call it instantly after last call,
rem so we should make it sure to generate unique file to avoid process collision of writing into
rem the same file concurrently.
if exist %LAUNCHER_OUTPUT% goto :gen
"%RUNNER%" -Xmx128m -cp "%LAUNCH_CLASSPATH%" org.apache.spark.launcher.Main %* > %LAUNCHER_OUTPUT%
for /f "tokens=*" %%i in (%LAUNCHER_OUTPUT%) do (
  set SPARK_CMD=%%i
)
del %LAUNCHER_OUTPUT%
%SPARK_CMD%

[SPARK-28302][CORE] Make sure to generate unique output file for SparkLauncher on Windows

## What changes were proposed in this pull request?

When using SparkLauncher to submit applications **concurrently** with multiple threads under **Windows**, some apps would show that "The process cannot access the file because it is being used by another process" and remains in LOST state at the end. The issue can be reproduced by  this [demo](https://issues.apache.org/jira/secure/attachment/12973920/Main.scala).

After digging into the code, I find that, Windows cmd `%RANDOM%` would return the same number if we call it  instantly(e.g. < 500ms) after last call. As a result, SparkLauncher would get same output file(spark-class-launcher-output-%RANDOM%.txt) for apps. Then, the following app would hit the issue when it tries to write the same file which has already been opened for writing by another app.

We should make sure to generate unique output file for SparkLauncher on Windows to avoid this issue.

## How was this patch tested?

Tested manually on Windows.

Closes #25076 from Ngone51/SPARK-28302.

Authored-by: wuyi <315d129247cdf1c97adf1451120b7428ae20ce7e@163.com>
Signed-off-by: HyukjinKwon <2680965ad5aae29275c8fb10150cb10f5554e78b@apache.org>


::
:: Start Pylp via the terminal.
::
:: Copyright (C) 2017, Guillaume Gonnet
:: This file is under the MIT License.
@echo off
setlocal

:: Test if Python 3 is called "python3" or just "python"
where python3 >nul 2>nul
if %ERRORLEVEL% EQU 0 (
     set PYTHON=python3
) else (
     set PYTHON=python
)

:: Test if python is installed and in the PATH
where %PYTHON% >nul 2>nul
if %ERRORLEVEL% NEQ 0 (
    echo Python is not installed or not in your PATH.
    exit /b
)

:: Checks the version of Python
for /f "tokens=*" %%i in ('%PYTHON% -c "import sys;print(sys.version_info[0])"') do set PYTHON_VER=%%i
if "%PYTHON_VER:~0,1%" NEQ "3" (
    echo You must have Python 3 to execute Pylp.
    exit /b
)

:: Start Pylp
%PYTHON% "%~dp0pylp\cli\cli.py" %*

::
:: Start Pylp CLI.
::
:: Copyright (C) 2017 The Pylp Authors.
:: This file is under the MIT License.
@echo off
setlocal

:: Test if Python 3 is called "python3" or just "python"
where python3 >nul 2>nul
if %ERRORLEVEL% EQU 0 (
     set PYTHON=python3
) else (
     set PYTHON=python
)

:: Test if python is installed and in the PATH
where %PYTHON% >nul 2>nul
if %ERRORLEVEL% NEQ 0 (
    echo Python is not installed or not in your PATH.
    exit /b
)

:: Checks the version of Python
for /f "tokens=*" %%i in ('%PYTHON% -c "import sys;print(sys.version_info[0])"') do set PYTHON_VER=%%i
if "%PYTHON_VER:~0,1%" NEQ "3" (
    echo You must have Python 3 to execute Pylp.
    exit /b
)

:: Start Pylp
%PYTHON% "%~dp0pylp\cli\cli.py" %*

Change copyright

Change copyright


robocopy dist ../gb-grocery-iis /MIR /XD .git
ping 127.0.0.1 -n 6 > nul
pushd ..\gb-grocery-iis
git add .
git commit -m "new version"
git push azure master
popd

add azure deploy script

add azure deploy script


<!-- : Begin batch script
@echo off
cscript //nologo "%~f0?.wsf"
exit /b

----- Begin wsf script --->
<job><script language="VBScript">

Private OSDrive

strComputer = "."

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

Set colDiskDrives = objWMIService.ExecQuery("SELECT * FROM Win32_DiskDrive")

Set colOperatingSystems = objWMIService.ExecQuery ("Select SystemDrive from Win32_OperatingSystem")

For Each objOperatingSystem in colOperatingSystems
    On Error Resume Next
    '' get the OS System Drive if exists
    OSDrive = objOperatingSystem.Properties_("SystemDrive")
    If Err.Number <> 0 Then
        OSDrive = Err.Description
        Err.Clear
    End If
Next

For Each objDrive In colDiskDrives
    strDeviceID = Replace(objDrive.DeviceID, "\", "\\")
    Set colPartitions = objWMIService.ExecQuery _
        ("ASSOCIATORS OF {Win32_DiskDrive.DeviceID=""" & _
            strDeviceID & """} WHERE AssocClass = " & _
                "Win32_DiskDriveToDiskPartition")
    For Each objPartition In colPartitions
        Set colLogicalDisks = objWMIService.ExecQuery _
            ("ASSOCIATORS OF {Win32_DiskPartition.DeviceID=""" & _
                objPartition.DeviceID & """} WHERE AssocClass = " & _
                    "Win32_LogicalDiskToPartition")
        For Each objLogicalDisk In colLogicalDisks
            Wscript.Echo "device: """ & Replace(objDrive.DeviceID, "\", "\\") & """"
            Wscript.Echo "description: """ & objDrive.Caption & """"
            Wscript.Echo "size: """ & Int(objDrive.Size / 1e+9) & " GB"""
            Wscript.Echo "mountpoint: """ & objLogicalDisk.DeviceID & """"
            Wscript.Echo "name: """ & objLogicalDisk.DeviceID & """"

            If objLogicalDisk.DeviceID = OSDrive Then
              Wscript.Echo "system: True"
            Else
              Wscript.Echo "system: False"
            End If

            Wscript.Echo ""
        Next
    Next
Next
</script></job>

<!-- : Begin batch script
@echo off
cscript //nologo "%~f0?.wsf"
exit /b

----- Begin wsf script --->
<job><script language="VBScript">

Private OSDrive

strComputer = "."

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

Set colDiskDrives = objWMIService.ExecQuery("SELECT * FROM Win32_DiskDrive")

Set colOperatingSystems = objWMIService.ExecQuery ("SELECT SystemDrive FROM Win32_OperatingSystem")

For Each objOperatingSystem in colOperatingSystems
    On Error Resume Next
    '' get the OS System Drive if exists
    OSDrive = objOperatingSystem.Properties_("SystemDrive")
    If Err.Number <> 0 Then
        OSDrive = Err.Description
        Err.Clear
    End If
Next

For Each objDrive In colDiskDrives
    strDeviceID = Replace(objDrive.DeviceID, "\", "\\")
    Set colPartitions = objWMIService.ExecQuery _
        ("ASSOCIATORS OF {Win32_DiskDrive.DeviceID=""" & _
            strDeviceID & """} WHERE AssocClass = " & _
                "Win32_DiskDriveToDiskPartition")
    For Each objPartition In colPartitions
        Set colLogicalDisks = objWMIService.ExecQuery _
            ("ASSOCIATORS OF {Win32_DiskPartition.DeviceID=""" & _
                objPartition.DeviceID & """} WHERE AssocClass = " & _
                    "Win32_LogicalDiskToPartition")
        For Each objLogicalDisk In colLogicalDisks
            Wscript.Echo "device: """ & Replace(objDrive.DeviceID, "\", "\\") & """"
            Wscript.Echo "description: """ & objDrive.Caption & """"
            Wscript.Echo "size: """ & Int(objDrive.Size / 1e+9) & " GB"""
            Wscript.Echo "mountpoint: """ & objLogicalDisk.DeviceID & """"
            Wscript.Echo "name: """ & objLogicalDisk.DeviceID & """"

            If objLogicalDisk.DeviceID = OSDrive Then
              Wscript.Echo "system: True"
            Else
              Wscript.Echo "system: False"
            End If

            Wscript.Echo ""
        Next
    Next
Next
</script></job>

Fix query syntax to match that of existing


mkdir build
cd build

:: Compilation of Windows shared library is not supported (see https://github.com/coin-or/qpOASES/pull/109)
cmake ^
    -G "Ninja" ^
    -DCMAKE_INSTALL_PREFIX=%LIBRARY_PREFIX% ^
    -DCMAKE_BUILD_TYPE=Release ^
    -DBUILD_SHARED_LIBS:BOOL=ON ^
    -DBUILD_TESTING:BOOL=ON ^
    %SRC_DIR%
if errorlevel 1 exit 1

:: Build.
cmake --build . --config Release
if errorlevel 1 exit 1

:: Install.
cmake --build . --config Release --target install
if errorlevel 1 exit 1

:: Test.
ctest --output-on-failure -C Release
if errorlevel 1 exit 1

Create bld.bat

Create bld.bat


:: SPDX-License-Identifier: MIT

set wd=%~dp0\..\cmd\apidoc

set mainPath=github.com\caixw\apidoc

set varsPath=%mainPath%\v5\internal\vars

set builddate=%date:~0,4%%date:~5,2%%date:~8,2%

for /f "delims=" %%t in ('git rev-parse HEAD') do set hash=%%t

echo compile
go build -o %wd%\apidoc.exe -ldflags "-X %varsPath%.buildDate=%builddate% -X %varsPath%.commitHash=%hash%" -v %wd%

:: SPDX-License-Identifier: MIT

set wd=%~dp0\..\cmd\apidoc

set mainPath=github.com\caixw\apidoc

set varsPath=%mainPath%\v6\internal\vars

set builddate=%date:~0,4%%date:~5,2%%date:~8,2%

for /f "delims=" %%t in ('git rev-parse HEAD') do set hash=%%t

echo compile
go build -o %wd%\apidoc.exe -ldflags "-X %varsPath%.buildDate=%builddate% -X %varsPath%.commitHash=%hash%" -v %wd%

修正 build.cmd 编译指向错误

build: 修正 build.cmd 编译指向错误


@echo off
rem dennyhalim.com
rem this will be copied after first reboot and then run after next reboot

#replace defaultlayouts before it gets created
move "%Public%\..\Default\AppData\Local\Microsoft\Windows\Shell\DefaultLayouts.xml" "%Public%\..\Default\AppData\Local\Microsoft\Windows\Shell\DefaultLayouts.dennyhalim"
copy /y "%WINDIR%\Setup\Files\DefaultLayouts.xml" "%Public%\..\Default\AppData\Local\Microsoft\Windows\Shell\DefaultLayouts.xml"
move "%SystemRoot%\SysWOW64\OneDriveSetup.exe" "%SystemRoot%\SysWOW64\OneDriveSetup.dennyhalim"
move "%SystemRoot%\System32\OneDriveSetup.exe" "%SystemRoot%\System32\OneDriveSetup.dennyhalim"
rem move "%windir%\SystemApps\Microsoft.Windows.Cortana_cw5n1h2txyewy" "%windir%\SystemApps\Microsoft.Windows.Cortana_cw5n1h2txyewy.dennyhalim"
rem startmenu disabled if shellex disabled
rem move "%windir%\SystemApps\ShellExperienceHost_cw5n1h2txyewy" "%windir%\SystemApps\ShellExperienceHost_cw5n1h2txyewy.dennyhalim"

sc.exe config wuauserv start= demand
sc.exe config DiagTrack start= disabled
sc.exe config dmwappushservice start= disabled
sc.exe config RetailDemo start= disabled
sc.exe config lfsvc start= disabled

reg load HKLM\DEFAULT "%Public%\..\default\ntuser.dat"
reg add "HKLM\DEFAULT\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced\People /v PeopleBand /t REG_DWORD /d 0 /f
reg add "HKLM\DEFAULT\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" /v HideFileExt /t REG_DWORD /d 0 /f
reg add "HKLM\DEFAULT\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" /v Start_TrackProgs /t REG_DWORD /d 1 /f
reg add "HKLM\DEFAULT\Software\Microsoft\Windows\CurrentVersion\AdvertisingInfo" /v Enabled /t REG_DWORD /d 0 /f
reg add "HKLM\DEFAULT\Software\MicrosoftMicrosoft\Input\TIPC" /v Enabled /t REG_DWORD /d 0 /f
reg add "HKLM\DEFAULT\Software\Microsoft\Windows\CurrentVersion\BackgroundAccessApplications" /v GlobalUserDisabled /t REG_DWORD /d 1 /f
reg add "HKLM\DEFAULT\Software\Microsoft\Windows\CurrentVersion\DeviceAccess\Global\A8804298-2D5F-42E3-9531-9C8C39EB29CE" /v Value /t REG_DWORD /d 0 /f
reg delete "HKLM\DEFAULT\Software\Microsoft\Windows\CurrentVersion\Run" /v OneDriveSetup /F
reg unload HKLM\DEFAULT

reg add "HKLM\SOFTWARE\Policies\Microsoft\Windows\DataCollection" /v AllowTelemetry /t REG_DWORD /d 0 /f
reg add "HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" /v DeferUpgrade /t REG_DWORD /d 1 /f
reg add "HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" /v BranchReadinessLevel /t REG_DWORD /d 32 /f
reg add "HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" /v DeferFeatureUpdates /t REG_DWORD /d 1 /f
reg add "HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" /v DeferFeatureUpdatesPeriodinDays /t REG_DWORD /d 365 /f
reg add "HKLM\SOFTWARE\Policies\Microsoft\Windows\Windows Search" /v AllowCortana /t REG_DWORD /d 0 /f
reg add "HKLM\SOFTWARE\Microsoft\WcmSvc\wifinetworkmanager\features" /v WiFiSenseCredShared /t REG_DWORD /d 0 /f
reg add "HKLM\SOFTWARE\Microsoft\WcmSvc\wifinetworkmanager\features" /v WiFiSenseOpen /t REG_DWORD /d 0 /f

cscript "%WINDIR%\System32\Printing_Admin_Scripts\en-US\prndrvr.vbs" -a -m "Canon LBP2900" -i "%WINDIR%\Setup\Files\CanonLBP2900\CNAB4STD.inf"
cscript "%WINDIR%\System32\Printing_Admin_Scripts\en-US\prndrvr.vbs" -a -m "Canon G2000 series Printer" -i "%WINDIR%\Setup\Files\CanonG2000\Driver\G2000P6.inf"
rem move "%WINDIR%\Setup\Drivers\*" "%WINDIR%\INF"

schtasks /change /TN "\Microsoft\Windows\Application Experience\Microsoft Compatibility Appraiser" /DISABLE
schtasks /change /TN "\Microsoft\Windows\Application Experience\ProgramDataUpdater" /DISABLE
schtasks /change /TN "\Microsoft\Windows\Customer Experience Improvement Program\Consolidator" /DISABLE
schtasks /change /TN "\Microsoft\Windows\Customer Experience Improvement Program\KernelCeipTask" /DISABLE
schtasks /change /TN "\Microsoft\Windows\Customer Experience Improvement Program\UsbCeip" /DISABLE

"%WINDIR%\Setup\Files\chocolatey.exe" /S
"%WINDIR%\Setup\Files\Firefox Setup 52.6.0esr.exe" -ms
"%WINDIR%\Setup\Files\vlc-3.0.1-win64.exe" /L=1033 /S
"%WINDIR%\Setup\Files\SumatraPDF-3.1.2-64-install.exe" /S
Msiexec /q /I "%WINDIR%\Setup\Files\7z1801-x64.msi"
Msiexec /q /I "%WINDIR%\Setup\Files\GoogleChromeStandaloneEnterprise64.msi"
Msiexec /q /I "%WINDIR%\Setup\Files\LibreOffice_5.4.6_Win_x64.msi"
rem "%WINDIR%\Setup\Files\avira_pc_cleaner_en.exe" /s
"%WINDIR%\Setup\Files\mb3-setup-consumer-3.4.5.2467-1.0.342-1.0.4664.exe" /VERYSILENT /SUPPRESSMSGBOXES /NORESTART /SP-
"%WINDIR%\Setup\Files\avast_business_antivirus_managed_setup_offline_silent.exe"

mkdir "%Public%\Desktop.dennyhalim"
move "%Public%\Desktop\*.*" "%Public%\Desktop.dennyhalim"
PowerShell -NoProfile -ExecutionPolicy Bypass -Command "& '%WINDIR%\Setup\Files\setup.ps1'"

rem "%WINDIR%\Setup-githubbox.exe"

@echo off
rem dennyhalim.com
rem this will be copied after first reboot and then run after next reboot

#replace defaultlayouts before it gets created
move "%Public%\..\Default\AppData\Local\Microsoft\Windows\Shell\DefaultLayouts.xml" "%Public%\..\Default\AppData\Local\Microsoft\Windows\Shell\DefaultLayouts.dennyhalim"
copy /y "%WINDIR%\Setup\Files\DefaultLayouts.xml" "%Public%\..\Default\AppData\Local\Microsoft\Windows\Shell\DefaultLayouts.xml"
move "%SystemRoot%\SysWOW64\OneDriveSetup.exe" "%SystemRoot%\SysWOW64\OneDriveSetup.dennyhalim"
move "%SystemRoot%\System32\OneDriveSetup.exe" "%SystemRoot%\System32\OneDriveSetup.dennyhalim"
rem move "%windir%\SystemApps\Microsoft.Windows.Cortana_cw5n1h2txyewy" "%windir%\SystemApps\Microsoft.Windows.Cortana_cw5n1h2txyewy.dennyhalim"
rem startmenu disabled if shellex disabled
rem move "%windir%\SystemApps\ShellExperienceHost_cw5n1h2txyewy" "%windir%\SystemApps\ShellExperienceHost_cw5n1h2txyewy.dennyhalim"

sc.exe config wuauserv start= demand
sc.exe config DiagTrack start= disabled
sc.exe config dmwappushservice start= disabled
sc.exe config RetailDemo start= disabled
sc.exe config lfsvc start= disabled

reg load HKLM\DEFAULT "%Public%\..\default\ntuser.dat"
reg add "HKLM\DEFAULT\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced\People /v PeopleBand /t REG_DWORD /d 0 /f
reg add "HKLM\DEFAULT\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" /v HideFileExt /t REG_DWORD /d 0 /f
reg add "HKLM\DEFAULT\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" /v Start_TrackProgs /t REG_DWORD /d 1 /f
reg add "HKLM\DEFAULT\Software\Microsoft\Windows\CurrentVersion\AdvertisingInfo" /v Enabled /t REG_DWORD /d 0 /f
reg add "HKLM\DEFAULT\Software\MicrosoftMicrosoft\Input\TIPC" /v Enabled /t REG_DWORD /d 0 /f
reg add "HKLM\DEFAULT\Software\Microsoft\Windows\CurrentVersion\BackgroundAccessApplications" /v GlobalUserDisabled /t REG_DWORD /d 1 /f
reg add "HKLM\DEFAULT\Software\Microsoft\Windows\CurrentVersion\DeviceAccess\Global\A8804298-2D5F-42E3-9531-9C8C39EB29CE" /v Value /d Deny /f
reg delete "HKLM\DEFAULT\Software\Microsoft\Windows\CurrentVersion\Run" /v OneDriveSetup /F
reg unload HKLM\DEFAULT

reg add "HKLM\SOFTWARE\Policies\Microsoft\Windows\DataCollection" /v AllowTelemetry /t REG_DWORD /d 0 /f
reg add "HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" /v DeferUpgrade /t REG_DWORD /d 1 /f
reg add "HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" /v BranchReadinessLevel /t REG_DWORD /d 32 /f
reg add "HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" /v DeferFeatureUpdates /t REG_DWORD /d 1 /f
reg add "HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" /v DeferFeatureUpdatesPeriodinDays /t REG_DWORD /d 365 /f
reg add "HKLM\SOFTWARE\Policies\Microsoft\Windows\Windows Search" /v AllowCortana /t REG_DWORD /d 0 /f
reg add "HKLM\SOFTWARE\Microsoft\WcmSvc\wifinetworkmanager\features" /v WiFiSenseCredShared /t REG_DWORD /d 0 /f
reg add "HKLM\SOFTWARE\Microsoft\WcmSvc\wifinetworkmanager\features" /v WiFiSenseOpen /t REG_DWORD /d 0 /f

cscript "%WINDIR%\System32\Printing_Admin_Scripts\en-US\prndrvr.vbs" -a -m "Canon LBP2900" -i "%WINDIR%\Setup\Files\CanonLBP2900\CNAB4STD.inf"
cscript "%WINDIR%\System32\Printing_Admin_Scripts\en-US\prndrvr.vbs" -a -m "Canon G2000 series Printer" -i "%WINDIR%\Setup\Files\CanonG2000\Driver\G2000P6.inf"
rem move "%WINDIR%\Setup\Drivers\*" "%WINDIR%\INF"

schtasks /change /TN "\Microsoft\Windows\Application Experience\Microsoft Compatibility Appraiser" /DISABLE
schtasks /change /TN "\Microsoft\Windows\Application Experience\ProgramDataUpdater" /DISABLE
schtasks /change /TN "\Microsoft\Windows\Customer Experience Improvement Program\Consolidator" /DISABLE
schtasks /change /TN "\Microsoft\Windows\Customer Experience Improvement Program\KernelCeipTask" /DISABLE
schtasks /change /TN "\Microsoft\Windows\Customer Experience Improvement Program\UsbCeip" /DISABLE

"%WINDIR%\Setup\Files\chocolatey.exe" /S
"%WINDIR%\Setup\Files\Firefox Setup 52.6.0esr.exe" -ms
"%WINDIR%\Setup\Files\vlc-3.0.1-win64.exe" /L=1033 /S
"%WINDIR%\Setup\Files\SumatraPDF-3.1.2-64-install.exe" /S
Msiexec /q /I "%WINDIR%\Setup\Files\7z1801-x64.msi"
Msiexec /q /I "%WINDIR%\Setup\Files\GoogleChromeStandaloneEnterprise64.msi"
Msiexec /q /I "%WINDIR%\Setup\Files\LibreOffice_5.4.6_Win_x64.msi"
rem "%WINDIR%\Setup\Files\avira_pc_cleaner_en.exe" /s
"%WINDIR%\Setup\Files\mb3-setup-consumer-3.4.5.2467-1.0.342-1.0.4664.exe" /VERYSILENT /SUPPRESSMSGBOXES /NORESTART /SP-
"%WINDIR%\Setup\Files\avast_business_antivirus_managed_setup_offline_silent.exe"

mkdir "%Public%\Desktop.dennyhalim"
move "%Public%\Desktop\*.*" "%Public%\Desktop.dennyhalim"
PowerShell -NoProfile -ExecutionPolicy Bypass -Command "& '%WINDIR%\Setup\Files\setup.ps1'"

rem "%WINDIR%\Setup-githubbox.exe"

Update SetupComplete.cmd

Update SetupComplete.cmd


xcopy depends\\log4z include\\log4z /s /y  /i
xcopy depends\\proto4z include\\proto4z /s /y  /i
xcopy depends\\rc4 include\\rc4 /s /y  /i
xcopy depends\\log4z\\lib lib /s /y  /i

xcopy include D:\\pj5\\CPP\\depends_win\\include /s /y  /i
xcopy lib D:\\pj5\\CPP\\depends_win\\lib /s /y  /i

xcopy include D:\\pj5\\CPP\\depends_linux\\include /s /y  /i
xcopy lib D:\\pj5\\CPP\\depends_linux\\lib /s /y  /i

pause

xcopy depends\\log4z include\\log4z /s /y  /i
xcopy depends\\proto4z include\\proto4z /s /y  /i
xcopy depends\\rc4 include\\rc4 /s /y  /i
xcopy depends\\log4z\\lib lib /s /y  /i

set destPath=E:\\github\\mini-breeze\\trunk
rem set destPath=D:\\pj5\\CPP

xcopy include %destPath%\\depends_win\\include /s /y  /i
xcopy lib %destPath%\\depends_win\\lib /s /y  /i

xcopy include %destPath%\\depends_linux\\include /s /y  /i
xcopy lib %destPath%\\depends_linux\\lib /s /y  /i

pause

update bat

update bat


## instalation steps

mkdir GoUI && cd GoUI

set GOPATH=./GoUI

set PATH=%PATH%;C:\Users\JOEL\Desktop\Go\GoUI\bin

go get github.com/JoelTinx/GoUI

go get github.com/lxn/walk

go get github.com/Knetic/govaluate

go get github.com/akavel/rsrc

cd src/github.com/JoelTinx/GoUI

rsrc -manifest main.manifest -o rsrc.syso

go build

go build -ldflags="-H windowsgui"

Append config.bat file for instalation auto


echo ON

if "%PY3K%" == "1" (
  powershell -Command "(gc engine\SCons\Errors.py) -replace 'exceptions', 'builtins --no-test' | Out-File engine\SCons\Errors.py"
  powershell -Command "Get-Content "engine\SCons\Util.py" | select -First 38" > engine\SCons\Util.back
  if errorlevel 1 exit 1
  more +39 engine\SCons\Util.py >> engine\SCons\Util.back
  if errorlevel 1 exit 1
  more engine\SCons\Util.back
  if errorlevel 1 exit 1
  del engine\SCons\Util.py
  if errorlevel 1 exit 1
  move engine\SCons\Util.back engine\SCons\Util.py
  if errorlevel 1 exit 1
  2to3 --output-dir=engine\SCons3 -W -n engine\SCons
  if errorlevel 1 exit 1
  rmdir engine\SCons /s /q
  if errorlevel 1 exit 1
  move engine\SCons3 engine/SCons
  if errorlevel 1 exit 1
  powershell -Command "Get-Content ".\script\scons" | select -First 58" > script\scons.back
  if errorlevel 1 exit 1
  more +64 script\scons >> script\scons.back
  if errorlevel 1 exit 1
  del script\scons
  if errorlevel 1 exit 1
  move script\scons.back script\scons
  if errorlevel 1 exit 1
  2to3 -w -n script\scons
  if errorlevel 1 exit 1
  2to3 -w -n script\sconsign
  if errorlevel 1 exit 1
  2to3 -w -n script\scons-time
  if errorlevel 1 exit 1
  powershell -Command "Get-Content ".\setup.py" | select -First 49" > setup.back
  if errorlevel 1 exit 1
  more +54 setup.py >> setup.back
  if errorlevel 1 exit 1
  del setup.py
  if errorlevel 1 exit 1
  move setup.back setup.py
  if errorlevel 1 exit 1
)

"%PYTHON%" setup.py install --standard-lib
if errorlevel 1 exit 1

echo ON

if "%PY3K%" == "1" (
  powershell -Command "(gc engine\SCons\Errors.py) -replace 'exceptions', 'builtins --no-test' | Out-File engine\SCons\Errors.py"
  if errorlevel 1 exit 1
  powershell -Command "Get-Content "engine\SCons\Util.py" | select -First 38" > engine\SCons\Util.back
  if errorlevel 1 exit 1
  more +39 engine\SCons\Util.py >> engine\SCons\Util.back
  if errorlevel 1 exit 1
  more engine\SCons\Util.back
  if errorlevel 1 exit 1
  del engine\SCons\Util.py
  if errorlevel 1 exit 1
  move engine\SCons\Util.back engine\SCons\Util.py
  if errorlevel 1 exit 1
  2to3 --output-dir=engine\SCons3 -W -n engine\SCons
  if errorlevel 1 exit 1
  rmdir engine\SCons /s /q
  if errorlevel 1 exit 1
  move engine\SCons3 engine/SCons
  if errorlevel 1 exit 1
  powershell -Command "Get-Content ".\script\scons" | select -First 58" > script\scons.back
  if errorlevel 1 exit 1
  more +64 script\scons >> script\scons.back
  if errorlevel 1 exit 1
  del script\scons
  if errorlevel 1 exit 1
  move script\scons.back script\scons
  if errorlevel 1 exit 1
  2to3 -w -n script\scons
  if errorlevel 1 exit 1
  2to3 -w -n script\sconsign
  if errorlevel 1 exit 1
  2to3 -w -n script\scons-time
  if errorlevel 1 exit 1
  powershell -Command "Get-Content ".\setup.py" | select -First 49" > setup.back
  if errorlevel 1 exit 1
  more +54 setup.py >> setup.back
  if errorlevel 1 exit 1
  del setup.py
  if errorlevel 1 exit 1
  move setup.back setup.py
  if errorlevel 1 exit 1
)

"%PYTHON%" setup.py install --standard-lib
if errorlevel 1 exit 1

Update bld.bat

Update bld.bat


@echo off
setlocal

set "output=nul"
set "times=1"

:help

:parseArgs

if "%~1" == "" goto main

if /i "%~1" == "-?" goto help
if /i "%~1" == "-h" goto help
if /i "%~1" == "--help" goto help

if /i "%~1" == "-t" (
    set "times=%~2"
    shift
)

if /i "%~1" == "--times" (
    set "times=%~2"
    shift
)

if /i "%~1" == "-o" (
    set "output=%~2"
    shift
)

if /i "%~1" == "--output" (
    set "output=%~2"
    shift
)

shift

:curl

@powershell -NoProfile "iwr %~1 -OutFile %~2" 2> nul

goto :eof

:downloadPackage

set "url=https://www.nuget.org/api/v2/package/%~1"
call :curl "%url%" %2

goto :eof

:main

for /l %%i in (1, 1, %times%) do (
    call :downloadPackage "%package%" "%output%"
)

Add the logic for the Windows script

Add the logic for the Windows script


@echo ==== STARTING ====
@echo.

@IF EXIST .\dist\ (
    @echo ^=^=^> Remove dist folder:
    @RMDIR /S .\dist
)
@REM ) ELSE (
@REM )

@echo.
@echo ^=^=^> Building app:
@call npm run build

@echo.
@echo ^=^=^> Copying not scanned files:
XCOPY /v .\CNAME .\dist
XCOPY /v .\LICENSE .\dist
XCOPY /v .\README.md .\dist
XCOPY /v .\Makefile .\dist
XCOPY /v .\deploy.bat .\dist

@echo.
@echo ^=^=^> Checkout master branch:
@call git checkout master

@echo.
@echo ^=^=^> Apply dist and clean unwanted files and folders:
XCOPY /s /v /h /y .\dist\* .\
@RMDIR /S /Q .\dist

@echo.
@echo ^=^=^> Commit changes to master:
@call git add .
@call git commit -m ":rocket: deploy website"
@call git push origin master

@echo.
@echo ^=^=^> Go back to source:
@call checkout develop

deploy batch

deploy batch


::This is a near full-circle deployment script for PSDLE.
::It does two major things:
:: - ./chrome/7-zip.bat - Zip up the PSDLE chrome extension properly for the webstore (and then opens the webstore for uploading).
:: - ./deploy-sync.bat  - Copy psdle.js, psdle.user.js, and psdle.min.js to the gh-pages branch for everything else.
::Generally, only actual developers will find this useful. The 7-zip.bat is universally functional though.
::jsmin is expected to be in PATH
::Read deploy-sync.bat's comments for more info

@echo off

::Update version numbers (JSON and TXT associated with proper text editors)
start /wait chrome/psdle/manifest.json
start /wait psdle.user.txt

::Create min version
jsmin <psdle.js >psdle.min.js "PSDLE, (c) RePod, https://github.com/RePod/psdle/blob/master/LICENSE"
::Create userscript version
copy psdle.user.txt+psdle.js /A /D psdle.user.js /B /Y

::Move into chrome directory, zip it, then return here.
cd chrome && call "7-zip.bat" && cd ..
::Open the chrome extension editing page on webstore.
explorer "https://chrome.google.com/webstore/developer/edit/jdjhhapoddhnimgdemnpbfagndcnmhii"

::Checkout psdle.js, psdle.user.js, and psdle.min.js to gh-pages.
call "deploy-sync.bat"

pause

::This is a near full-circle deployment script for PSDLE.
::It does two major things:
:: - ./chrome/7-zip.bat - Zip up the PSDLE chrome extension properly for the webstore (and then opens the webstore for uploading).
:: - ./deploy-sync.bat  - Copy psdle.js, psdle.user.js, and psdle.min.js to the gh-pages branch for everything else.
::Generally, only actual developers will find this useful. The 7-zip.bat is universally functional though.
::jsmin is expected to be in PATH
::Read deploy-sync.bat's comments for more info

@echo off

::Update version numbers (very specific quality of life n++ening)
start "" /wait "C:\Program Files\Notepad++\notepad++.exe" -nosession -n9 "chrome/psdle/manifest.json"
start "" /wait "C:\Program Files\Notepad++\notepad++.exe" -nosession -n7 "psdle.user.txt"

::Create min version
jsmin <psdle.js >psdle.min.js "PSDLE, (c) RePod, https://github.com/RePod/psdle/blob/master/LICENSE"
::Create userscript version
copy psdle.user.txt+psdle.js /A /D psdle.user.js /B /Y

::Move into chrome directory, zip it, then return here.
cd chrome && call "7-zip.bat" && cd ..
::Open the chrome extension editing page on webstore.
explorer "https://chrome.google.com/webstore/developer/edit/jdjhhapoddhnimgdemnpbfagndcnmhii"

::Checkout psdle.js, psdle.user.js, and psdle.min.js to gh-pages.
call "deploy-sync.bat"

pause

Deploy - Even easier

Deploy - Even easier


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

:: ----------------------
:: KUDU Deployment Script
:: Version: 1.0.6
:: ----------------------

:: 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
)

:: 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
)
IF NOT DEFINED DEPLOYMENT_TEMP (
  SET DEPLOYMENT_TEMP=%temp%\___deployTemp%random%
  SET CLEAN_LOCAL_DEPLOYMENT_TEMP=true
)

IF DEFINED CLEAN_LOCAL_DEPLOYMENT_TEMP (
  IF EXIST "%DEPLOYMENT_TEMP%" rd /s /q "%DEPLOYMENT_TEMP%"
  mkdir "%DEPLOYMENT_TEMP%"
)

IF DEFINED MSBUILD_PATH goto MsbuildPathDefined
SET MSBUILD_PATH=%ProgramFiles(x86)%\MSBuild\14.0\Bin\MSBuild.exe
:MsbuildPathDefined

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: Deployment
:: ----------

echo Handling backend WebApi project.

:: 1. Restore NuGet packages
IF /I "AzureFunctions.sln" NEQ "" (
  call :ExecuteCmd nuget restore "%DEPLOYMENT_SOURCE%\AzureFunctions.sln"
  IF !ERRORLEVEL! NEQ 0 goto error
)

:: 2. Build to the temporary path
IF /I "%IN_PLACE_DEPLOYMENT%" NEQ "1" (
  call :ExecuteCmd "%MSBUILD_PATH%" "%DEPLOYMENT_SOURCE%\AzureFunctions\AzureFunctions.csproj" /nologo /verbosity:m /t:Build /t:pipelinePreDeployCopyAllFilesToOneFolder /p:_PackageTempDir="%DEPLOYMENT_TEMP%";AutoParameterizationWebConfigConnectionStrings=false;Configuration=Release;UseSharedCompilation=false /p:SolutionDir="%DEPLOYMENT_SOURCE%\.\\" %SCM_BUILD_ARGS%
) ELSE (
  call :ExecuteCmd "%MSBUILD_PATH%" "%DEPLOYMENT_SOURCE%\AzureFunctions\AzureFunctions.csproj" /nologo /verbosity:m /t:Build /p:AutoParameterizationWebConfigConnectionStrings=false;Configuration=Release;UseSharedCompilation=false /p:SolutionDir="%DEPLOYMENT_SOURCE%\.\\" %SCM_BUILD_ARGS%
)

IF !ERRORLEVEL! NEQ 0 goto error

:: 3. KuduSync
IF /I "%IN_PLACE_DEPLOYMENT%" NEQ "1" (
  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"
  IF !ERRORLEVEL! NEQ 0 goto error
)

echo Handling frontend Angular2 project.

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

:: 5. Install npm packages
IF EXIST "%DEPLOYMENT_TARGET%\package.json" (
  pushd "%DEPLOYMENT_TARGET%"

  call :ExecuteCmd npm install
  IF !ERRORLEVEL! NEQ 0 (
    call :ExecuteCmd npm install
    IF !ERRORLEVEL! NEQ 0 goto error
  )

  call :ExecuteCmd npm run jspm:i
  IF !ERRORLEVEL! NEQ 0 (
    call :ExecuteCmd npm run jspm:i
    IF !ERRORLEVEL! NEQ 0 goto error
  )

  call :ExecuteCmd npm run typings install
  IF !ERRORLEVEL! NEQ 0 goto error

  call :ExecuteCmd gulp
  IF !ERRORLEVEL! NEQ 0 goto error

  call :ExecuteCmd npm run tsc
  IF !ERRORLEVEL! NEQ 0 goto error

  call :ExecuteCmd npm run jspm:bundle
  IF !ERRORLEVEL! NEQ 0 goto error

  ::call :ExecuteCmd npm run uglifyjs
  ::IF !ERRORLEVEL! NEQ 0 goto error

  popd
)

:: 7. Install bower
IF EXIST "%DEPLOYMENT_TARGET%\bower.json" (
  pushd "%DEPLOYMENT_TARGET%"

  call :ExecuteCmd bower install
  IF !ERRORLEVEL! NEQ 0 goto error
  popd
)

:: 8. Copy templates-update webjob
SET WEBJOB_PATH=%HOME%\site\wwwroot\App_Data\jobs\triggered\templates-update
IF NOT EXIST "%WEBJOB_PATH%" (
  mkdir "%WEBJOB_PATH%"
)

copy "%DEPLOYMENT_SOURCE%\WebJobs\templates-update\templates-update.cmd" "%WEBJOB_PATH%"
copy "%DEPLOYMENT_SOURCE%\WebJobs\templates-update\settings.job" "%WEBJOB_PATH%"

:: 9. update build.txt
call :ExecuteCmd echo %SCM_COMMIT_ID% > %DEPLOYMENT_TARGET%\build.txt
IF !ERRORLEVEL! NEQ 0 (
  call :ExecuteCmd echo %SCM_COMMIT_ID% > %DEPLOYMENT_TARGET%\build.txt
  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.

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

:: ----------------------
:: KUDU Deployment Script
:: Version: 1.0.6
:: ----------------------

:: 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
)

:: 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
)
IF NOT DEFINED DEPLOYMENT_TEMP (
  SET DEPLOYMENT_TEMP=%temp%\___deployTemp%random%
  SET CLEAN_LOCAL_DEPLOYMENT_TEMP=true
)

IF DEFINED CLEAN_LOCAL_DEPLOYMENT_TEMP (
  IF EXIST "%DEPLOYMENT_TEMP%" rd /s /q "%DEPLOYMENT_TEMP%"
  mkdir "%DEPLOYMENT_TEMP%"
)

IF DEFINED MSBUILD_PATH goto MsbuildPathDefined
SET MSBUILD_PATH=%ProgramFiles(x86)%\MSBuild\14.0\Bin\MSBuild.exe
:MsbuildPathDefined

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: Deployment
:: ----------

echo Handling backend WebApi project.

:: 1. Restore NuGet packages
IF /I "AzureFunctions.sln" NEQ "" (
  call :ExecuteCmd nuget restore "%DEPLOYMENT_SOURCE%\AzureFunctions.sln"
  IF !ERRORLEVEL! NEQ 0 goto error
)

:: 2. Build to the temporary path
IF /I "%IN_PLACE_DEPLOYMENT%" NEQ "1" (
  call :ExecuteCmd "%MSBUILD_PATH%" "%DEPLOYMENT_SOURCE%\AzureFunctions\AzureFunctions.csproj" /nologo /verbosity:m /t:Build /t:pipelinePreDeployCopyAllFilesToOneFolder /p:_PackageTempDir="%DEPLOYMENT_TEMP%";AutoParameterizationWebConfigConnectionStrings=false;Configuration=Release;UseSharedCompilation=false /p:SolutionDir="%DEPLOYMENT_SOURCE%\.\\" %SCM_BUILD_ARGS%
) ELSE (
  call :ExecuteCmd "%MSBUILD_PATH%" "%DEPLOYMENT_SOURCE%\AzureFunctions\AzureFunctions.csproj" /nologo /verbosity:m /t:Build /p:AutoParameterizationWebConfigConnectionStrings=false;Configuration=Release;UseSharedCompilation=false /p:SolutionDir="%DEPLOYMENT_SOURCE%\.\\" %SCM_BUILD_ARGS%
)

IF !ERRORLEVEL! NEQ 0 goto error

:: 3. KuduSync
IF /I "%IN_PLACE_DEPLOYMENT%" NEQ "1" (
  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"
  IF !ERRORLEVEL! NEQ 0 goto error
)

echo Handling frontend Angular2 project.

:: 4. KuduSync
IF /I "%IN_PLACE_DEPLOYMENT%" NEQ "1" (
  call :ExecuteCmd ROBOCOPY "%DEPLOYMENT_SOURCE%\AzureFunctions.Client" -t "%DEPLOYMENT_TARGET%" /E /IS
  IF !ERRORLEVEL! NEQ 0 goto error
)

:: 5. Install npm packages
IF EXIST "%DEPLOYMENT_TARGET%\package.json" (
  pushd "%DEPLOYMENT_TARGET%"

  call :ExecuteCmd npm install
  IF !ERRORLEVEL! NEQ 0 (
    call :ExecuteCmd npm install
    IF !ERRORLEVEL! NEQ 0 goto error
  )

  call :ExecuteCmd npm run jspm:i
  IF !ERRORLEVEL! NEQ 0 (
    call :ExecuteCmd npm run jspm:i
    IF !ERRORLEVEL! NEQ 0 goto error
  )

  call :ExecuteCmd npm run typings install
  IF !ERRORLEVEL! NEQ 0 goto error

  call :ExecuteCmd gulp
  IF !ERRORLEVEL! NEQ 0 goto error

  call :ExecuteCmd npm run tsc
  IF !ERRORLEVEL! NEQ 0 goto error

  call :ExecuteCmd npm run jspm:bundle
  IF !ERRORLEVEL! NEQ 0 goto error

  ::call :ExecuteCmd npm run uglifyjs
  ::IF !ERRORLEVEL! NEQ 0 goto error

  popd
)

:: 7. Install bower
IF EXIST "%DEPLOYMENT_TARGET%\bower.json" (
  pushd "%DEPLOYMENT_TARGET%"

  call :ExecuteCmd bower install
  IF !ERRORLEVEL! NEQ 0 goto error
  popd
)

:: 8. Copy templates-update webjob
SET WEBJOB_PATH=%HOME%\site\wwwroot\App_Data\jobs\triggered\templates-update
IF NOT EXIST "%WEBJOB_PATH%" (
  mkdir "%WEBJOB_PATH%"
)

copy "%DEPLOYMENT_SOURCE%\WebJobs\templates-update\templates-update.cmd" "%WEBJOB_PATH%"
copy "%DEPLOYMENT_SOURCE%\WebJobs\templates-update\settings.job" "%WEBJOB_PATH%"

:: 9. update build.txt
call :ExecuteCmd echo %SCM_COMMIT_ID% > %DEPLOYMENT_TARGET%\build.txt
IF !ERRORLEVEL! NEQ 0 (
  call :ExecuteCmd echo %SCM_COMMIT_ID% > %DEPLOYMENT_TARGET%\build.txt
  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.

Update deployment script

Update deployment script


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

:: ----------------------
:: KUDU Deployment Script
:: Version: 0.2.2
:: ----------------------

:: 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
)

:: 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
)
goto Deployment

:: Utility Functions
:: -----------------

:SelectNodeVersion

IF DEFINED KUDU_SELECT_NODE_VERSION_CMD (
  :: The following are done only on Windows Azure Websites environment
  call %KUDU_SELECT_NODE_VERSION_CMD% "%DEPLOYMENT_SOURCE%" "%DEPLOYMENT_TARGET%" "%DEPLOYMENT_TEMP%"
  IF !ERRORLEVEL! NEQ 0 goto error

  IF EXIST "%DEPLOYMENT_TEMP%\__nodeVersion.tmp" (
    SET /p NODE_EXE=<"%DEPLOYMENT_TEMP%\__nodeVersion.tmp"
    IF !ERRORLEVEL! NEQ 0 goto error
  )

  IF EXIST "%DEPLOYMENT_TEMP%\__npmVersion.tmp" (
    SET /p NPM_JS_PATH=<"%DEPLOYMENT_TEMP%\__npmVersion.tmp"
    IF !ERRORLEVEL! NEQ 0 goto error
  )

  IF NOT DEFINED NODE_EXE (
    SET NODE_EXE=node
  )

  SET NPM_CMD="!NODE_EXE!" "!NPM_JS_PATH!"
) ELSE (
  SET NPM_CMD=npm
  SET NODE_EXE=node
)

goto :EOF

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: Deployment
:: ----------

:Deployment
echo Handling node.js deployment.

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

:: 2. Select node version
call :SelectNodeVersion

:: 3. Install npm packages
IF EXIST "%DEPLOYMENT_TARGET%\package.json" (
  pushd "%DEPLOYMENT_TARGET%"
  call :ExecuteCmd !NPM_CMD! install
  IF !ERRORLEVEL! NEQ 0 goto error
  popd
)

:: 4. Install bower packages
IF EXIST "%DEPLOYMENT_TARGET%\bower.json" (
  pushd "%DEPLOYMENT_TARGET%"
  call :ExecuteCmd .\node_modules\.bin\bower install
  IF !ERRORLEVEL! NEQ 0 goto error
  popd
)

:: 5. Run gulp transformations
IF EXIST "%DEPLOYMENT_TARGET%\gulpfile.js" (
  pushd "%DEPLOYMENT_TARGET%"
  call :ExecuteCmd .\node_modules\.bin\gulp
  IF !ERRORLEVEL! NEQ 0 goto error
  popd
)

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

:: Post deployment stub
IF DEFINED POST_DEPLOYMENT_ACTION call "%POST_DEPLOYMENT_ACTION%"
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.

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

:: ----------------------
:: KUDU Deployment Script
:: Version: 0.2.2
:: ----------------------

:: 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
)

:: 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
)
goto Deployment

:: Utility Functions
:: -----------------

:SelectNodeVersion

IF DEFINED KUDU_SELECT_NODE_VERSION_CMD (
  :: The following are done only on Windows Azure Websites environment
  call %KUDU_SELECT_NODE_VERSION_CMD% "%DEPLOYMENT_SOURCE%" "%DEPLOYMENT_TARGET%" "%DEPLOYMENT_TEMP%"
  IF !ERRORLEVEL! NEQ 0 goto error

  IF EXIST "%DEPLOYMENT_TEMP%\__nodeVersion.tmp" (
    SET /p NODE_EXE=<"%DEPLOYMENT_TEMP%\__nodeVersion.tmp"
    IF !ERRORLEVEL! NEQ 0 goto error
  )

  IF EXIST "%DEPLOYMENT_TEMP%\__npmVersion.tmp" (
    SET /p NPM_JS_PATH=<"%DEPLOYMENT_TEMP%\__npmVersion.tmp"
    IF !ERRORLEVEL! NEQ 0 goto error
  )

  IF NOT DEFINED NODE_EXE (
    SET NODE_EXE=node
  )

  SET NPM_CMD="!NODE_EXE!" "!NPM_JS_PATH!"
) ELSE (
  SET NPM_CMD=npm
  SET NODE_EXE=node
)

goto :EOF

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: Deployment
:: ----------

:Deployment
echo Handling node.js deployment.

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

:: 2. Select node version
call :SelectNodeVersion

:: 3. Install npm packages
IF EXIST "%DEPLOYMENT_TARGET%\package.json" (
  pushd "%DEPLOYMENT_TARGET%"
  call :ExecuteCmd !NPM_CMD! set registry http://registry.npmjs.org/
  call :ExecuteCmd !NPM_CMD! install
  IF !ERRORLEVEL! NEQ 0 goto error
  popd
)

:: 4. Install bower packages
IF EXIST "%DEPLOYMENT_TARGET%\bower.json" (
  pushd "%DEPLOYMENT_TARGET%"
  call :ExecuteCmd .\node_modules\.bin\bower install
  IF !ERRORLEVEL! NEQ 0 goto error
  popd
)

:: 5. Run gulp transformations
IF EXIST "%DEPLOYMENT_TARGET%\gulpfile.js" (
  pushd "%DEPLOYMENT_TARGET%"
  call :ExecuteCmd .\node_modules\.bin\gulp
  IF !ERRORLEVEL! NEQ 0 goto error
  popd
)

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

:: Post deployment stub
IF DEFINED POST_DEPLOYMENT_ACTION call "%POST_DEPLOYMENT_ACTION%"
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.

Use http for nom packages

Use http for nom packages


cd test
mkdir build
cd build
cmake .. -GNinja -DCMAKE_PREFIX_PATH=%LIBRARY_PREFIX% -DCMAKE_LIBRARY_PATH:PATH=%LIBRARY_PREFIX%\lib
ninja
test.exe

cd test
if errorlevel 1 exit 1

mkdir build
if errorlevel 1 exit 1

cd build
if errorlevel 1 exit 1

cmake .. ^
    -GNinja ^
    -DCMAKE_PREFIX_PATH=%LIBRARY_PREFIX% ^
    -DCMAKE_LIBRARY_PATH:PATH=%LIBRARY_PREFIX%\lib ^
    -DCMAKE_VERBOSE_MAKEFILE=ON
echo "CMake finished"
if errorlevel 1 exit 1
echo "CMake okay"

ninja
echo "Ninja finished"
if errorlevel 1 exit 1
echo "Ninja okay"

test.exe
echo "Ninja finished"
if errorlevel 1 exit 1
echo "Ninja okay"

Add lots of debugging output to run_test.bat


@ECHO OFF

REM ---
REM --- Windows CMD script
REM --- to build PHP Reflect documentation in HTML chunked / HTML Help / ePUB / PDF (a4 and us) format
REM ---
REM --- Released under the Apache 2 license (http://www.apache.org/licenses/LICENSE-2.0.html)
REM --- (c) 2014 Laurent Laville
REM ---

IF "%ASCIIDOC%"==""       SET "ASCIIDOC=C:\asciidoc-8.6.9"
IF "%ASCIIDOC_BIN%"==""   SET "ASCIIDOC_BIN=%ASCIIDOC%\asciidoc.py"
IF "%A2X_BIN%"==""        SET "A2X_BIN=%ASCIIDOC%\a2x.py"
IF "%ASCIIDOC_THEME%"=="" SET "ASCIIDOC_THEME=cerulean"
IF "%HHC_BIN%"==""        SET "HHC_BIN=C:\Program Files\HTML Help Workshop\hhc.exe"

REM --
REM -- WEB HTML CHUNKED FORMAT
REM --
ECHO GENERATING WEB HTML CHUNKED FORMAT ...

"%A2X_BIN%" %1 --resource=./images -L --icons --stylesheet="%ASCIIDOC%"/stylesheets/docbook-xsl.css -d book -f chunked -D . phpreflect-book.asciidoc

REM --
REM -- HTML HELP FORMAT
REM --
ECHO GENERATING HTML HELP FORMAT ...

"%A2X_BIN%" %1 --resource=./images -L --icons --stylesheet="%ASCIIDOC%"/stylesheets/docbook-xsl.css -d book -f htmlhelp -D . phpreflect-book.asciidoc

"%HHC_BIN%" phpreflect-book.hhp

REM --
REM -- PDF A4 FORMAT
REM --
ECHO GENERATING PDF A4 FORMAT ...

"%A2X_BIN%" %1 %2 --resource=./images -L --icons --stylesheet="%ASCIIDOC%"/stylesheets/docbook-xsl.css -d book -f pdf --fop phpreflect-book.asciidoc

MOVE /Y phpreflect-book.pdf phpreflect-book-a4.pdf

REM --
REM -- PDF US FORMAT
REM --
ECHO GENERATING PDF US FORMAT ...

"%A2X_BIN%" %1 %2 --xsl-file="%ASCIIDOC%"/docbook-xsl/fo-custom.xsl --resource=./images -L --icons --stylesheet="%ASCIIDOC%"/stylesheets/docbook-xsl.css -d book -f pdf --fop phpreflect-book.asciidoc

MOVE /Y phpreflect-book.pdf phpreflect-book-us.pdf

REM --
REM -- ePUB FORMAT
REM --
ECHO GENERATING ePUB FORMAT ...

"%A2X_BIN%" %1 %2 --resource=./images -L --icons --stylesheet="%ASCIIDOC%"/stylesheets/docbook-xsl.css -d book -f epub phpreflect-book.asciidoc

REM --
REM -- Single xHTML page FORMAT
REM --
ECHO GENERATING Single xHTML page FORMAT ...

"%A2X_BIN%" %1 %2 --resource=./images -L --icons --stylesheet="%ASCIIDOC%"/stylesheets/docbook-xsl.css -d book -f xhtml phpreflect-book.asciidoc

@ECHO OFF

REM ---
REM --- Windows CMD script
REM --- to build PHP Reflect documentation in HTML chunked / HTML Help / ePUB / PDF (a4 and us) format
REM ---
REM --- Released under the Apache 2 license (http://www.apache.org/licenses/LICENSE-2.0.html)
REM --- (c) 2014 Laurent Laville
REM ---

IF "%ASCIIDOC%"==""       SET "ASCIIDOC=C:\asciidoc-8.6.9"
IF "%ASCIIDOC_BIN%"==""   SET "ASCIIDOC_BIN=%ASCIIDOC%\asciidoc.py"
IF "%A2X_BIN%"==""        SET "A2X_BIN=%ASCIIDOC%\a2x.py"
IF "%ASCIIDOC_THEME%"=="" SET "ASCIIDOC_THEME=cerulean"
IF "%HHC_BIN%"==""        SET "HHC_BIN=C:\Program Files\HTML Help Workshop\hhc.exe"

REM --
REM -- WEB HTML CHUNKED FORMAT
REM --
ECHO GENERATING WEB HTML CHUNKED FORMAT ...

"%A2X_BIN%" %1 --resource=./images -L --icons --stylesheet="%ASCIIDOC%"/stylesheets/docbook-xsl.css -d book -f chunked -D . phpreflect-book.asciidoc

REM --
REM -- HTML HELP FORMAT
REM --
ECHO GENERATING HTML HELP FORMAT ...

"%A2X_BIN%" %1 --resource=./images -L --icons --stylesheet="%ASCIIDOC%"/stylesheets/docbook-xsl.css -d book -f htmlhelp -D . phpreflect-book.asciidoc

"%HHC_BIN%" phpreflect-book.hhp

REM --
REM -- PDF A4 FORMAT
REM --
ECHO GENERATING PDF A4 FORMAT ...

"%A2X_BIN%" %1 %2 --resource=./images -L --icons --stylesheet="%ASCIIDOC%"/stylesheets/docbook-xsl.css -d book -f pdf --fop phpreflect-book.asciidoc

MOVE /Y phpreflect-book.pdf phpreflect-book-a4.pdf

REM --
REM -- PDF US FORMAT
REM --
ECHO GENERATING PDF US FORMAT ...

"%A2X_BIN%" %1 %2 --xsl-file="%ASCIIDOC%"/docbook-xsl/fo-custom.xsl --resource=./images -L --icons --stylesheet="%ASCIIDOC%"/stylesheets/docbook-xsl.css -d book -f pdf --fop phpreflect-book.asciidoc

MOVE /Y phpreflect-book.pdf phpreflect-book-us.pdf

REM --
REM -- ePUB FORMAT
REM --
ECHO GENERATING ePUB FORMAT ...

"%A2X_BIN%" %1 %2 -a docinfo --resource=./images -L --icons --stylesheet="%ASCIIDOC%"/stylesheets/docbook-xsl.css -d book -f epub phpreflect-book.asciidoc

REM --
REM -- Single xHTML page FORMAT
REM --
ECHO GENERATING Single xHTML page FORMAT ...

"%A2X_BIN%" %1 %2 --resource=./images -L --icons --stylesheet="%ASCIIDOC%"/stylesheets/docbook-xsl.css -d book -f xhtml phpreflect-book.asciidoc

add docinfo attribute to include cover in eBook


@Echo off
Title %CD% - Restore Last Visual C^+^+ Tools
PowerShell -NoProfile -NoLogo -ExecutionPolicy unrestricted -Command "[System.Threading.Thread]::CurrentThread.CurrentCulture = ''; [System.Threading.Thread]::CurrentThread.CurrentUICulture = '';& '%~dp0RestoreLastVisualCppTools.ps1' %*"

Add file

Add file


@rem Script to build LuaJIT with the XBox 360 SDK.
@rem Donated to the public domain.
@rem
@rem Open a "Visual Studio .NET Command Prompt" (32 bit host compiler)
@rem Then cd to this directory and run this script.

@if not defined INCLUDE goto :FAIL
@if not defined XEDK goto :FAIL

@setlocal
@rem ---- Host compiler ----
@set LJCOMPILE=cl /nologo /c /MD /O2 /W3 /D_CRT_SECURE_NO_DEPRECATE
@set LJLINK=link /nologo
@set LJMT=mt /nologo
@set DASMDIR=..\dynasm
@set DASM=%DASMDIR%\dynasm.lua
@set ALL_LIB=lib_base.c lib_math.c lib_bit.c lib_string.c lib_table.c lib_io.c lib_os.c lib_package.c lib_debug.c lib_jit.c lib_ffi.c

%LJCOMPILE% host\minilua.c
@if errorlevel 1 goto :BAD
%LJLINK% /out:minilua.exe minilua.obj
@if errorlevel 1 goto :BAD
if exist minilua.exe.manifest^
  %LJMT% -manifest minilua.exe.manifest -outputresource:minilua.exe

@rem Error out for 64 bit host compiler
@minilua
@if errorlevel 8 goto :FAIL

@set DASMFLAGS=-D GPR64 -D FRAME32 -D PPE -D SQRT -D DUALNUM
minilua %DASM% -LN %DASMFLAGS% -o host\buildvm_arch.h vm_ppc.dasc
@if errorlevel 1 goto :BAD

%LJCOMPILE% /I "." /I %DASMDIR% /D_XBOX_VER=200 /DLUAJIT_TARGET=LUAJIT_ARCH_PPC  host\buildvm*.c
@if errorlevel 1 goto :BAD
%LJLINK% /out:buildvm.exe buildvm*.obj
@if errorlevel 1 goto :BAD
if exist buildvm.exe.manifest^
  %LJMT% -manifest buildvm.exe.manifest -outputresource:buildvm.exe

buildvm -m peobj -o lj_vm.obj
@if errorlevel 1 goto :BAD
buildvm -m bcdef -o lj_bcdef.h %ALL_LIB%
@if errorlevel 1 goto :BAD
buildvm -m ffdef -o lj_ffdef.h %ALL_LIB%
@if errorlevel 1 goto :BAD
buildvm -m libdef -o lj_libdef.h %ALL_LIB%
@if errorlevel 1 goto :BAD
buildvm -m recdef -o lj_recdef.h %ALL_LIB%
@if errorlevel 1 goto :BAD
buildvm -m vmdef -o jit\vmdef.lua %ALL_LIB%
@if errorlevel 1 goto :BAD
buildvm -m folddef -o lj_folddef.h lj_opt_fold.c
@if errorlevel 1 goto :BAD

@rem ---- Cross compiler ----
@set LJCOMPILE="%XEDK%\bin\win32\cl" /nologo /c /MT /O2 /W3 /GF /Gm- /GR- /GS- /Gy /openmp- /D_CRT_SECURE_NO_DEPRECATE /DNDEBUG /D_XBOX /D_LIB /DLUAJIT_USE_SYSMALLOC
@set LJLIB="%XEDK%\bin\win32\lib" /nologo

@if "%1" neq "debug" goto :NODEBUG
@shift
@set LJCOMPILE="%LJCOMPILE%" /Zi
:NODEBUG
@if "%1"=="amalg" goto :AMALG
%LJCOMPILE% /DLUA_BUILD_AS_DLL lj_*.c lib_*.c
@if errorlevel 1 goto :BAD
%LJLIB% /OUT:luajit20.lib lj_*.obj lib_*.obj
@if errorlevel 1 goto :BAD
@goto :NOAMALG
:AMALG
%LJCOMPILE% /DLUA_BUILD_AS_DLL ljamalg.c
@if errorlevel 1 goto :BAD
%LJLIB% /OUT:luajit20.lib ljamalg.obj lj_vm.obj
@if errorlevel 1 goto :BAD
:NOAMALG

@del *.obj *.manifest minilua.exe buildvm.exe
@echo.
@echo === Successfully built LuaJIT for XBox 360 ===

@goto :END
:BAD
@echo.
@echo *******************************************************
@echo *** Build FAILED -- Please check the error messages ***
@echo *******************************************************
@goto :END
:FAIL
@echo To run this script you must open a "Visual Studio .NET Command Prompt"
@echo (32 bit host compiler). The XBox 360 SDK must be installed, too.
:END

@rem Script to build LuaJIT with the XBox 360 SDK.
@rem Donated to the public domain.
@rem
@rem Open a "Visual Studio .NET Command Prompt" (32 bit host compiler)
@rem Then cd to this directory and run this script.

@if not defined INCLUDE goto :FAIL
@if not defined XEDK goto :FAIL

@setlocal
@rem ---- Host compiler ----
@set LJCOMPILE=cl /nologo /c /MD /O2 /W3 /D_CRT_SECURE_NO_DEPRECATE
@set LJLINK=link /nologo
@set LJMT=mt /nologo
@set DASMDIR=..\dynasm
@set DASM=%DASMDIR%\dynasm.lua
@set ALL_LIB=lib_base.c lib_math.c lib_bit.c lib_string.c lib_table.c lib_io.c lib_os.c lib_package.c lib_debug.c lib_jit.c lib_ffi.c

%LJCOMPILE% host\minilua.c
@if errorlevel 1 goto :BAD
%LJLINK% /out:minilua.exe minilua.obj
@if errorlevel 1 goto :BAD
if exist minilua.exe.manifest^
  %LJMT% -manifest minilua.exe.manifest -outputresource:minilua.exe

@rem Error out for 64 bit host compiler
@minilua
@if errorlevel 8 goto :FAIL

@set DASMFLAGS=-D GPR64 -D FRAME32 -D PPE -D SQRT -D DUALNUM
minilua %DASM% -LN %DASMFLAGS% -o host\buildvm_arch.h vm_ppc.dasc
@if errorlevel 1 goto :BAD

%LJCOMPILE% /I "." /I %DASMDIR% /D_XBOX_VER=200 /DLUAJIT_TARGET=LUAJIT_ARCH_PPC  host\buildvm*.c
@if errorlevel 1 goto :BAD
%LJLINK% /out:buildvm.exe buildvm*.obj
@if errorlevel 1 goto :BAD
if exist buildvm.exe.manifest^
  %LJMT% -manifest buildvm.exe.manifest -outputresource:buildvm.exe

buildvm -m peobj -o lj_vm.obj
@if errorlevel 1 goto :BAD
buildvm -m bcdef -o lj_bcdef.h %ALL_LIB%
@if errorlevel 1 goto :BAD
buildvm -m ffdef -o lj_ffdef.h %ALL_LIB%
@if errorlevel 1 goto :BAD
buildvm -m libdef -o lj_libdef.h %ALL_LIB%
@if errorlevel 1 goto :BAD
buildvm -m recdef -o lj_recdef.h %ALL_LIB%
@if errorlevel 1 goto :BAD
buildvm -m vmdef -o jit\vmdef.lua %ALL_LIB%
@if errorlevel 1 goto :BAD
buildvm -m folddef -o lj_folddef.h lj_opt_fold.c
@if errorlevel 1 goto :BAD

@rem ---- Cross compiler ----
@set LJCOMPILE="%XEDK%\bin\win32\cl" /nologo /c /MT /O2 /W3 /GF /Gm- /GR- /GS- /Gy /openmp- /D_CRT_SECURE_NO_DEPRECATE /DNDEBUG /D_XBOX /D_LIB /DLUAJIT_USE_SYSMALLOC
@set LJLIB="%XEDK%\bin\win32\lib" /nologo
@set INCLUDE="%XEDK%\include\xbox"

@if "%1" neq "debug" goto :NODEBUG
@shift
@set LJCOMPILE="%LJCOMPILE%" /Zi
:NODEBUG
@if "%1"=="amalg" goto :AMALG
%LJCOMPILE% /DLUA_BUILD_AS_DLL lj_*.c lib_*.c
@if errorlevel 1 goto :BAD
%LJLIB% /OUT:luajit20.lib lj_*.obj lib_*.obj
@if errorlevel 1 goto :BAD
@goto :NOAMALG
:AMALG
%LJCOMPILE% /DLUA_BUILD_AS_DLL ljamalg.c
@if errorlevel 1 goto :BAD
%LJLIB% /OUT:luajit20.lib ljamalg.obj lj_vm.obj
@if errorlevel 1 goto :BAD
:NOAMALG

@del *.obj *.manifest minilua.exe buildvm.exe
@echo.
@echo === Successfully built LuaJIT for XBox 360 ===

@goto :END
:BAD
@echo.
@echo *******************************************************
@echo *** Build FAILED -- Please check the error messages ***
@echo *******************************************************
@goto :END
:FAIL
@echo To run this script you must open a "Visual Studio .NET Command Prompt"
@echo (32 bit host compiler). The XBox 360 SDK must be installed, too.
:END

Fix XBox 360 port.

Fix XBox 360 port.


del IGNORE
cd ..
cd src
call buildvc.bat
pause
call buildvcw.bat
pause

Update Script : build.bat

Update Script : build.bat