@echo off

set SCRIPTS=..\scripts
set SOFTWARE=..\software
set T=%SystemDrive%\TEMP
set TOOLS=%SystemDrive%\tools
set MSI=vnc-setup.msi

if NOT EXIST %SOFTWARE%\%MSI% (
  echo ERROR: %SOFTWARE%\%MSI% not found!
  exit /b
)

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

echo unpacking vnc (tvnviewer) ...
cd %SOFTWARE%
@echo on
msiexec /a %MSI% TARGETDIR=%T% /qn
@echo off
cd %SCRIPTS%

echo moving vnc binary to tools folder ...
move /Y %T%\PFiles\TightVNC\tvnviewer.exe %TOOLS%
del /F /Q %T%\%MSI% 1>nul 2>nul
rd /S /Q %T%\PFiles

rem create symbolic link ...
mklink %TOOLS%\vnc.exe %TOOLS%\tvnviewer.exe 2>nul

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

