@echo off
call check-for-admin
if %ERRORLEVEL% neq 0 exit /b

set TOOLS=%SystemDrive%\tools
set INIFILE=config\snapcontrol.ini
set SOFTWARE=..\software
set STARTMENU="%PROGRAMDATA%\Microsoft\Windows\Start Menu\Programs\tools"

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

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

echo killing snapcontrol processes...
taskkill /F /IM snapcontrol.exe 2>nul

echo killing snapshot processes...
taskkill /F /IM snapshot64.exe 2>nul

echo copy snapcontrol binary to [ %windir% ] ...
copy /Y %SOFTWARE%\snapcontrol.exe %windir% 2>nul

if EXIST %SOFTWARE%\snapshot64_licensed.exe (
  echo copying LICENSED snapshot64 to %windir% ...
  copy /Y %SOFTWARE%\snapshot64_licensed.exe %windir%\snapshot64.exe
) else (
  echo copying STANDARD snapshot64 to boot image ...
  copy /Y %SOFTWARE%\snapshot64.exe %windir%
)
  
if NOT EXIST %windir%\snapcontrol.ini (
  echo copying STANDARD inifile to %windir% ...
  copy /Y %INIFILE% %windir%
) else (
  echo inifile already copied. nothing to do!
)

echo creating scheduler task ...
%windir%\snapcontrol /I

echo copy startmenu link ...
copy /Y "startmenu\Drive Snapshot.lnk" %STARTMENU%

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

