
@echo off
cls
title PAD Controller Setup

set "params=%*"
cd /d "%~dp0" && ( if exist "%temp%\getadmin.vbs" del "%temp%\getadmin.vbs" ) && fsutil dirty query %systemdrive% 1>nul 2>nul || (  echo Set UAC = CreateObject^("Shell.Application"^) : UAC.ShellExecute "cmd.exe", "/k cd ""%~sdp0"" && %~s0 %params%", "", "runas", 1 >> "%temp%\getadmin.vbs" && "%temp%\getadmin.vbs" && exit /B )

call vc_redist.x86.exe /q

echo Updating 
taskkill /im CentralizedPADControllerMFC.exe /t /f > nul 2> nul

IF not exist "C:\ProgramData\PineLabs" (
mkdir "C:\ProgramData\PineLabs"
) 

IF exist "%USERPROFILE%\AppData\Local\VirtualStore\Progra~2\PineLabs\CentralisedPADController\Config.ini" (
  move "%USERPROFILE%\AppData\Local\VirtualStore\Progra~2\PineLabs\CentralisedPADController\Config.ini" "C:\ProgramData\PineLabs\Config.ini" > nul 2> nul
 ) ELSE IF exist "C:\Progra~2\PineLabs\CentralisedPADController\Config.ini" (
  move "C:\Progra~2\PineLabs\CentralisedPADController\Config.ini" "C:\ProgramData\PineLabs\Config.ini" > nul 2> nul
 ) ELSE IF exist "%USERPROFILE%\AppData\Local\VirtualStore\ProgramData\PineLabs\CentralisedPADController\Config.ini" (
  move "%USERPROFILE%\AppData\Local\VirtualStore\ProgramData\PineLabs\CentralisedPADController\Config.ini" "C:\ProgramData\PineLabs\Config.ini" > nul 2> nul
 ) ELSE (
 move "C:\ProgramData\PineLabs\CentralisedPADController\Config.ini" "C:\ProgramData\PineLabs\Config.ini" > nul 2> nul
)
rem move "C:\ProgramData\PineLabs\CentralisedPADController\Config.ini" "C:\ProgramData\PineLabs\Config.ini"
rem msiexec /i "%~dp0\ServiceBuild\PADDaemonSetupWin7.msi" /qn
echo Clearing please wait...
rem msiexec /x "%~dp0\PADDaemonSetupWin7.msi" /qn
wmic product where "name='PADDaemonSetup'" call uninstall > nul 2> nul
rem msiexec /uninstall {D873F3C3-36CA-4A73-B1A3-273E225DEC83} /qn
IF exist "C:\Progra~2\PineLabs\CentralisedPADController" (
msiexec /x "%~dp0\PADDaemonSetupWin7.msi" /qn
msiexec /uninstall {D873F3C3-36CA-4A73-B1A3-273E225DEC83} /qn )
IF exist "%userprofile%\desktop\CentralizedPADController.lnk" (
del "%userprofile%\desktop\CentralizedPADController.lnk")
IF exist "C:\Progra~2\PineLabs\CentralisedPADController" (
RmDir /s /q "C:\Progra~2\PineLabs\CentralisedPADController")
echo Installing
msiexec /i "%~dp0\PADDaemonSetup.msi"  /qn
move "C:\ProgramData\PineLabs\Config.ini" "C:\ProgramData\PineLabs\CentralisedPADController\Config.ini" > nul 2> nul
rem C:\Windows\System32\cmd /min /C start "" /B "%userprofile%\desktop\CentralizedPADController.lnk" > nul 2> nul 
echo restarting
taskkill /im CentralizedPADControllerMFC.exe /t /f > nul 2> nul
rem C:\Windows\System32\cmd /min /C start "" /B "%userprofile%\desktop\CentralizedPADController.lnk" > nul 2> nul
net start PADControllerDaemon
rem del "PADDaemonSetup.msi"
echo Process Done
Pause
TASKKILL /F /IM cmd.exe /T 





