@echo off
::configure and install app files
set install_dir="%appdata%\QuickWho_App\"
set config_dir="%appdata%\QuickWho\"
set config
if not exist %install_dir% (
mkdir %install_dir%
)
 
if not exist %config_dir% (
mkdir %config_dir%
)
call 7za  x quickwho.zip
xcopy bin %install_dir%\bin /s /i /y
xcopy lib %install_dir%\lib /s /i /y
xcopy quickwho %install_dir%\quickwho /s /i /y
copy /Y uninstall.bat %config_dir%\
copy /Y quickwho.ico %config_dir%\

::test for key, add to registry
reg query "HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\QuickWho.exe"
if errorlevel 0 (
reg delete "HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\QuickWho.exe" /f
)
reg add "HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\QuickWho.exe" /f
reg add "HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\QuickWho.exe"  /ve /d "%appdata%\QuickWho_App\quickwho\QuickWho.exe" /f
 
reg add "HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\QuickWho" /f
reg add "HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\QuickWho" /f /v "DisplayIcon" /t REG_SZ /d "%appdata%\QuickWho\quickwho.ico"
reg add "HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\QuickWho" /f /v "DisplayName" /t REG_SZ /d "QuickWho"
reg add "HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\QuickWho" /f /v "InstallLocation" /t REG_SZ /d "%install_dir%"

reg add "HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\QuickWho" /f /v "Publisher" /t REG_SZ /d "WordTech Communications LLC"
reg add "HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\QuickWho" /f /v "InstallDate" /t REG_SZ /d %DATE%
reg add "HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\QuickWho" /f /v "Version" /t REG_SZ /d 6.0.0
 
reg add "HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\QuickWho" /f /v "UninstallString" /t REG_SZ /d "cmd /c %appdata%\QuickWho\uninstall.bat"
 
::add to start menu
set startdir="%appdata%\Microsoft\Windows\Start Menu\QuickWho\"

if not exist %startdir% (
mkdir %startdir%
)
cd %startdir%

::mklink /H QuickWho.exe "%appdata%\QuickWho_App\quickwho\QuickWho.exe"

echo Set oWS = WScript.CreateObject("WScript.Shell") >%temp%\link.vbs
echo sLinkFile = "QuickWho.lnk" >>  %temp%\link.vbs
echo Set oLink = oWS.CreateShortcut(sLinkFile) >>  %temp%\link.vbs
echo oLink.TargetPath = "%appdata%\QuickWho_App\quickwho\QuickWho.exe" >> %temp%\link.vbs
echo oLink.Save >>  %temp%\link.vbs
call  %temp%\link.vbs
del %temp%\link.vbs

cd C:\Users\%username%\Desktop
echo Done.