@echo off
rem Batch file to build MIPT-MIPS with Visual Studio
rem Copyright 2017 (C) MIPT-MIPS
rem Pavel Kryukov

rem Clean up
del *.obj

rem Build object files
cl /I. /EHsc /c /nologo /MD ^
   /D__LIBELF_INTERNAL__=1 ^
   /D_HAS_AUTO_PTR_ETC=1 ^
   /W4 /WX /wd4505 /wd4244 /wd4996 /wd4267 ^
   /std:c++17 ^
   infra/macro_test.cpp ^
   infra/elf_parser/elf_parser.cpp ^
   infra/memory/memory.cpp ^
   infra/config/config.cpp ^
   infra/ports/ports.cpp ^
   infra/cache/cache_tag_array.cpp ^
   mips/mips_instr.cpp ^
   mips/mips_memory.cpp ^
   func_sim/func_sim.cpp ^
   core/perf_sim.cpp || exit /b

rem Build GoogleTest
cl /EHsc /c /nologo /MD ^
   ..\googletest\googletest\src\gtest-all.cc ^
   /I ..\googletest\googletest\ /I ..\googletest\googletest\include\ || exit /b

set TRUNK=%cd%
set TRUNKX=%TRUNK:\=\\%

rem Build and run all the tests
for %%G in (infra\cache infra\elf_parser infra\config infra\memory infra\ports infra\string mips infra\instrcache func_sim bpu core) do (
    echo Testing %%G
    cd %%G\t
    cl /nologo unit_test.cpp %TRUNK%\*.obj %TRUNK%\..\libelf\lib\libelf.lib ^
       /EHsc /I %TRUNK%\..\googletest\googletest\include\ /I %TRUNK% /Fetest ^
       /D_HAS_AUTO_PTR_ETC=1 ^
       /std:c++17 ^
       /DTEST_PATH=\"%TRUNKX%\\..\\traces\\tt.core.out\" /MD || exit /b
    .\test.exe || exit /b
    cd %TRUNK%
)

rem Build main.cpp
cl /I. /EHsc /c /nologo /MD ^
   /D__LIBELF_INTERNAL__=1 ^
   /D_HAS_AUTO_PTR_ETC=1 ^
   /W4 /WX /wd4505 /wd4244 /wd4996 /wd4267 ^
   /std:c++17 ^
   main.cpp || exit /b

rem Build MIPT-MIPS
cl ..\libelf\lib\libelf.lib *.obj /Femipt-mips /nologo /MD || exit /b

@echo off
rem Batch file to build MIPT-MIPS with Visual Studio
rem Copyright 2017 (C) MIPT-MIPS
rem Pavel Kryukov

rem Clean up
del *.obj

rem Build object files
cl /I. /EHsc /c /nologo /MD ^
   /D__LIBELF_INTERNAL__=1 ^
   /D_HAS_AUTO_PTR_ETC=1 ^
   /W4 /WX /wd4505 /wd4244 /wd4996 /wd4267 ^
   /std:c++17 ^
   infra/macro_test.cpp ^
   infra/elf_parser/elf_parser.cpp ^
   infra/memory/memory.cpp ^
   infra/config/config.cpp ^
   infra/ports/ports.cpp ^
   infra/cache/cache_tag_array.cpp ^
   mips/mips_instr.cpp ^
   mips/mips_memory.cpp ^
   func_sim/func_sim.cpp ^
   core/perf_sim.cpp ^
   simulator.cpp || exit /b

rem Build GoogleTest
cl /EHsc /c /nologo /MD ^
   ..\googletest\googletest\src\gtest-all.cc ^
   /I ..\googletest\googletest\ /I ..\googletest\googletest\include\ || exit /b

set TRUNK=%cd%
set TRUNKX=%TRUNK:\=\\%

rem Build and run all the tests
for %%G in (infra\cache infra\elf_parser infra\config infra\memory infra\ports infra\string mips infra\instrcache func_sim bpu core) do (
    echo Testing %%G
    cd %%G\t
    cl /nologo unit_test.cpp %TRUNK%\*.obj %TRUNK%\..\libelf\lib\libelf.lib ^
       /EHsc /I %TRUNK%\..\googletest\googletest\include\ /I %TRUNK% /Fetest ^
       /D_HAS_AUTO_PTR_ETC=1 ^
       /std:c++17 ^
       /DTEST_PATH=\"%TRUNKX%\\..\\traces\\tt.core.out\" /MD || exit /b
    .\test.exe || exit /b
    cd %TRUNK%
)

rem Build main.cpp
cl /I. /EHsc /c /nologo /MD ^
   /D__LIBELF_INTERNAL__=1 ^
   /D_HAS_AUTO_PTR_ETC=1 ^
   /W4 /WX /wd4505 /wd4244 /wd4996 /wd4267 ^
   /std:c++17 ^
   main.cpp || exit /b

rem Build MIPT-MIPS
cl ..\libelf\lib\libelf.lib *.obj /Femipt-mips /nologo /MD || exit /b

Add simulator.cpp to MSVC build script

Add simulator.cpp to MSVC build script


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

rem 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"

wmic.exe USERACCOUNT WHERE "Name='admin'" set PasswordExpires=FALSE
wmic.exe USERACCOUNT WHERE "Name='user'" set PasswordExpires=FALSE

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

reg.exe add "HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" /v BranchReadinessLevel /d 32 /t REG_DWORD /f
reg.exe add "HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" /v DeferFeatureUpdates /d 1 /t REG_DWORD /f
reg.exe add "HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" /v DeferFeatureUpdatesPeriodInDays /d 365 /t REG_DWORD /f
reg.exe add "HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" /v DeferQualityUpdates /d 1 /t REG_DWORD /f
reg.exe add "HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" /v DeferQualityUpdatesPeriodInDays /d 14 /t REG_DWORD /f
reg.exe add "HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" /v ExcludeWUDriversInQualityUpdate /d 1 /t REG_DWORD /f
reg.exe add "HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" /v DeferUpgrade /t REG_DWORD /d 1 /f
reg.exe add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" /v NoConnectedUser /t REG_DWORD /d 3 /f
rem reg.exe add "HKLM\SOFTWARE\Microsoft\PolicyManager\default\Settings" /v AllowYourAccount /t REG_DWORD /d 0 /f
reg.exe add "HKLM\Software\Policies\Microsoft\Windows\CloudContent" /v DisableWindowsConsumerFeatures /t REG_DWORD /d 1 /f
reg.exe add "HKLM\SOFTWARE\Policies\Microsoft\Windows\AppPrivacy" /v LetAppsRunInBackground /t REG_DWORD /d 0 /f
reg.exe add "HKLM\SOFTWARE\Policies\Microsoft\Windows\DataCollection" /v AllowTelemetry /t REG_DWORD /d 0 /f
reg.exe add "HKLM\SOFTWARE\Policies\Microsoft\Windows\Windows Search" /v AllowCortana /t REG_DWORD /d 0 /f
reg.exe add "HKLM\SOFTWARE\Microsoft\WcmSvc\wifinetworkmanager\features" /v WiFiSenseCredShared /t REG_DWORD /d 0 /f
reg.exe add "HKLM\SOFTWARE\Microsoft\WcmSvc\wifinetworkmanager\features" /v WiFiSenseOpen /t REG_DWORD /d 0 /f
reg.exe add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\DateTime\Servers" /v 1 /t REG_SZ /d pool.ntp.org /f
rem reg.exe add "HKLM\SYSTEM\CurrentControlSet\services\sppsvc" /v Start /t REG_DWORD /d 3 /f
reg.exe add "HKLM\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" /v HideFileExt /t REG_DWORD /d 1 /f
reg.exe add "HKLM\Software\Google\Chrome\Extensions\cjpalhdlnbpafiamejdnhcphjbkeiagm" /v update_url /t REG_SZ /D "https://clients2.google.com/service/update2/crx" /F
reg.exe add "HKLM\Software\Wow6432Node\Google\Chrome\Extensions\cjpalhdlnbpafiamejdnhcphjbkeiagm" /v update_url /t REG_SZ /D "https://clients2.google.com/service/update2/crx" /F
reg.exe add "HKLM\Software\Policies\Google\Chrome" /v BackgroundModeEnabled /f /t REG_DWORD /d 0
reg.exe add "HKLM\Software\Policies\Google\Chrome\Recommended" /v DefaultCookiesSetting /f /t REG_DWORD /d 4
reg.exe add "HKLM\Software\Policies\Google\Chrome\Recommended" /v DefaultNotificationsSetting /f /t REG_DWORD /d 2
rem reg.exe add "HKLM\Software\Policies\Google\Chrome\Recommended" /v DefaultGeolocationSetting /f /t REG_DWORD /d 2
reg.exe add "HKLM\Software\Policies\Google\Chrome\Recommended" /v HomepageLocation /f /t REG_SZ /d "http://dennyhalim.com"
reg.exe add "HKLM\Software\Policies\Google\Chrome\Recommended" /v BlockThirdPartyCookies /f /t REG_DWORD /d 1
reg.exe add "HKLM\Software\Policies\Google\Chrome\Recommended" /v BuiltInDnsClientEnabled /f /t REG_DWORD /d 1
reg.exe add "HKLM\Software\Policies\Google\Chrome\Recommended" /v DiskCacheSize /f /t REG_DWORD /d 1
reg.exe add "HKLM\Software\Policies\Google\Chrome\Recommended" /v ForceGoogleSafeSearch /f /t REG_DWORD /d 1
reg.exe add "HKLM\Software\Policies\Google\Chrome\Recommended" /v ForceYouTubeRestrict /f /t REG_DWORD /d 1

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

schtasks.exe /change /TN "\Microsoft\Windows\Setup\SetupCleanupTask" /DISABLE
schtasks.exe /change /TN "\Microsoft\Windows\Application Experience\Microsoft Compatibility Appraiser" /DISABLE
schtasks.exe /change /TN "\Microsoft\Windows\Application Experience\ProgramDataUpdater" /DISABLE
schtasks.exe /change /TN "\Microsoft\Windows\Customer Experience Improvement Program\Consolidator" /DISABLE
schtasks.exe /change /TN "\Microsoft\Windows\Customer Experience Improvement Program\KernelCeipTask" /DISABLE
schtasks.exe /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.exe /passive /norestart /I "%WINDIR%\Setup\Files\just-install.msi"
msiexec.exe /passive /norestart /I "%WINDIR%\Setup\Files\NpackdCL-1.23.2.msi"
msiexec.exe /passive /norestart /I "%WINDIR%\Setup\Files\7z1805-x64.msi"
msiexec.exe /passive /norestart /I "%WINDIR%\Setup\Files\qalculate-2.4.0a.msi"
msiexec.exe /passive /norestart /I "%WINDIR%\Setup\Files\GoogleChromeStandaloneEnterprise64.msi"
msiexec.exe /passive /norestart /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"

powershell.exe -ExecutionPolicy Bypass -File "%WINDIR%\Setup\Progs\OpenSSH\install-sshd.ps1"
PowerShell.exe -ExecutionPolicy Bypass -File "%WINDIR%\Setup\Files\setup.ps1"

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
sc.exe config ssh-agent start= auto
sc.exe config sshd start= auto

netsh advfirewall firewall add rule dir=in action=allow profile=any protocol=TCP localport=2222 name="sshd"

mkdir "%Public%\Desktop.dennyhalim"
move "%Public%\Desktop\*.*" "%Public%\Desktop.dennyhalim"

rem use powershell for w10 only features
dism.exe /online /norestart /Enable-Feature /FeatureName:TelnetClient
dism.exe /online /norestart /Disable-Feature /FeatureName:MediaPlayback
dism.exe /online /norestart /Disable-Feature /FeatureName:WindowsMediaPlayer
dism.exe /online /norestart /Disable-Feature /FeatureName:WindowsGadgetPlatform
dism.exe /online /norestart /Disable-Feature /FeatureName:Indexing-Service-Package
dism.exe /online /norestart /Disable-Feature /FeatureName:Internet-Explorer-Optional-x86
dism.exe /online /norestart /Disable-Feature /FeatureName:Internet-Explorer-Optional-amd64

rem powercfg -hibernate on
REAGENTC.EXE /enable
rem "%WINDIR%\Setup-githubbox.exe"
rem shutdown /r /f /t 0

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

rem 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"

wmic.exe USERACCOUNT WHERE "Name='admin'" set PasswordExpires=FALSE
wmic.exe USERACCOUNT WHERE "Name='user'" set PasswordExpires=FALSE

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

reg.exe add "HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" /v BranchReadinessLevel /d 32 /t REG_DWORD /f
reg.exe add "HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" /v DeferFeatureUpdates /d 1 /t REG_DWORD /f
reg.exe add "HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" /v DeferFeatureUpdatesPeriodInDays /d 365 /t REG_DWORD /f
reg.exe add "HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" /v DeferQualityUpdates /d 1 /t REG_DWORD /f
reg.exe add "HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" /v DeferQualityUpdatesPeriodInDays /d 14 /t REG_DWORD /f
reg.exe add "HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" /v ExcludeWUDriversInQualityUpdate /d 1 /t REG_DWORD /f
reg.exe add "HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" /v DeferUpgrade /t REG_DWORD /d 1 /f
reg.exe add "HKLM\SOFTWARE\Policies\Microsoft\Windows\CloudContent" /v DisableWindowsConsumerFeatures /t REG_DWORD /d 1 /f
reg.exe add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" /v NoConnectedUser /t REG_DWORD /d 3 /f
rem reg.exe add "HKLM\SOFTWARE\Microsoft\PolicyManager\default\Settings" /v AllowYourAccount /t REG_DWORD /d 0 /f
reg.exe add "HKLM\Software\Policies\Microsoft\Windows\CloudContent" /v DisableWindowsConsumerFeatures /t REG_DWORD /d 1 /f
reg.exe add "HKLM\SOFTWARE\Policies\Microsoft\Windows\AppPrivacy" /v LetAppsRunInBackground /t REG_DWORD /d 0 /f
reg.exe add "HKLM\SOFTWARE\Policies\Microsoft\Windows\DataCollection" /v AllowTelemetry /t REG_DWORD /d 0 /f
reg.exe add "HKLM\SOFTWARE\Policies\Microsoft\Windows\Windows Search" /v AllowCortana /t REG_DWORD /d 0 /f
reg.exe add "HKLM\SOFTWARE\Microsoft\WcmSvc\wifinetworkmanager\features" /v WiFiSenseCredShared /t REG_DWORD /d 0 /f
reg.exe add "HKLM\SOFTWARE\Microsoft\WcmSvc\wifinetworkmanager\features" /v WiFiSenseOpen /t REG_DWORD /d 0 /f
reg.exe add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\DateTime\Servers" /v 1 /t REG_SZ /d pool.ntp.org /f
rem reg.exe add "HKLM\SYSTEM\CurrentControlSet\services\sppsvc" /v Start /t REG_DWORD /d 3 /f
reg.exe add "HKLM\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" /v HideFileExt /t REG_DWORD /d 1 /f
reg.exe add "HKLM\Software\Google\Chrome\Extensions\cjpalhdlnbpafiamejdnhcphjbkeiagm" /v update_url /t REG_SZ /D "https://clients2.google.com/service/update2/crx" /F
reg.exe add "HKLM\Software\Wow6432Node\Google\Chrome\Extensions\cjpalhdlnbpafiamejdnhcphjbkeiagm" /v update_url /t REG_SZ /D "https://clients2.google.com/service/update2/crx" /F
reg.exe add "HKLM\Software\Policies\Google\Chrome" /v BackgroundModeEnabled /f /t REG_DWORD /d 0
reg.exe add "HKLM\Software\Policies\Google\Chrome\Recommended" /v DefaultCookiesSetting /f /t REG_DWORD /d 4
reg.exe add "HKLM\Software\Policies\Google\Chrome\Recommended" /v DefaultNotificationsSetting /f /t REG_DWORD /d 2
rem reg.exe add "HKLM\Software\Policies\Google\Chrome\Recommended" /v DefaultGeolocationSetting /f /t REG_DWORD /d 2
reg.exe add "HKLM\Software\Policies\Google\Chrome\Recommended" /v HomepageLocation /f /t REG_SZ /d "http://dennyhalim.com"
reg.exe add "HKLM\Software\Policies\Google\Chrome\Recommended" /v BlockThirdPartyCookies /f /t REG_DWORD /d 1
reg.exe add "HKLM\Software\Policies\Google\Chrome\Recommended" /v BuiltInDnsClientEnabled /f /t REG_DWORD /d 1
reg.exe add "HKLM\Software\Policies\Google\Chrome\Recommended" /v DiskCacheSize /f /t REG_DWORD /d 1
reg.exe add "HKLM\Software\Policies\Google\Chrome\Recommended" /v ForceGoogleSafeSearch /f /t REG_DWORD /d 1
reg.exe add "HKLM\Software\Policies\Google\Chrome\Recommended" /v ForceYouTubeRestrict /f /t REG_DWORD /d 1

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

schtasks.exe /change /TN "\Microsoft\Windows\Setup\SetupCleanupTask" /DISABLE
schtasks.exe /change /TN "\Microsoft\Windows\Application Experience\Microsoft Compatibility Appraiser" /DISABLE
schtasks.exe /change /TN "\Microsoft\Windows\Application Experience\ProgramDataUpdater" /DISABLE
schtasks.exe /change /TN "\Microsoft\Windows\Customer Experience Improvement Program\Consolidator" /DISABLE
schtasks.exe /change /TN "\Microsoft\Windows\Customer Experience Improvement Program\KernelCeipTask" /DISABLE
schtasks.exe /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.exe /passive /norestart /I "%WINDIR%\Setup\Files\just-install.msi"
msiexec.exe /passive /norestart /I "%WINDIR%\Setup\Files\NpackdCL-1.23.2.msi"
msiexec.exe /passive /norestart /I "%WINDIR%\Setup\Files\7z1805-x64.msi"
msiexec.exe /passive /norestart /I "%WINDIR%\Setup\Files\qalculate-2.4.0a.msi"
msiexec.exe /passive /norestart /I "%WINDIR%\Setup\Files\GoogleChromeStandaloneEnterprise64.msi"
msiexec.exe /passive /norestart /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"

powershell.exe -ExecutionPolicy Bypass -File "%WINDIR%\Setup\Progs\OpenSSH\install-sshd.ps1"
PowerShell.exe -ExecutionPolicy Bypass -File "%WINDIR%\Setup\Files\setup.ps1"

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
sc.exe config ssh-agent start= auto
sc.exe config sshd start= auto

netsh advfirewall firewall add rule dir=in action=allow profile=any protocol=TCP localport=2222 name="sshd"

mkdir "%Public%\Desktop.dennyhalim"
move "%Public%\Desktop\*.*" "%Public%\Desktop.dennyhalim"

rem use powershell for w10 only features
dism.exe /online /norestart /Enable-Feature /FeatureName:TelnetClient
dism.exe /online /norestart /Disable-Feature /FeatureName:MediaPlayback
dism.exe /online /norestart /Disable-Feature /FeatureName:WindowsMediaPlayer
dism.exe /online /norestart /Disable-Feature /FeatureName:WindowsGadgetPlatform
dism.exe /online /norestart /Disable-Feature /FeatureName:Indexing-Service-Package
dism.exe /online /norestart /Disable-Feature /FeatureName:Internet-Explorer-Optional-x86
dism.exe /online /norestart /Disable-Feature /FeatureName:Internet-Explorer-Optional-amd64

rem powercfg -hibernate on
REAGENTC.EXE /enable
rem "%WINDIR%\Setup-githubbox.exe"
rem shutdown /r /f /t 0

Update SetupComplete.cmd

Update SetupComplete.cmd


@echo off
echo Cleaning...
if exist target\site rd /s /q target\site

haxelib list | findstr dox >NUL
if errorlevel 1 (
    echo Installing [dox]...
    haxelib install dox
)

echo Analyzing source code...
haxe -xml target/doc.xml -cp src --macro include('hx.strings')

echo Generating HTML files...
haxelib run dox ^
  -in "^hx" ^
  -ex "^haxe" ^
  -ex "^[A-Z]" ^
  -i target/doc.xml ^
  -o target/site

setlocal
set pwd=%~dp0
echo Documentation generated at [file:///%pwd:\=/%target/site/index.html]...
endlocal

@echo off
echo Cleaning...
if exist target\site rd /s /q target\site

haxelib list | findstr dox >NUL
if errorlevel 1 (
    echo Installing [dox]...
    haxelib install dox
)

echo Analyzing source code...
haxe -xml target/doc.xml -cp src --macro include('hx.strings')

echo Generating HTML files...
haxelib run dox ^
  -in "^hx" ^
  -ex "^haxe" ^
  -ex "internal" ^
  -ex "^[A-Z]" ^
  -i target/doc.xml ^
  -o target/site

setlocal
set pwd=%~dp0
echo Documentation generated at [file:///%pwd:\=/%target/site/index.html]...
endlocal

exclude internal package

exclude internal package


git pull https://github.com/RazielXT/mtTorrent.git
pause

add pull bat

add pull bat


@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem      https://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

@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem  Gradle startup script for Windows
@rem
@rem ##########################################################################

@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal

set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%

@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi

@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"

@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome

set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto execute

echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.

goto fail

:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe

if exist "%JAVA_EXE%" goto execute

echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.

goto fail

:execute
@rem Setup the command line

set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar

@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*

:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd

:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if  not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1

:mainEnd
if "%OS%"=="Windows_NT" endlocal

:omega

Fix eol in bat

Fix eol in bat


@echo off
:: Gets localization strings depending user's system locale
::  Windows Language abbreveations - http://msdn.microsoft.com/en-us/library/ms903928.aspx
::	DOS Codepage identifiers - http://msdn.microsoft.com/en-us/library/windows/desktop/dd317756(v=vs.85).aspx

if [!Key!]==[] (
	set Key="HKEY_CURRENT_USER\Control Panel\International"
	for /F "tokens=3" %%a in ('reg query !Key!  ^| find /i "sLang"') do set LANGUAGE=%%a
)

:: initialize English as default
call module\i18n\ENU.bat %1 %2 %3 %4 %5

:: switch to another language, if found
if exist module\i18n\%LANGUAGE%.bat call module\i18n\%LANGUAGE%.bat %1 %2 %3 %4 %5

:: print phrase
if not [%1]==[] echo !PHRASE_%1!

@echo off
:: Gets localization strings depending user's system locale
::  Windows Language abbreveations - http://msdn.microsoft.com/en-us/library/ms903928.aspx
::	DOS Codepage identifiers - http://msdn.microsoft.com/en-us/library/windows/desktop/dd317756(v=vs.85).aspx

if [!Key!]==[] (
	set Key="HKEY_CURRENT_USER\Control Panel\International"
	for /F "tokens=3" %%a in ('reg query !Key!  ^| find /i "sLang"') do set LANGUAGE=%%a
)
set LANGUAGE=KKZ

:: initialize English as default
call module\i18n\ENU.bat %1 %2 %3 %4 %5

:: Russian
if [%LANGUAGE%]==[UZB] set LANGUAGE=RUS
if [%LANGUAGE%]==[KKZ] set LANGUAGE=RUS
if [%LANGUAGE%]==[TTT] set LANGUAGE=RUS
if [%LANGUAGE%]==[UKR] set LANGUAGE=RUS
:: Serbian
if [%LANGUAGE%]==[SRL] set LANGUAGE=SRL
if [%LANGUAGE%]==[SRB] set LANGUAGE=SRL
if [%LANGUAGE%]==[HRV] set LANGUAGE=SRL
:: Chinese
if [%LANGUAGE%]==[CHS] set LANGUAGE=CHS
if [%LANGUAGE%]==[CHT] set LANGUAGE=CHT
if "!LANGUAGE:~0,2!"=="ZH" set LANGUAGE=CHS
:: Portuguese
if "!LANGUAGE:~0,2!"=="PT" set LANGUAGE=PTB
:: Swedish
if "!LANGUAGE:~0,2!"=="SV" set LANGUAGE=SVF
:: German
if "!LANGUAGE:~0,2!"=="DE" set LANGUAGE=DEU
:: Dutch
if "!LANGUAGE:~0,2!"=="NL" set LANGUAGE=NLD
:: Spanish
if "!LANGUAGE:~0,2!"=="ES" set LANGUAGE=ESN

:: switch to another language, if found
if exist module\i18n\%LANGUAGE%.bat call module\i18n\%LANGUAGE%.bat %1 %2 %3 %4 %5

:: print phrase
if not [%1]==[] echo !PHRASE_%1!

add multiple language variations

add multiple language variations


@echo on
call "%VS120COMNTOOLS%vsvars32.bat"

msbuild.exe /ToolsVersion:4.0 "SimpleMusicPlayer.sln" /p:StrongName=True /p:configuration=Release /p:platform=x86 /m
msbuild.exe /ToolsVersion:4.0 "SimpleMusicPlayer.sln" /p:StrongName=True /p:configuration=Release /p:platform="Any CPU" /m

@echo on
call "%VS120COMNTOOLS%vsvars32.bat"

msbuild.exe /ToolsVersion:4.0 "SimpleMusicPlayer.sln" /p:StrongName=True /p:configuration=Release /p:platform=x86 /m /t:Clean,Rebuild
msbuild.exe /ToolsVersion:4.0 "SimpleMusicPlayer.sln" /p:StrongName=True /p:configuration=Release /p:platform="Any CPU" /m /t:Clean,Rebuild

update build batch

update build batch


Fix spelling error in service's bat files

git-svn-id: 6d1cac2d86fac78d43d5e0dd3566a1010e844f91@53973 81fbe566-5dc4-48c1-bdea-7421811ca204


### application.bat - 2015 - gandubert ###
version = "1.2"
build_hour = "11H00"

echo "Build ${build_hour}"
echo "version ${version}"

### application.bat - 2015 - gandubert MAIGNAN ###
version = "1.2"
build_hour = "11H00"

echo "Build ${build_hour}"
echo "version ${version}"

Update header for new member

Update header for new member


### application.bat - 2013 - ROBIN  ###

echo "Build : 10:00"

Add file header

Add file header


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

REM Install Bazel using Chocolatey.
choco install -y bazel --version 2.0.0

REM Change PATH to use chocolatey's version of Bazel
set PATH=C:\ProgramData\chocolatey\bin;%PATH%
bazel version

REM Configure the environment to use MSVC 2019 and then switch to PowerShell.
call "c:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars64.bat"

REM The remaining of the build script is implemented in PowerShell.
echo %date% %time%
cd github\google-cloud-cpp-spanner
powershell -exec bypass ci\kokoro\windows\build.ps1
if %errorlevel% neq 0 exit /b %errorlevel%

@REM Kokoro rsyncs all the files in the %KOKORO_ARTIFACTS_DIR%, which takes a
@REM long time. The recommended workaround is to remove all the files that are
@REM not interesting artifacts.
if defined KOKORO_ARTIFACTS_DIR (
  @echo %date% %time% "Cleanup Kokoro artifacts directory"
  cd "%KOKORO_ARTIFACTS_DIR%"
  powershell -Command "& {Get-ChildItem -Recurse -File -Exclude test.xml,sponge_log.xml,build.bat | Remove-Item -Recurse -Force}"
  if %errorlevel% neq 0 exit /b %errorlevel%
)

@echo DONE "============================================="
@echo %date% %time%

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

REM Install Bazel using Chocolatey.
choco install -y bazel --version 2.0.0

REM Change PATH to use chocolatey's version of Bazel
set PATH=C:\ProgramData\chocolatey\bin;%PATH%
bazel version

REM Configure the environment to use MSVC 2019 and then switch to PowerShell.
call "c:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars64.bat"

REM The remaining of the build script is implemented in PowerShell.
echo %date% %time%
cd github\google-cloud-cpp-spanner
powershell -exec bypass ci\kokoro\windows\build.ps1
if %errorlevel% neq 0 exit /b %errorlevel%

@echo DONE "============================================="
@echo %date% %time%

ci: troubleshoot new Windows+Bazel build (#1378)


@set args=%*
@powershell "iex((@('')*3+(cat '%~f0'|select -skip 3))-join[char]10)"
@exit /b %ERRORLEVEL%

$args = @( ([regex]'"([^"]*)"').Replace($env:args,{
        $args[0].Groups[1] -replace " ",[char]1
    }) -split " " | ForEach-Object{ $_ -replace [char]1," " })

set GO "go.exe" -option constant

set CMD "Cmd" -option constant

Set-PSDebug -strict
$VerbosePreference = "Continue"

function Do-Copy($src,$dst){
    Write-Verbose "$ copy '$src' '$dst'"
    Copy-Item $src $dst
}

function Do-Remove($file){
    if( Test-Path $file ){
        Write-Verbose "$ del '$file'"
        Remove-Item $file
    }
}

function Make-Dir($folder){
    if( -not (Test-Path $folder) ){
        Write-Verbose "$ mkdir '$folder'"
        New-Item $folder -type directory | Out-Null
    }
}

Add-Type -Assembly System.Windows.Forms
function Ask-Copy($src,$dst){
    $fname = (Join-Path $dst (Split-Path $src -Leaf))
    if( Test-Path $fname ){
        if( "Yes" -ne [System.Windows.Forms.MessageBox]::Show(
            'Override "{0}" by default ?' -f $fname,
            "NYAGOS Install", "YesNo","Question","button2") ){
            return
        }
    }
    Do-Copy $src $dst
}

function ForEach-GoDir{
    Get-ChildItem . -Recurse |
    Where-Object{ $_.Extension -eq '.go' } |
    ForEach-Object{ Split-Path $_.FullName -Parent } |
    Sort-Object |
    Get-Unique
}

function Go-Fmt{
    $status = $true
    git status -s | %{
        $fname = $_.Substring(3)
        $arrow = $fname.IndexOf(" -> ")
        if( $arrow -ge 0 ){
            $fname = $fname.Substring($arrow+4)
        }
        if( $fname -like "*.go" -and (Test-Path($fname)) ){
            $prop = Get-ItemProperty($fname)
            if( $prop.Mode -like "?a*" ){
                Write-Verbose "$ $GO fmt $fname"
                & $GO fmt $fname
                if( $LastExitCode -ne 0 ){
                    $status = $false
                }else{
                    attrib -a $fname
                }
            }
        }
    }
    if( -not $status ){
        Write-Warning "Some of '$GO fmt' failed."
    }
    return $status
}

function Make-SysO($version) {
    Download-Exe "github.com/josephspurrier/goversioninfo/cmd/goversioninfo" "goversioninfo.exe"
    if( $version -match "^\d+[\._]\d+[\._]\d+[\._]\d+$" ){
        $v = $version.Split("[\._]")
    }else{
        $v = @(0,0,0,0)
        if( $version -eq $null -or $version -eq "" ){
            $version = "0.0.0_0"
        }
    }
    Write-Verbose "version=$version"

    .\goversioninfo.exe `
        "-file-version=$version" `
        "-product-version=$version" `
        "-icon=nyagos.ico" `
        ("-ver-major=" + $v[0]) `
        ("-ver-minor=" + $v[1]) `
        ("-ver-patch=" + $v[2]) `
        ("-ver-build=" + $v[3]) `
        ("-product-ver-major=" + $v[0]) `
        ("-product-ver-minor=" + $v[1]) `
        ("-product-ver-patch=" + $v[2]) `
        ("-product-ver-build=" + $v[3]) `
        "-o" nyagos.syso `
        versioninfo.json
}

function Download-Exe($url,$exename){
    if( Test-Path $exename ){
        Write-Verbose -Message ("Found {0}" -f $exename)
        return
    }
    Write-Verbose -Message ("{0} not found." -f $exename)
    Write-Verbose -Message ("$ $GO get -d " + $url)
    & $GO get -d $url
    $workdir = (Join-Path (Join-Path (& $GO env GOPATH).Split(";")[0] "src") $url)
    $cwd = (Get-Location)
    Set-Location $workdir
    Write-Verbose -Message ("$ $GO build {0} on {1}" -f $exename,$workdir)
    & $GO build
    Do-Copy $exename $cwd
    Set-Location $cwd
}

function Build($version,$tags) {
    Write-Verbose "Build as version='$version' tags='$tags'"

    if( -not (Go-Fmt) ){
        return
    }
    $saveGOARCH = $env:GOARCH
    $env:GOARCH = (& $go env GOARCH)

    Make-Dir $CMD
    $binDir = (Join-Path $CMD $env:GOARCH)
    Make-Dir $binDir
    $target = (Join-Path $binDir "nyagos.exe")

    Make-SysO $version

    Write-Verbose "$ $GO build -o '$target'"
    & $GO build "-o" $target -ldflags "-s -w -X main.version=$version" $tags
    if( $LastExitCode -eq 0 ){
        Do-Copy $target ".\nyagos.exe"
    }
    $env:GOARCH = $saveGOARCH
}

function Make-Package($arch){
    $zipname = ("nyagos-{0}.zip" -f (& cmd\$arch\nyagos.exe --show-version-only))
    Write-Verbose "$ zip -9 $zipname ...."
    if( Test-Path $zipname ){
        Do-Remove $zipname
    }
    zip -9j $zipname `
        "cmd\$arch\nyagos.exe" `
        .nyagos `
        _nyagos `
        makeicon.cmd `
        LICENSE `
        readme_ja.md `
        readme.md

    zip -9 $zipname `
        nyagos.d\*.lua `
        nyagos.d\catalog\*.lua `
        Doc\*.md
}

switch( $args[0] ){
    "" {
        Build (git describe --tags) ""
    }
    "386"{
        $private:save = $env:GOARCH
        $env:GOARCH = "386"
        Build (git describe --tags) ""
        $env:GOARCH = $save
    }
    "debug" {
        $private:save = $env:GOARCH
        if( $args[1] ){
            $env:GOARCH = $args[1]
        }
        Build "" "-tags=debug"
        $env:GOARCH = $save
    }
    "release" {
        $private:save = $env:GOARCH
        if( $args[1] ){
            $env:GOARCH = $args[1]
        }
        Build (Get-Content Misc\version.txt) ""
        $env:GOARCH = $save
    }
    "clean" {
        foreach( $p in @(`
            (Join-Path $CMD "amd64\nyagos.exe"),`
            (Join-Path $CMD "386\nyagos.exe"),`
            "nyagos.exe",`
            "nyagos.syso",`
            "version.now",`
            "goversioninfo.exe") )
        {
            Do-Remove $p
        }
        ForEach-GoDir | %{
            Write-Verbose "$ $GO clean on $_"
            pushd $_
            & $GO clean
            popd
        }
    }
    "package" {
        $goarch = if( $args[1] ){ $args[1] }else{ (& $go env GOARCH) }
        Make-Package $goarch
    }
    "install" {
        $installDir = $args[1]
        if( $installDir -eq $null -or $installDir -eq "" ){
            $installDir = (
                Select-String 'INSTALLDIR=([^\)"]+)' Misc\version.cmd |
                ForEach-Object{ $_.Matches[0].Groups[1].Value }
            )
            if( -not $installDir ){
                Write-Warning "Usage: make.ps1 install INSTALLDIR"
                exit
            }
            if( -not (Test-Path $installDir) ){
                Write-Warning "$installDir not found."
                exit
            }
            Write-Verbose "installDir=$installDir"
        }
        Write-Output "@set `"INSTALLDIR=$installDir`"" |
            Out-File "Misc\version.cmd" -Encoding Default

        robocopy nyagos.d (Join-Path $installDir "nyagos.d") /E
        Write-Verbose ("ERRORLEVEL=" + $LastExitCode)
        if( $LastExitCode -lt 8 ){
            Remove-Item Variable:LastExitCode
        }
        Ask-Copy "_nyagos" $installDir
        try{
            Do-Copy nyagos.exe $installDir
        }catch{
            taskkill /F /im nyagos.exe
            try{
                Do-Copy nyagos.exe $installDir
            }catch{
                Write-Host "Could not update installed nyagos.exe"
                Write-Host "Some processes holds nyagos.exe now"
            }
            # [void]([System.Windows.Forms.MessageBox]::Show("Done"))
            timeout /T 3
        }
    }
    "get" {
        if( (git branch --contains) -eq "* master" ){
            Write-Verbose "$GO get -u -v ./..."
            & $GO get -u -v ./...
        } else {
            Write-Verbose "$GO get -v ./..."
            & $GO get -v ./...
        }
    }
    "fmt" {
        Go-Fmt | Out-Null
    }
    "help" {
        Write-Output @'
make                     build as snapshot
make debug   [386|amd64] build as debug version     (tagged as `debug`)
make release [386|amd64] build as release version
make clean               remove all work files
make package [386|amd64] make `nyagos-(VERSION)-(ARCH).zip`
make install [FOLDER]    copy executables to FOLDER or last folder
make fmt                 `go fmt`
make help                show this
'@
    }
    default {
        Write-Warning ("{0} not supported." -f $args[0])
    }
}
if( Test-Path Variable:LastExitCode ){
    exit $LastExitCode
}

# vim:set ft=ps1:

@set args=%*
@powershell "iex((@('')*3+(cat '%~f0'|select -skip 3))-join[char]10)"
@exit /b %ERRORLEVEL%

$args = @( ([regex]'"([^"]*)"').Replace($env:args,{
        $args[0].Groups[1] -replace " ",[char]1
    }) -split " " | ForEach-Object{ $_ -replace [char]1," " })

set GO "go.exe" -option constant

set CMD "Cmd" -option constant

Set-PSDebug -strict
$VerbosePreference = "Continue"

function Do-Copy($src,$dst){
    Write-Verbose "$ copy '$src' '$dst'"
    Copy-Item $src $dst
}

function Do-Remove($file){
    if( Test-Path $file ){
        Write-Verbose "$ del '$file'"
        Remove-Item $file
    }
}

function Make-Dir($folder){
    if( -not (Test-Path $folder) ){
        Write-Verbose "$ mkdir '$folder'"
        New-Item $folder -type directory | Out-Null
    }
}

Add-Type -Assembly System.Windows.Forms
function Ask-Copy($src,$dst){
    $fname = (Join-Path $dst (Split-Path $src -Leaf))
    if( Test-Path $fname ){
        if( "Yes" -ne [System.Windows.Forms.MessageBox]::Show(
            'Override "{0}" by default ?' -f $fname,
            "NYAGOS Install", "YesNo","Question","button2") ){
            return
        }
    }
    Do-Copy $src $dst
}

function ForEach-GoDir{
    Get-ChildItem . -Recurse |
    Where-Object{ $_.Extension -eq '.go' } |
    ForEach-Object{ Split-Path $_.FullName -Parent } |
    Sort-Object |
    Get-Unique
}

function Go-Fmt{
    $status = $true
    git status -s | %{
        $fname = $_.Substring(3)
        $arrow = $fname.IndexOf(" -> ")
        if( $arrow -ge 0 ){
            $fname = $fname.Substring($arrow+4)
        }
        if( $fname -like "*.go" -and (Test-Path($fname)) ){
            $prop = Get-ItemProperty($fname)
            if( $prop.Mode -like "?a*" ){
                Write-Verbose "$ $GO fmt $fname"
                & $GO fmt $fname
                if( $LastExitCode -ne 0 ){
                    $status = $false
                }else{
                    attrib -a $fname
                }
            }
        }
    }
    if( -not $status ){
        Write-Warning "Some of '$GO fmt' failed."
    }
    return $status
}

function Make-SysO($version) {
    Download-Exe "github.com/josephspurrier/goversioninfo/cmd/goversioninfo" "goversioninfo.exe"
    if( $version -match "^\d+[\._]\d+[\._]\d+[\._]\d+$" ){
        $v = $version.Split("[\._]")
    }else{
        $v = @(0,0,0,0)
        if( $version -eq $null -or $version -eq "" ){
            $version = "0.0.0_0"
        }
    }
    Write-Verbose "version=$version"

    .\goversioninfo.exe `
        "-file-version=$version" `
        "-product-version=$version" `
        "-icon=nyagos.ico" `
        ("-ver-major=" + $v[0]) `
        ("-ver-minor=" + $v[1]) `
        ("-ver-patch=" + $v[2]) `
        ("-ver-build=" + $v[3]) `
        ("-product-ver-major=" + $v[0]) `
        ("-product-ver-minor=" + $v[1]) `
        ("-product-ver-patch=" + $v[2]) `
        ("-product-ver-build=" + $v[3]) `
        "-o" nyagos.syso `
        versioninfo.json
}

function Download-Exe($url,$exename){
    if( Test-Path $exename ){
        Write-Verbose -Message ("Found {0}" -f $exename)
        return
    }
    Write-Verbose -Message ("{0} not found." -f $exename)
    Write-Verbose -Message ("$ $GO get -d " + $url)
    & $GO get -d $url
    $workdir = (Join-Path (Join-Path (& $GO env GOPATH).Split(";")[0] "src") $url)
    $cwd = (Get-Location)
    Set-Location $workdir
    Write-Verbose -Message ("$ $GO build {0} on {1}" -f $exename,$workdir)
    & $GO build
    Do-Copy $exename $cwd
    Set-Location $cwd
}

function Build($version,$tags) {
    Write-Verbose "Build as version='$version' tags='$tags'"

    if( -not (Go-Fmt) ){
        return
    }
    $saveGOARCH = $env:GOARCH
    $env:GOARCH = (& $go env GOARCH)

    Make-Dir $CMD
    $binDir = (Join-Path $CMD $env:GOARCH)
    Make-Dir $binDir
    $target = (Join-Path $binDir "nyagos.exe")

    Make-SysO $version

    Write-Verbose "$ $GO build -o '$target'"
    & $GO build "-o" $target -ldflags "-s -w -X main.version=$version" $tags
    if( $LastExitCode -eq 0 ){
        Do-Copy $target ".\nyagos.exe"
    }
    $env:GOARCH = $saveGOARCH
}

function Make-Package($arch){
    $zipname = ("nyagos-{0}.zip" -f (& cmd\$arch\nyagos.exe --show-version-only))
    Write-Verbose "$ zip -9 $zipname ...."
    if( Test-Path $zipname ){
        Do-Remove $zipname
    }
    zip -9j $zipname `
        "cmd\$arch\nyagos.exe" `
        .nyagos `
        _nyagos `
        makeicon.cmd `
        LICENSE `
        readme_ja.md `
        readme.md

    zip -9 $zipname `
        nyagos.d\*.lua `
        nyagos.d\catalog\*.lua `
        Doc\*.md
}

switch( $args[0] ){
    "" {
        Build (git describe --tags) ""
    }
    "386"{
        $private:save = $env:GOARCH
        $env:GOARCH = "386"
        Build (git describe --tags) ""
        $env:GOARCH = $save
    }
    "debug" {
        $private:save = $env:GOARCH
        if( $args[1] ){
            $env:GOARCH = $args[1]
        }
        Build "" "-tags=debug"
        $env:GOARCH = $save
    }
    "release" {
        $private:save = $env:GOARCH
        if( $args[1] ){
            $env:GOARCH = $args[1]
        }
        Build (Get-Content Misc\version.txt) ""
        $env:GOARCH = $save
    }
    "clean" {
        foreach( $p in @(`
            (Join-Path $CMD "amd64\nyagos.exe"),`
            (Join-Path $CMD "386\nyagos.exe"),`
            "nyagos.exe",`
            "nyagos.syso",`
            "version.now",`
            "goversioninfo.exe") )
        {
            Do-Remove $p
        }
        ForEach-GoDir | %{
            Write-Verbose "$ $GO clean on $_"
            pushd $_
            & $GO clean
            popd
        }
    }
    "package" {
        $goarch = if( $args[1] ){ $args[1] }else{ (& $go env GOARCH) }
        Make-Package $goarch
    }
    "install" {
        $installDir = $args[1]
        if( $installDir -eq $null -or $installDir -eq "" ){
            $installDir = (
                Select-String 'INSTALLDIR=([^\)"]+)' Misc\version.cmd |
                ForEach-Object{ $_.Matches[0].Groups[1].Value }
            )
            if( -not $installDir ){
                Write-Warning "Usage: make.ps1 install INSTALLDIR"
                exit
            }
            if( -not (Test-Path $installDir) ){
                Write-Warning "$installDir not found."
                exit
            }
            Write-Verbose "installDir=$installDir"
        }
        Write-Output "@set `"INSTALLDIR=$installDir`"" |
            Out-File "Misc\version.cmd" -Encoding Default

        robocopy nyagos.d (Join-Path $installDir "nyagos.d") /E
        Write-Verbose ("ERRORLEVEL=" + $LastExitCode)
        if( $LastExitCode -lt 8 ){
            Remove-Item Variable:LastExitCode
        }
        Ask-Copy "_nyagos" $installDir
        try{
            Do-Copy nyagos.exe $installDir
        }catch{
            $now = (Get-Date -Format "yyyyMMddHHmmss")
            try{
                $old = (Join-Path $installDir "nyagos.exe")
                Rename-Item -path $old -newname ($old + "-" + $now)
                Do-Copy nyagos.exe $installDir
            }catch{
                Write-Host "Could not update installed nyagos.exe"
                Write-Host "Some processes holds nyagos.exe now"
            }
            # [void]([System.Windows.Forms.MessageBox]::Show("Done"))
            timeout /T 3
        }
    }
    "get" {
        if( (git branch --contains) -eq "* master" ){
            Write-Verbose "$GO get -u -v ./..."
            & $GO get -u -v ./...
        } else {
            Write-Verbose "$GO get -v ./..."
            & $GO get -v ./...
        }
    }
    "fmt" {
        Go-Fmt | Out-Null
    }
    "help" {
        Write-Output @'
make                     build as snapshot
make debug   [386|amd64] build as debug version     (tagged as `debug`)
make release [386|amd64] build as release version
make clean               remove all work files
make package [386|amd64] make `nyagos-(VERSION)-(ARCH).zip`
make install [FOLDER]    copy executables to FOLDER or last folder
make fmt                 `go fmt`
make help                show this
'@
    }
    default {
        Write-Warning ("{0} not supported." -f $args[0])
    }
}
if( Test-Path Variable:LastExitCode ){
    exit $LastExitCode
}

# vim:set ft=ps1:

make install: stop killing nyagos.exe running


@ECHO OFF
:: ---------------------------------------------------------------------------
:: Set JAVA_HOME or JRE_HOME if not already set.
::
:: ---------------------------------------------------------------------------
IF "%OS%" == "Windows_NT" setlocal
SET BASEDIR=%~dp0..
SET SCRIPTDIR=%BASEDIR%\scripts

:: ---------------------------------------------------------------------------
:: Tool runner utility
::
:: Environment Variable Prerequisites
::
::   Do not set the variables in this script. Instead put them into a script
::   setenv.bat in scripts directory to keep your customizations separate.
::
::
::   JAVA_HOME       Must point at your Java Development Kit installation.
::
::
::   JRE_HOME        Must point at your Java Runtime installation.
::                   Defaults to JAVA_HOME if empty. If JRE_HOME and JAVA_HOME
::                   are both set, JRE_HOME is used.
::

:: ---------------------------------------------------------------------------
::     JRE_HOME setup

IF NOT "%JRE_HOME%" == "" GOTO gotJRE
SET JRE_HOME=%JAVA_HOME%

if "%JRE_HOME%" == "" (
    ECHO "Error: Cannot find a JRE or JDK. Please set JRE_HOME or JAVA_HOME"
    PAUSE
    EXIT 1
)

:gotJRE

:: ---------------------------------------------------------------------------
::     JAVA_CMD setup

:: check if we got JAVA_CMD set
IF NOT "%JAVA_CMD%" == "" GOTO gotJavaCmd
:: Trying to guess java command
SET JAVA_CMD=%JRE_HOME%\bin\java

:gotJavaCmd

IF EXIST "%JAVA_CMD%.exe" (
    rem OK
) ELSE (
    ECHO "Java command is not defined. Please set JAVA_CMD environment variable pointing to java executable"
    PAUSE
    EXIT 1
)

:: ---------------------------------------------------------------------------
::     CLASS PATH

SETLOCAL EnableDelayedExpansion

REM Get standard environment variables
IF EXIST "%HOMEDRIVE%%HOMEPATH%"/.opengamma/tools.bat (
    CALL "%HOMEDRIVE%%HOMEPATH%/.opengamma/tools.bat"
)

IF "%MEM_OPTS%" == "" (
SET MEM_OPTS=-Xms512m -Xmx1024m -XX:MaxPermSize=256M
)
IF "%GC_OPTS%" == "" (
SET GC_OPTS=-XX:+UseConcMarkSweepGC -XX:+CMSIncrementalMode -XX:+CMSIncrementalPacing
)

SET CLASSPATH=%BASEDIR%\config;%BASEDIR%\lib\override\*;%BASEDIR%\lib\%PROJECTJAR%;

ECHO "%JAVA_CMD%" %MEM_OPTS% %GC_OPTS% -cp "%CLASSPATH%" %*

"%JAVA_CMD%" %MEM_OPTS% %GC_OPTS% -cp "%CLASSPATH%" %*

@ECHO OFF
:: ---------------------------------------------------------------------------
:: Set JAVA_HOME or JRE_HOME if not already set.
::
:: ---------------------------------------------------------------------------
IF "%OS%" == "Windows_NT" setlocal
SET BASEDIR=%~dp0..
SET SCRIPTDIR=%BASEDIR%\scripts

:: ---------------------------------------------------------------------------
:: Tool runner utility
::
:: Environment Variable Prerequisites
::
::   Do not set the variables in this script. Instead put them into a script
::   setenv.bat in scripts directory to keep your customizations separate.
::
::
::   JAVA_HOME       Must point at your Java Development Kit installation.
::
::
::   JRE_HOME        Must point at your Java Runtime installation.
::                   Defaults to JAVA_HOME if empty. If JRE_HOME and JAVA_HOME
::                   are both set, JRE_HOME is used.
::

:: ---------------------------------------------------------------------------
::     JRE_HOME setup

IF NOT "%JRE_HOME%" == "" GOTO gotJRE
SET JRE_HOME=%JAVA_HOME%

if "%JRE_HOME%" == "" (
    ECHO "Error: Cannot find a JRE or JDK. Please set JRE_HOME or JAVA_HOME"
    PAUSE
    EXIT 1
)

:gotJRE

:: ---------------------------------------------------------------------------
::     JAVA_CMD setup

:: check if we got JAVA_CMD set
IF NOT "%JAVA_CMD%" == "" GOTO gotJavaCmd
:: Trying to guess java command
SET JAVA_CMD=%JRE_HOME%\bin\java

:gotJavaCmd

IF EXIST "%JAVA_CMD%.exe" (
    rem OK
) ELSE (
    ECHO "Java command is not defined. Please set JAVA_CMD environment variable pointing to java executable"
    PAUSE
    EXIT 1
)

:: ---------------------------------------------------------------------------
::     CLASS PATH

SETLOCAL EnableDelayedExpansion

REM Get standard environment variables
IF EXIST "%HOMEDRIVE%%HOMEPATH%"/.opengamma/tools.bat (
    CALL "%HOMEDRIVE%%HOMEPATH%/.opengamma/tools.bat"
)

IF "%MEM_OPTS%" == "" (
SET MEM_OPTS=-Xms512m -Xmx1024m -XX:MaxPermSize=256M
)
IF "%GC_OPTS%" == "" (
SET GC_OPTS=-XX:+UseConcMarkSweepGC -XX:+CMSIncrementalMode -XX:+CMSIncrementalPacing
)

SET OVERRIDE=
IF EXIST %BASEDIR%\lib\override (
    PUSHD %BASEDIR%\lib\override
    FOR %%i in (*.jar) do (
        ECHO Using override jar file: %%i
        SET OVERRIDE=!OVERRIDE!;%BASEDIR%\lib\override\%%i
    )
    POPD
)

SET CLASSPATH=%BASEDIR%\config%OVERRIDE%;%BASEDIR%\lib\%PROJECTJAR%;

ECHO "%JAVA_CMD%" %MEM_OPTS% %GC_OPTS% -cp "%CLASSPATH%" %*

"%JAVA_CMD%" %MEM_OPTS% %GC_OPTS% -cp "%CLASSPATH%" %*

Implement override folder without using wildcard

Wildcard confuses scanning


<# :
@echo off
setlocal
set "POWERSHELL_BAT_ARGS=%*"
if defined POWERSHELL_BAT_ARGS set "POWERSHELL_BAT_ARGS=%POWERSHELL_BAT_ARGS:"=\"%"
endlocal & powershell -NoLogo -NoProfile -Command "$_ = $input; Invoke-Expression $( '$input = $_; $_ = \"\"; $args = @( &{ $args } %POWERSHELL_BAT_ARGS% );' + [String]::Join( [char]10, $( Get-Content \"%~f0\" ) ) )"
goto :EOF
#>

$packages = @(

	@{
		"name" = "7-zip";
		"home" = "http://7-zip.org/";
		"url" = "http://downloads.sourceforge.net/sevenzip/7za920.zip";
		"dir" = "7za";
		"postinstall" = {
			$dir = $args[0];
			$script:7zip_exe = "$dir\7za.exe";
		};
	}

	@{
		"name" = "ConEmu";
		"home" = "https://github.com/Maximus5/ConEmu/";
		"url" = "https://github.com/Maximus5/ConEmu/releases/download/v16.03.13/ConEmuPack.160313.7z";
		"dir" = "ConEmu";
	}

	@{
		"Skip" = $True;
		"name" = "ConsoleZ";
		"home" = "https://github.com/cbucher/console";
		# "url" = "https://github.com/cbucher/console/releases/download/1.16.0/ConsoleZ.x86.1.16.0.16038.zip";
		# "url" = "https://github.com/cbucher/console/releases/download/1.16.0/ConsoleZ.x64.1.16.0.16038.zip";
		# "url" = "https://github.com/cbucher/console/releases/download/1.18.0/ConsoleZ.x64.1.18.0.17048.zip";
		# "url" = "https://github.com/cbucher/console/releases/download/1.18.0/ConsoleZ.x86.1.18.0.17048.zip";
		"dir" = "ConsoleZ";
	}

	@{
		"name" = "Clink";
		"home" = "http://mridgers.github.io/clink";
		"url" = "https://github.com/mridgers/clink/releases/download/0.4.8/clink_0.4.8.zip";
		"dir" = "clink";
		"onlyFiles" = $True;
		"postinstall" = {
			$dir = $args[0];
			ls $dir |
			? { $_.Attributes -eq "Directory" } |
			% { rmdir -Force -Path "$dir\$_"; };
		};
	}

	@{
		"name" = "Far3";
		"home" = "http://www.farmanager.com/";
		"url" = "http://www.farmanager.com/files/Far30b4949.x86.20170503.7z";
		"url" = "http://www.farmanager.com/files/Far30b5000.x86.20170807.7z";
		"dir" = "Far3";
	}

	@{
		"skip" = $True;
		"name" = "Far3bis";
		"home" = "http://code.google.com/p/conemu-maximus5/";
		"url" = "http://downloads.sourceforge.net/project/conemu/FarManager/Far3bis/far3.4254bis.x86.x64.7z";
		"dir" = "Far3bis";
	}

	@{
		"name" = "Notepad2-mod";
		"home" = "http://xhmikosr.github.io/notepad2-mod/";
		"url" = "https://github.com/XhmikosR/notepad2-mod/releases/download/4.2.25.985/Notepad2-mod.4.2.25.985_x86.zip";
		"dir" = "notepad2-mod";
		"postinstall" = {
			$dir = $args[0];
			$ini = "$dir\Notepad2.ini";
			mv -Force -Path "$ini" -Destination "$ini.orig";
			& {
				"[Notepad2]";
				"Notepad2.ini=..\..\etc\notepad2\Notepad2.ini";
			} | Out-File "$ini";
		};
	}

	@{
		"name" = "UnxUtils";
		"home" = "http://unxutils.sourceforge.met/";
		"url" = "http://downloads.sourceforge.net/project/unxutils/unxutils/current/UnxUtils.zip";
		"dir" = "unxutils";
		"postinstall" = {
			$dir = $args[0];
			$src = "$dir\usr\local\wbin\*";
			$dst = "$dir\bin";
			mv -Force -Path $src -Destination $dst;
		};
	}

	@{
		"name" = "UnxUtils Updates";
		"home" = "http://unxutils.sourceforge.met/";
		"url" = "http://unxutils.sourceforge.net/UnxUpdates.zip";
		"dir" = "unxutils\bin";
	}

);

# =========================================================================

$vendorsDir = [System.IO.Path]::GetFullPath("$pwd\..\vendors");
$distribDir = "$pwd\distrib";

$7zip_exe = "";

# =========================================================================

function download-archive( [string]$url, [string]$targetDir ) {
	$filename = "$targetDir\" + [System.IO.Path]::GetFileName($url);
	if ( ! ( Test-Path $filename ) ) {
		$webclient = New-Object System.Net.WebClient;
		$webclient.DownloadFile($url, $filename);
	}
	return $filename;
}

function extract-zip( [string]$filename, [string]$targetDir ) {
	$shell = New-Object -com shell.application;
	$zip = $shell.NameSpace($filename);
	foreach ( $item in $zip.items() ) {
		$shell.Namespace($targetDir).CopyHere($item, 16);
	}
}

function extract-7z( [string]$filename, [string]$targetDir, [bool]$onlyFiles ) {
	$mode = if ( $onlyFiles ) { "e" } else { "x" };
	& "$script:7zip_exe" $mode "$filename" -y "-o$targetDir";
}

function extract-archive( [string]$filename, [string]$targetDir, [bool]$onlyFiles ) {
	if ( $script:7zip_exe ) {
		extract-7z $filename $targetDir $onlyFiles;
	} else {
		extract-zip $filename $targetDir;
	}
}

function install-package( $package ) {
	$dstDir = $script:vendorsDir + "\" + $package.dir;

	"=================================================================";
	"Package     : $($package.name)";
	"Destination : $dstDir";

	if ( $package.skip ) {
		"Skipped";
		return;
	}

	New-Item -Force -ItemType Directory -Path $dstDir >$null;
	$filename = download-archive $package.url $script:distribDir;
	extract-archive $filename $dstDir ( !! $package.onlyFiles );

	if ( ! $package.postinstall ) {
		return;
	}

	"`nInvoke command:";
	$package.postinstall;
	Invoke-Command -ScriptBlock $package.postinstall -ArgumentList $dstDir;
}

# =========================================================================

$enabled = "$pwd\candy-for-tea.enabled";
$logfile = "$pwd\candy-for-tea.log";

if ( ! ( Test-Path "$enabled" ) ) {
	[System.Reflection.Assembly]::LoadWithPartialName( "System.Windows.Forms" ) >$Null;
	[System.Windows.Forms.MessageBox]::Show( "To enable execution create the file:`n$enabled.", "Disabled", 0, "Stop" ) >$Null;
	exit;
}

$packages | % { install-package $_; } | Out-File $logfile;

if ( Test-Path $enabled ) {
	Remove-Item -Force -Path "$enabled";
}

# =========================================================================

# EOF

<# :
@echo off
setlocal
set "POWERSHELL_BAT_ARGS=%*"
if defined POWERSHELL_BAT_ARGS set "POWERSHELL_BAT_ARGS=%POWERSHELL_BAT_ARGS:"=\"%"
endlocal & powershell -NoLogo -NoProfile -Command "$_ = $input; Invoke-Expression $( '$input = $_; $_ = \"\"; $args = @( &{ $args } %POWERSHELL_BAT_ARGS% );' + [String]::Join( [char]10, $( Get-Content \"%~f0\" ) ) )"
goto :EOF
#>

$packages = @(

	@{
		"name" = "7-zip";
		"home" = "http://7-zip.org/";
		"url" = "http://downloads.sourceforge.net/sevenzip/7za920.zip";
		"dir" = "7za";
		"postinstall" = {
			$dir = $args[0];
			$script:7zip_exe = "$dir\7za.exe";
		};
	}

	@{
		"name" = "ConEmu";
		"home" = "https://github.com/Maximus5/ConEmu/";
		"url" = "https://github.com/Maximus5/ConEmu/releases/download/v16.03.13/ConEmuPack.160313.7z";
		"dir" = "ConEmu";
	}

	@{
		"Skip" = $True;
		"name" = "ConsoleZ";
		"home" = "https://github.com/cbucher/console";
		# "url" = "https://github.com/cbucher/console/releases/download/1.16.0/ConsoleZ.x86.1.16.0.16038.zip";
		# "url" = "https://github.com/cbucher/console/releases/download/1.16.0/ConsoleZ.x64.1.16.0.16038.zip";
		# "url" = "https://github.com/cbucher/console/releases/download/1.18.0/ConsoleZ.x64.1.18.0.17048.zip";
		# "url" = "https://github.com/cbucher/console/releases/download/1.18.0/ConsoleZ.x86.1.18.0.17048.zip";
		"dir" = "ConsoleZ";
	}

	@{
		"name" = "Clink";
		"home" = "http://mridgers.github.io/clink";
		"url" = "https://github.com/mridgers/clink/releases/download/0.4.8/clink_0.4.8.zip";
		"dir" = "clink";
		"onlyFiles" = $True;
		"postinstall" = {
			$dir = $args[0];
			ls $dir |
			? { $_.Attributes -eq "Directory" } |
			% { rmdir -Force -Path "$dir\$_"; };
		};
	}

	@{
		"name" = "Far3";
		"home" = "http://www.farmanager.com/";
		"url" = "https://farmanager.com/files/Far30b5225.x86.20180604.7z";
		"dir" = "Far3";
	}

	@{
		"skip" = $True;
		"name" = "Far3bis";
		"home" = "http://code.google.com/p/conemu-maximus5/";
		"url" = "http://downloads.sourceforge.net/project/conemu/FarManager/Far3bis/far3.4254bis.x86.x64.7z";
		"dir" = "Far3bis";
	}

	@{
		"name" = "Notepad2-mod";
		"home" = "http://xhmikosr.github.io/notepad2-mod/";
		"url" = "https://github.com/XhmikosR/notepad2-mod/releases/download/4.2.25.985/Notepad2-mod.4.2.25.985_x86.zip";
		"dir" = "notepad2-mod";
		"postinstall" = {
			$dir = $args[0];
			$ini = "$dir\Notepad2.ini";
			mv -Force -Path "$ini" -Destination "$ini.orig";
			& {
				"[Notepad2]";
				"Notepad2.ini=..\..\etc\notepad2\Notepad2.ini";
			} | Out-File "$ini";
		};
	}

	@{
		"name" = "UnxUtils";
		"home" = "http://unxutils.sourceforge.met/";
		"url" = "http://downloads.sourceforge.net/project/unxutils/unxutils/current/UnxUtils.zip";
		"dir" = "unxutils";
		"postinstall" = {
			$dir = $args[0];
			$src = "$dir\usr\local\wbin\*";
			$dst = "$dir\bin";
			mv -Force -Path $src -Destination $dst;
		};
	}

	@{
		"name" = "UnxUtils Updates";
		"home" = "http://unxutils.sourceforge.met/";
		"url" = "http://unxutils.sourceforge.net/UnxUpdates.zip";
		"dir" = "unxutils\bin";
	}

);

# =========================================================================

$vendorsDir = [System.IO.Path]::GetFullPath("$pwd\..\vendors");
$distribDir = "$pwd\distrib";

$7zip_exe = "";

# =========================================================================

function download-archive( [string]$url, [string]$targetDir ) {
	$filename = "$targetDir\" + [System.IO.Path]::GetFileName($url);
	if ( ! ( Test-Path $filename ) ) {
		$webclient = New-Object System.Net.WebClient;
		$webclient.DownloadFile($url, $filename);
	}
	return $filename;
}

function extract-zip( [string]$filename, [string]$targetDir ) {
	$shell = New-Object -com shell.application;
	$zip = $shell.NameSpace($filename);
	foreach ( $item in $zip.items() ) {
		$shell.Namespace($targetDir).CopyHere($item, 16);
	}
}

function extract-7z( [string]$filename, [string]$targetDir, [bool]$onlyFiles ) {
	$mode = if ( $onlyFiles ) { "e" } else { "x" };
	& "$script:7zip_exe" $mode "$filename" -y "-o$targetDir";
}

function extract-archive( [string]$filename, [string]$targetDir, [bool]$onlyFiles ) {
	if ( $script:7zip_exe ) {
		extract-7z $filename $targetDir $onlyFiles;
	} else {
		extract-zip $filename $targetDir;
	}
}

function install-package( $package ) {
	$dstDir = $script:vendorsDir + "\" + $package.dir;

	"=================================================================";
	"Package     : $($package.name)";
	"Destination : $dstDir";

	if ( $package.skip ) {
		"Skipped";
		return;
	}

	New-Item -Force -ItemType Directory -Path $dstDir >$null;
	$filename = download-archive $package.url $script:distribDir;
	extract-archive $filename $dstDir ( !! $package.onlyFiles );

	if ( ! $package.postinstall ) {
		return;
	}

	"`nInvoke command:";
	$package.postinstall;
	Invoke-Command -ScriptBlock $package.postinstall -ArgumentList $dstDir;
}

# =========================================================================

$enabled = "$pwd\candy-for-tea.enabled";
$logfile = "$pwd\candy-for-tea.log";

if ( ! ( Test-Path "$enabled" ) ) {
	[System.Reflection.Assembly]::LoadWithPartialName( "System.Windows.Forms" ) >$Null;
	[System.Windows.Forms.MessageBox]::Show( "To enable execution create the file:`n$enabled.", "Disabled", 0, "Stop" ) >$Null;
	exit;
}

$packages | % { install-package $_; } | Out-File $logfile;

if ( Test-Path $enabled ) {
	Remove-Item -Force -Path "$enabled";
}

# =========================================================================

# EOF

update far3 dl url

update far3 dl url


echo ON

python -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())" > temp.txt
set /p TMP_DIR=<temp.txt
del temp.txt
if %SCONSFLAGS%=="" (
    set SCONSFLAGS=--site-dir=%TMP_DIR%\scons_tools
) else (
    set SCONSFLAGS=%SCONSFLAGS% --site-dir=%TMP_DIR%\scons_tools
)
set TMP_DIR=

echo OFF

echo ON

python -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())" > temp.txt
set /p TMP_DIR=<temp.txt
del temp.txt
if "%SCONSFLAGS%"=="" (
    set SCONSFLAGS=--site-dir=%TMP_DIR%\scons_tools
) else (
    set SCONSFLAGS=%SCONSFLAGS% --site-dir=%TMP_DIR%\scons_tools
)
set TMP_DIR=

echo OFF

Update activate.bat

Update activate.bat


@ECHO OFF

SET UPSTREAMURL=https://github.com/ShiftMediaProject
SET DEPENDENCIES=( ^
bzip2, ^
fontconfig, ^
freetype2, ^
fribidi, ^
game-music-emu, ^
gnutls, ^
lame, ^
libass, ^
libbluray, ^
libgcrypt, ^
libiconv, ^
libilbc, ^
liblzma, ^
libssh, ^
libxml2, ^
libvpx, ^
mfx_dispatch, ^
modplug, ^
opus, ^
sdl, ^
soxr, ^
speex, ^
theora, ^
vorbis, ^
zlib ^
)
SET PGOPTIONS=--enable-version3 --enable-bzlib --enable-iconv --enable-lzma --enable-sdl2 --enable-zlib --enable-libmp3lame --enable-libvorbis --enable-libspeex --enable-libopus --enable-libilbc --enable-libtheora --enable-libvpx --enable-libgme --enable-libmodplug --enable-libsoxr --enable-libfreetype --enable-fontconfig --enable-libfribidi --enable-libass --enable-libxml2 --enable-gnutls --disable-schannel --enable-gcrypt --enable-libssh --enable-libbluray --enable-opengl --enable-libmfx--enable-ffnvcodec --enable-cuda --enable-amf --toolchain=msvc

REM Store current directory and ensure working directory is the location of current .bat
SET CURRDIR=%CD%
cd %~dp0

REM Initialise error check value
SET ERROR=0

REM Check if executable can be located
IF NOT EXIST "project_generate.exe" (
    ECHO "Error: FFVS Project Generator executable file not found."
    IF EXIST "../.git" (
        ECHO "Please build the executable using the supplied project before continuing."
    )
    GOTO exitOnError
)

REM Check if FFmpeg directory can be located
SET SEARCHPATHS=(./, ../, ./ffmpeg/, ../ffmpeg/, ../../ffmpeg/, ../../../, ../../)
SET FFMPEGPATH=
FOR %%I IN %SEARCHPATHS% DO (
    IF EXIST "%%I/ffmpeg.h" (
        SET FFMPEGPATH=%%I
    )
    IF EXIST "%%I/fftools/ffmpeg.h" (
        SET FFMPEGPATH=%%I
    )
)
IF "%FFMPEGPATH%"=="" (
    ECHO Error: Failed finding FFmpeg source directory
    GOTO exitOnError
) ELSE (
    ECHO Located FFmpeg source directory at "%FFMPEGPATH%"
    ECHO.
)

REM Copy across the batch file used to auto get required dependencies
CALL :makeGetDeps || GOTO exit

REM Get/Update any used dependency libraries
SET USERPROMPT=N
SET /P USERPROMPT=Do you want to download/update the required dependency projects (Y/N)?
IF /I "%USERPROMPT%"=="Y" (
    ECHO.
    CALL :getDeps || GOTO exit
    ECHO Ensure that any dependency projects have been built using the supplied project within the dependencies ./SMP folder before continuing.
    ECHO Warning: Some used dependencies require a manual download. Consult the readme for instructions to install the following needed components:
    ECHO    OpenGL
    PAUSE
)

REM Run the executable
ECHO Running project generator...
project_generate.exe %PGOPTIONS%
GOTO exit

:makeGetDeps
ECHO Creating project_get_dependencies.bat...
FOR %%I IN %DEPENDENCIES% DO SET LASTDEP=%%I
MKDIR "%FFMPEGPATH%/SMP" >NUL 2>&1
(
    ECHO @ECHO OFF
    ECHO SETLOCAL EnableDelayedExpansion
    ECHO.
    ECHO SET UPSTREAMURL=%UPSTREAMURL%
    ECHO SET DEPENDENCIES=( ^^
    FOR %%I IN %DEPENDENCIES% DO (
        IF "%%I"=="%LASTDEP%" (
            ECHO %%I ^^
        ) ELSE (
            ECHO %%I, ^^
        )
    )
    type smp_project_get_dependencies
) > "%FFMPEGPATH%/SMP/project_get_dependencies.bat"
ECHO.
EXIT /B %ERRORLEVEL%

:getDeps
REM Add current repo to list of already passed dependencies
ECHO Getting and updating any required dependency libs...
cd "%FFMPEGPATH%/SMP"
CALL project_get_dependencies.bat "ffmpeg" || EXIT /B 1
cd %~dp0
ECHO.
EXIT /B %ERRORLEVEL%

:exitOnError
SET ERROR=1

:exit
REM Check if this was launched from an existing terminal or directly from .bat
REM  If launched by executing the .bat then pause on completion
cd %CURRDIR%
ECHO %CMDCMDLINE% | FINDSTR /L %COMSPEC% >NUL 2>&1
IF %ERRORLEVEL% == 0 IF "%~1"=="" PAUSE
EXIT /B %ERROR%

@ECHO OFF

SET UPSTREAMURL=https://github.com/ShiftMediaProject
SET DEPENDENCIES=( ^
bzip2, ^
fontconfig, ^
freetype2, ^
fribidi, ^
game-music-emu, ^
gnutls, ^
lame, ^
libass, ^
libbluray, ^
libgcrypt, ^
libiconv, ^
libilbc, ^
liblzma, ^
libssh, ^
libxml2, ^
libvpx, ^
mfx_dispatch, ^
modplug, ^
opus, ^
sdl, ^
soxr, ^
speex, ^
theora, ^
vorbis, ^
zlib ^
)
SET PGOPTIONS=--enable-version3 --enable-bzlib --enable-iconv --enable-lzma --enable-sdl2 --enable-zlib --enable-libmp3lame --enable-libvorbis --enable-libspeex --enable-libopus --enable-libilbc --enable-libtheora --enable-libvpx --enable-libgme --enable-libmodplug --enable-libsoxr --enable-libfreetype --enable-fontconfig --enable-libfribidi --enable-libass --enable-libxml2 --enable-gnutls --disable-schannel --enable-gcrypt --enable-libssh --enable-libbluray --enable-opengl --enable-libmfx --enable-ffnvcodec --enable-cuda --enable-amf --toolchain=msvc

REM Store current directory and ensure working directory is the location of current .bat
SET CURRDIR=%CD%
cd %~dp0

REM Initialise error check value
SET ERROR=0

REM Check if executable can be located
IF NOT EXIST "project_generate.exe" (
    ECHO "Error: FFVS Project Generator executable file not found."
    IF EXIST "../.git" (
        ECHO "Please build the executable using the supplied project before continuing."
    )
    GOTO exitOnError
)

REM Check if FFmpeg directory can be located
SET SEARCHPATHS=(./, ../, ./ffmpeg/, ../ffmpeg/, ../../ffmpeg/, ../../../, ../../)
SET FFMPEGPATH=
FOR %%I IN %SEARCHPATHS% DO (
    IF EXIST "%%I/ffmpeg.h" (
        SET FFMPEGPATH=%%I
    )
    IF EXIST "%%I/fftools/ffmpeg.h" (
        SET FFMPEGPATH=%%I
    )
)
IF "%FFMPEGPATH%"=="" (
    ECHO Error: Failed finding FFmpeg source directory
    GOTO exitOnError
) ELSE (
    ECHO Located FFmpeg source directory at "%FFMPEGPATH%"
    ECHO.
)

REM Copy across the batch file used to auto get required dependencies
CALL :makeGetDeps || GOTO exit

REM Get/Update any used dependency libraries
SET USERPROMPT=N
SET /P USERPROMPT=Do you want to download/update the required dependency projects (Y/N)?
IF /I "%USERPROMPT%"=="Y" (
    ECHO.
    CALL :getDeps || GOTO exit
    ECHO Ensure that any dependency projects have been built using the supplied project within the dependencies ./SMP folder before continuing.
    ECHO Warning: Some used dependencies require a manual download. Consult the readme for instructions to install the following needed components:
    ECHO    OpenGL
    PAUSE
)

REM Run the executable
ECHO Running project generator...
project_generate.exe %PGOPTIONS%
GOTO exit

:makeGetDeps
ECHO Creating project_get_dependencies.bat...
FOR %%I IN %DEPENDENCIES% DO SET LASTDEP=%%I
MKDIR "%FFMPEGPATH%/SMP" >NUL 2>&1
(
    ECHO @ECHO OFF
    ECHO SETLOCAL EnableDelayedExpansion
    ECHO.
    ECHO SET UPSTREAMURL=%UPSTREAMURL%
    ECHO SET DEPENDENCIES=( ^^
    FOR %%I IN %DEPENDENCIES% DO (
        IF "%%I"=="%LASTDEP%" (
            ECHO %%I ^^
        ) ELSE (
            ECHO %%I, ^^
        )
    )
    type smp_project_get_dependencies
) > "%FFMPEGPATH%/SMP/project_get_dependencies.bat"
ECHO.
EXIT /B %ERRORLEVEL%

:getDeps
REM Add current repo to list of already passed dependencies
ECHO Getting and updating any required dependency libs...
cd "%FFMPEGPATH%/SMP"
CALL project_get_dependencies.bat "ffmpeg" || EXIT /B 1
cd %~dp0
ECHO.
EXIT /B %ERRORLEVEL%

:exitOnError
SET ERROR=1

:exit
REM Check if this was launched from an existing terminal or directly from .bat
REM  If launched by executing the .bat then pause on completion
cd %CURRDIR%
ECHO %CMDCMDLINE% | FINDSTR /L %COMSPEC% >NUL 2>&1
IF %ERRORLEVEL% == 0 IF "%~1"=="" PAUSE
EXIT /B %ERROR%

Update smp_project_generate_lgpl3.bat

Update smp_project_generate_lgpl3.bat

Missing space between flags.


@echo ==========================
@echo Copying source files for NuGet symbols package
xcopy /ys src\* %TO_PACK_TARGET%\src\src\

@echo ==========================
@echo Copying signed files to the NuGet lib path
set PORTABLE_LIB=portable-net45+win

md %TO_PACK_TARGET%\lib\%PORTABLE_LIB%\
copy /y  %SIGNED%\*.dll "%NUGET_TARGET%\lib\%PORTABLE_LIB%\"
copy /y %TO_SIGN_TARGET%\*.pdb "%NUGET_TARGET%\lib\%PORTABLE_LIB%\"
copy /y %TO_SIGN_TARGET%\*.xml "%NUGET_TARGET%\lib\%PORTABLE_LIB%\"

call %COPY_TO_NUGET_LIBFOLDER% Desktop net45
call %COPY_TO_NUGET_LIBFOLDER% CoreCLR netstandard1.3
call %COPY_TO_NUGET_LIBFOLDER% WinRT netcore45
call %COPY_TO_NUGET_LIBFOLDER% Android MonoAndroid10
call %COPY_TO_NUGET_LIBFOLDER% iOS Xamarin.iOS10

copy /y "%TO_PACK_TARGET%\lib\%PORTABLE_LIB%\*.*" %TO_PACK_TARGET%\lib\net45\
copy /y "%TO_PACK_TARGET%\lib\%PORTABLE_LIB%\*.*" %TO_PACK_TARGET%\lib\netstandard1.3
copy /y "%TO_PACK_TARGET%\lib\%PORTABLE_LIB%\*.*" %TO_PACK_TARGET%\lib\netcore45\
copy /y "%TO_PACK_TARGET%\lib\%PORTABLE_LIB%\*.*" %TO_PACK_TARGET%\lib\MonoAndroid10\
copy /y "%TO_PACK_TARGET%\lib\%PORTABLE_LIB%\*.*" %TO_PACK_TARGET%\lib\Xamarin.iOS10\

del %TO_PACK_TARGET%\*.CodeAnalysisLog.xml /s
del %TO_PACK_TARGET%\*.lastcodeanalysissucceeded /s

@echo ====================================
@echo Copying files for packaging DONE
@echo ====================================
exit 0

@echo ==========================
@echo Copying source files for NuGet symbols package
xcopy /ys src\* %TO_PACK_TARGET%\src\src\

@echo ==========================
@echo Copying signed files to the NuGet lib path
set PORTABLE_LIB=portable-net45+win

md %TO_PACK_TARGET%\lib\%PORTABLE_LIB%\
copy /y  %SIGNED%\*.dll "%NUGET_TARGET%\lib\%PORTABLE_LIB%\"
copy /y %TO_SIGN_TARGET%\*.pdb "%NUGET_TARGET%\lib\%PORTABLE_LIB%\"
copy /y %TO_SIGN_TARGET%\*.xml "%NUGET_TARGET%\lib\%PORTABLE_LIB%\"

set COPY_TO_NUGET_LIBFOLDER=build/copy-to-nuget-libfolder.cmd

call %COPY_TO_NUGET_LIBFOLDER% Desktop net45
call %COPY_TO_NUGET_LIBFOLDER% CoreCLR netstandard1.3
call %COPY_TO_NUGET_LIBFOLDER% WinRT netcore45
call %COPY_TO_NUGET_LIBFOLDER% Android MonoAndroid10
call %COPY_TO_NUGET_LIBFOLDER% iOS Xamarin.iOS10

copy /y "%TO_PACK_TARGET%\lib\%PORTABLE_LIB%\*.*" %TO_PACK_TARGET%\lib\net45\
copy /y "%TO_PACK_TARGET%\lib\%PORTABLE_LIB%\*.*" %TO_PACK_TARGET%\lib\netstandard1.3
copy /y "%TO_PACK_TARGET%\lib\%PORTABLE_LIB%\*.*" %TO_PACK_TARGET%\lib\netcore45\
copy /y "%TO_PACK_TARGET%\lib\%PORTABLE_LIB%\*.*" %TO_PACK_TARGET%\lib\MonoAndroid10\
copy /y "%TO_PACK_TARGET%\lib\%PORTABLE_LIB%\*.*" %TO_PACK_TARGET%\lib\Xamarin.iOS10\

del %TO_PACK_TARGET%\*.CodeAnalysisLog.xml /s
del %TO_PACK_TARGET%\*.lastcodeanalysissucceeded /s

@echo ====================================
@echo Copying files for packaging DONE
@echo ====================================
exit 0

Address review comments for automated packing.


if not exist C:\dev\swig goto noswig

set PATH=C:\dev\swig;C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC;%PATH%

@echo off
rem NOTE: If building under MobaSSH, the C:\Windows\System32\bsh\temp path is an issue
rem You'll see something like this after the swig step:
rem 	c1xx : fatal error C1083: Cannot open compiler intermediate file:
rem           'C:\Windows\system32\bsh\tmp\_CL_96a80b23ex': No such file or directory

echo.%TMP% | findstr /I /C:"system32\bsh">nul && (
    echo "Detected MobaSSH session. Changing TMP path to C:\temp."
    mkdir C:\temp
    set TMP=C:\temp
) || (
    echo "Running under regular command line"
)
@echo on

"%PYTHON%" setup.py build
"%PYTHON%" setup.py install
if errorlevel 1 exit 1

exit 0

:noswig
echo "Expected SWIG to be in the path C:\dev\swig"
echo "Please install swig >= 3.0.7 there from:"
echo "http://sourceforge.net/projects/swig/files/swigwin/swigwin-3.0.7/swigwin-3.0.7.zip/download"
exit 1

if not exist C:\dev\swig goto noswig

echo on

set PATH=C:\dev\swig;C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC;%PATH%

rem NOTE: git version tag broken on conda-build-1.18.2 (revert to 1.18.1 or use
rem       the version after when it's released)

@echo off
rem NOTE: If building under MobaSSH, the C:\Windows\System32\bsh\temp path is an issue
rem You'll see something like this after the swig step:
rem 	c1xx : fatal error C1083: Cannot open compiler intermediate file:
rem           'C:\Windows\system32\bsh\tmp\_CL_96a80b23ex': No such file or directory

echo.%TMP% | findstr /I /C:"system32\bsh">nul && (
    echo "Detected MobaSSH session. Changing TMP path to C:\temp."
    mkdir C:\temp
    set TMP=C:\temp
) || (
    echo "Running under regular command line"
)
@echo on

"%PYTHON%" setup.py build
"%PYTHON%" setup.py install
if errorlevel 1 exit 1

exit 0

:noswig
echo "Expected SWIG to be in the path C:\dev\swig"
echo "Please install swig >= 3.0.7 there from:"
echo "http://sourceforge.net/projects/swig/files/swigwin/swigwin-3.0.7/swigwin-3.0.7.zip/download"
exit 1

Add note about version tag being busted on conda-build-1.18.2 on windows


@jam --workspace --gen=vs2008 Jamfile.jam ./Build

add this, even though it doesn't work

add this, even though it doesn't work


@echo off
REM - Project: MultiPython-For-Windows
REM - File: Run Python 2.7 Executable Script
REM - Filename: py27.cmd
REM - Author: Daniel Pronych
REM - Date: March 20, 2015
REM - License Notes:
REM - MultiPython-For-Windows is Copyright (C) 2015 Daniel Pronych
REM - MultiPython-For-Windows comes with ABSOLUTELY NO WARRANTY; For details
REM - see the file named LICENSE.txt in the root of the source directory tree.
setlocal
REM - Run Configuration File For Python 2.7 Environment
call %~dp0%config_python_2.7.cmd
REM - Run Python Executable
"%PYTHONPATH%\python" %1 %*
endlocal

@echo off
REM - Project: MultiPython-For-Windows
REM - File: Run Python 2.7 Executable Script
REM - Filename: py27.cmd
REM - Author: Daniel Pronych
REM - Date: March 20, 2015
REM - License Notes:
REM - MultiPython-For-Windows is Copyright (C) 2015 Daniel Pronych
REM - MultiPython-For-Windows comes with ABSOLUTELY NO WARRANTY; For details
REM - see the file named LICENSE.txt in the root of the source directory tree.
setlocal
REM - Run Configuration File For Python 2.7 Environment
call %~dp0%config_python_2.7.cmd
REM - Run Python Executable
"%PYTHONDIR%\python" %1 %*
endlocal

Update py27.cmd

Update py27.cmd

Use PYTHONDIR instead of PYTHONPATH.


cd c:\tools\php
copy php.ini-production php.ini /Y
echo date.timezone="UTC" >> php.ini
echo extension_dir=ext >> php.ini
echo extension=php_openssl.dll >> php.ini
echo extension=php_mbstring.dll >> php.ini
echo extension=php_fileinfo.dll >> php.ini
echo @php %%~dp0composer.phar %%* > composer.bat
appveyor-retry appveyor DownloadFile https://getcomposer.org/composer.phar

Create appveyor.bat

Create appveyor.bat

Copied from https://raw.githubusercontent.com/php-api-clients/hydrator/master/appveyor.bat


@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 OS=32 || SET OS=64
REM -- Disable UAC.
reg ADD "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" /v EnableLUA /t REG_DWORD /d 0 /f

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

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

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 7-Zip
SET SEVENZIP_FILENAME=7z1604

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

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" http://download.virtualbox.org/virtualbox/%VERSION%/%VBOXGUEST_FILENAME% %TEMP%\%VBOXGUEST_FILENAME%

if not exist %VBOXGUEST_MOUNTDIR% (
  MKDIR %VBOXGUEST_MOUNTDIR%
)

7z e -o%VBOXGUEST_MOUNTDIR% %TEMP%\%VBOXGUEST_FILENAME% -y
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"
)

ECHO All good.
GOTO :end

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

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

EXIT /B

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

REM ----------------------------------------------------------------------------
:install

START /B /wait msiexec /QB /i %2 /L*vx %2-install.log /norestart
EXIT /B

REM ----------------------------------------------------------------------------
:end

ENDLOCAL
PAUSE
EXIT /B

@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 OS=32 || SET OS=64
REM -- Disable UAC.
reg ADD "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" /v EnableLUA /t REG_DWORD /d 0 /f

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

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

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 == %OS% (
  SET SEVENZIP_FILENAME=%SEVENZIP_FILENAME%-x%OS%
)

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 http://download.virtualbox.org/virtualbox/%VERSION%/%VBOXGUEST_FILENAME% %TEMP%\%VBOXGUEST_FILENAME%

if not exist %VBOXGUEST_MOUNTDIR% (
  MKDIR %VBOXGUEST_MOUNTDIR%
)

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
  ) else (
    ECHO [SUCCESS] VM successfully provisioned.
  )
)

GOTO :end

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

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

EXIT /B

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

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

REM ----------------------------------------------------------------------------
:end
PAUSE
EXIT /B 0

Improve Windows environment preparation

[CIKit][Tests] Improve Windows environment preparation


@echo off
:: Copyright (c) 2010 The Chromium Authors. All rights reserved.
:: Use of this source code is governed by a BSD-style license that can be
:: found in the LICENSE file.

set PYTHONPATH=%~dp0../python/google
python %~dp0/chrome_tests.py %*

@echo off
:: Copyright (c) 2010 The Chromium Authors. All rights reserved.
:: Use of this source code is governed by a BSD-style license that can be
:: found in the LICENSE file.

set TSAN_PATH=%~dp0..\..\third_party\tsan
set TSAN_SFX=%TSAN_PATH%\tsan-x86-windows-sfx.exe
if EXIST %TSAN_SFX% GOTO BINARY_OK
echo "Can't find ThreadSanitizer executables."
echo "See http://www.chromium.org/developers/how-tos/using-valgrind/threadsanitizer/threadsanitizer-on-windows"
echo "for the instructions on how to get them."
set %ERRORLEVEL% 1
goto :EOF

:BINARY_OK
%TSAN_SFX% -o%TSAN_PATH%\unpacked -y
set PIN_COMMAND=%TSAN_PATH%\unpacked\tsan-x86-windows\tsan.bat
set PYTHONPATH=%~dp0../python/google
python %~dp0/chrome_tests.py %*

Set PIN_COMMAND env to the TSan/Win runner path.
This is similar to the way Valgrind path is guessed in locate_valgrind.sh
TBR=glider
Review URL: http://codereview.chromium.org/2150002

git-svn-id: de016e52bd170d2d4f2344f9bf92d50478b649e0@48033 0039d316-1c4b-4281-b951-d872f2087c98


@echo off
:#*****************************************************************************
:#                                                                            *
:#  Filename:	    configure.minicoms.bat				      *
:#                                                                            *
:#  Description:    Define MiniComs-specific configuration settings           *
:#                                                                            *
:#  Notes:	                                                              *
:#                                                                            *
:#  History:                                                                  *
:#   2015-10-27 JFL Created this file.					      *
:#   2016-04-11 JFL Renamed NODOSLIB as BIOSLIB.                              *
:#   2016-04-12 JFL Added a dependency on the MULTIOS library.                *
:#                                                                            *
:#*****************************************************************************

:# Declare the SDKs and libraries we need
%BEGIN_SDK_DEFS%
%USE_SDK% BIOSLIB
%USE_SDK% LODOSLIB
%USE_SDK% PMODELIB
%END_SDK_DEFS%

Configure BiosLib, LoDosLib, PModeLib.

Configure BiosLib, LoDosLib, PModeLib.


:: Automatically check & get admin rights
:::::::::::::::::::::::::::::::::::::::::
@echo off
CLS
ECHO.
ECHO =======================================
ECHO Running Admin shell to create symlink
ECHO =======================================

:checkPrivileges
NET FILE 1>NUL 2>NUL
if '%errorlevel%' == '0' ( goto gotPrivileges ) else ( goto getPrivileges )

:getPrivileges
if '%1'=='ELEV' (shift & goto gotPrivileges)
ECHO.
ECHO **************************************
ECHO Invoking UAC for Privilege Escalation
ECHO **************************************

setlocal DisableDelayedExpansion
set "batchPath=%~0"
setlocal EnableDelayedExpansion
ECHO Set UAC = CreateObject^("Shell.Application"^) > "%temp%\OEgetPrivileges.vbs"
ECHO UAC.ShellExecute "!batchPath!", "ELEV", "", "runas", 1 >> "%temp%\OEgetPrivileges.vbs"
"%temp%\OEgetPrivileges.vbs"
exit /B

:gotPrivileges
::::::::::::::::::::::::::::
::START
::::::::::::::::::::::::::::
setlocal & pushd .

REM Run shell as admin (example) - put here code as you like
REM cmd /k

@echo off
for /F %%f IN ( %~dp0..\MinGW\msysgit\libexec\git-core\msysgit_stripped_files ) DO (
 @echo Processing %%f
 mklink  /H %~dp0..\MinGW\msysgit\libexec\git-core\%%f %~dp0..\MinGW\msysgit\libexec\git-core\git.exe
)
pause

Add symlink files.

Add symlink files.


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.

@echo off

set OLD_ANT_HOME=%ANT_HOME%
set ANT_HOME=..\..\tools\ant

set OLD_CLASSPATH=%CLASSPATH%
set CLASSPATH=
for %%i in (..\..\lib\endorsed\*.jar) do call appendcp.bat %%i

echo Using classpath: "%CLASSPATH%"
call %ANT_HOME%\bin\ant -emacs %1 %2 %3 %4 %5 %6 %7 %8 %9

set ANT_HOME=%OLD_ANT_HOME%
set CLASSPATH=%OLD_CLASSPATH%

@echo off
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.

set OLD_ANT_HOME=%ANT_HOME%
set ANT_HOME=..\..\tools\ant

set OLD_CLASSPATH=%CLASSPATH%
set CLASSPATH=
for %%i in (..\..\lib\endorsed\*.jar) do call appendcp.bat %%i

echo Using classpath: "%CLASSPATH%"
call %ANT_HOME%\bin\ant -emacs %1 %2 %3 %4 %5 %6 %7 %8 %9

set ANT_HOME=%OLD_ANT_HOME%
set CLASSPATH=%OLD_CLASSPATH%

Move the @echo line above license header so it is not echoed to command line. Thanks to Vincent Siveton FOR-1021

git-svn-id: 36dcc065b18e9ace584b1c777eaeefb1d96b1ee8@555984 13f79535-47bb-0310-9956-ffa450edef68


inject.exe --run "F:\Games\SteamLibrary\steamapps\common\ARK\ShooterGame\Binaries\Win64\ShooterGame.exe" --inject --steam-app-id 346110 --export Load --add-path --path-resolution --module cerberus.dll

Add ARK.

[Scripts] Add ARK.