@echo off

set T=%SystemDrive%\TEMP
set TOOLS=%SystemDrive%\tools
set SOFTWARE=..\software

echo ####### %0 #######

rem ###################################
rem MAIN loop ( unzip archives ) ...
rem ###################################

for %%A in (

  cmail
  curl
  desktopinfo
  devmanview
  imapcopy
  nsudo
  offlineregistryfinder
  rclone
  registryfinder
  regscanner
  restic
  serviwin
  setdefaultbrowser
  showkeyplus
  sumatrapdf
  tcpoptimize
  trid
  triddefs
  vim
  wget
  wgetdeps
  winscp
  wub
  wumgr
  uwt

) do (
  
  if NOT EXIST %SOFTWARE%\%%A.zip (
    echo WARNING: %SOFTWARE%\%%A.zip not found!
  ) else (
    echo unpacking %%A.zip ...
    %TOOLS%\7z e -y -aoa -o%T%\%%A %SOFTWARE%\%%A.zip 1>nul
  )

)

echo.
echo ###################################
echo move files to tools folder
echo ###################################
echo.

echo CMail - a Windows mailer
move /Y %T%\cmail\cmail.exe %TOOLS%
rd /S /Q %T%\cmail
echo.

echo CURL
move /Y %T%\curl\curl.exe %TOOLS%
move /Y %T%\curl\libcurl*.dll %TOOLS%
move /Y %T%\curl\curl-ca-bundle.crt %TOOLS%
rd /S /Q %T%\curl
echo.

echo Desktopinfo
mkdir %TOOLS%\desktopinfo 2>nul
move /Y %T%\desktopinfo\Desktopinfo64.exe %TOOLS%\desktopinfo
move /Y %T%\desktopinfo\*.dll %TOOLS%\desktopinfo
move /Y %T%\desktopinfo\*.pdf %TOOLS%\desktopinfo
rd /S /Q %T%\desktopinfo
copy /Y config\desktopinfo.ini %TOOLS%\desktopinfo
echo.

echo DevManView
move /Y %T%\devmanview\*.exe %TOOLS%
rd /S /Q %T%\devmanview
echo.

echo ImapCopy
mkdir %TOOLS%\imapcopy 2>nul
move /Y %T%\imapcopy\* %TOOLS%\imapcopy
rd /S /Q %T%\imapcopy
echo.

echo OfflineRegistryFinder
move /Y %T%\offlineregistryfinder\*.exe %TOOLS%
rd /S /Q %T%\offlineregistryfinder
copy /Y config\OfflineRegistryFinder.cfg %TOOLS%
echo.

echo NSudo
move /Y %T%\nsudo\NSudoLC.exe %TOOLS%\nsudo.exe
rd /S /Q %T%\nsudo
echo.

echo RClone
move /Y %T%\rclone\rclone.exe %TOOLS%
rd /S /Q %T%\rclone
echo.

echo Registry Finder
mkdir %TOOLS%\registryfinder 2>nul
move /Y %T%\registryfinder\RegistryFinder.exe %TOOLS%\registryfinder
move /Y %T%\registryfinder\RegistryFinder.ico %TOOLS%\registryfinder
rd /S /Q %T%\registryfinder
echo.

echo RegScanner
move /Y %T%\regscanner\*.exe %TOOLS%
rd /S /Q %T%\regscanner
echo.

echo Restic
move /Y %T%\restic\*.exe %TOOLS%\restic.exe
rd /S /Q %T%\restic
echo.

echo SetDefaultBrowser
move /Y %T%\SetDefaultBrowser\*.exe %TOOLS%
rd /S /Q %T%\SetDefaultBrowser
echo.

echo ServiWIN
move /Y %T%\serviwin\*.exe %TOOLS%
rd /S /Q %T%\serviwin
echo.

echo ShowKeyPlus
move /Y %T%\showkeyplus\*.exe %TOOLS%
rd /S /Q %T%\showkeyplus
echo.

echo SumatraPDF
move /Y %T%\sumatrapdf\*.exe %TOOLS%\SumatraPDF.exe
rd /S /Q %T%\sumatrapdf
echo.

echo TCP-optimize script
move /Y %T%\tcpoptimize\*.ps1 %TOOLS%\scripts\tcpoptimize.ps1
rd /S /Q %T%\tcpoptimize
echo.

echo TrID (File identifier)
move /Y %T%\trid\trid.exe %TOOLS%
rd /S /Q %T%\trid
echo.

echo TrID (File identifier DATABASE)
move /Y %T%\triddefs\triddefs.trd %TOOLS%
rd /S /Q %T%\triddefs
echo.

echo VIM
move /Y %T%\vim\vim.exe %TOOLS%
rd /S /Q %T%\vim
rem create symbolic link ...
mklink %TOOLS%\vi.exe %TOOLS%\vim.exe 2>nul
echo.

echo wGET
move /Y %T%\wget\wget.exe %TOOLS%
rd /S /Q %T%\wget
move /Y %T%\wgetdeps\*.dll %TOOLS%
rd /S /Q %T%\wgetdeps
echo.

echo WinSCP
move /Y %T%\winscp\*.exe %TOOLS%
rd /S /Q %T%\winscp
echo.

echo WUB - Windows update blocker
move /Y %T%\wub\wub_x64.exe %TOOLS%\wub.exe
rd /S /Q %T%\wub
echo.

echo WUMGR - Windows update manager
move /Y %T%\wumgr\wumgr.exe %TOOLS%\wumgr.exe
rd /S /Q %T%\wumgr
echo.

echo UWT - Ultimate Windows Tweaker
mkdir %TOOLS%\uwt 2>nul
move /Y %T%\uwt\*.exe %TOOLS%\uwt\uwt.exe
move /Y %T%\uwt\*.dll %TOOLS%\uwt
rd /S /Q %T%\uwt
echo.

echo +++++++++++++++++++++++
echo ++++ Android tools ++++
echo +++++++++++++++++++++++

if NOT EXIST %SOFTWARE%\android.zip (
  echo WARNING: %SOFTWARE%\android.zip not found!
) else (
  echo unpacking android.zip ...
  %TOOLS%\7z x -y -aoa -o%TOOLS% %SOFTWARE%\android.zip 1>nul
  rd /S /Q %TOOLS%\android 2>nul
  move /Y %TOOLS%\platform-tools %TOOLS%\android
)
echo.

echo ++++++++++++++++++++++
echo ++++ Sysinternals ++++
echo ++++++++++++++++++++++

if NOT EXIST %SOFTWARE%\sysinternals.zip (
  echo WARNING: %SOFTWARE%\sysinternals.zip not found!
) else (
  echo unpacking sysinternals.zip ...
  mkdir %TOOLS%\sysinternals 2>nul
  %TOOLS%\7z e -y -aoa -o%TOOLS%\sysinternals %SOFTWARE%\sysinternals.zip 1>nul

  echo put autoruns in place ...
  move /Y %TOOLS%\sysinternals\autoruns.exe %TOOLS%
)
echo.

echo ####### %0 #######

