git-lfs/script/install.bat.example

49 lines
1.3 KiB
Plaintext

:::::::::::::::::::::::::::::::::::::::::
:: Automatically check & get admin rights
:::::::::::::::::::::::::::::::::::::::::
@echo off
CLS
:: Check if git.exe is in the user's path before continuing
where /q git.exe
if %errorlevel% neq 0 (ECHO Unable to find git.exe, exiting... & EXIT /b %errorlevel%)
:checkPrivileges
NET FILE 1>NUL 2>NUL
if '%errorlevel%' == '0' ( goto gotPrivileges ) else ( goto getPrivileges )
:getPrivileges
if '%1'=='ELEV' (shift & goto gotPrivileges)
echo.
echo **************************************
echo Installing Git LFS as Administrator
echo **************************************
setlocal DisableDelayedExpansion
set "batchPath=%~0"
setlocal EnableDelayedExpansion
echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\OEgetPrivileges.vbs"
echo UAC.ShellExecute "!batchPath!", "ELEV", "", "runas", 1 >> "%temp%\OEgetPrivileges.vbs"
"%temp%\OEgetPrivileges.vbs"
exit /B
:gotPrivileges
setlocal & cd /d %~dp0
set GIT_MEDIA_BIN_PATH="%LOCALAPPDATA%\GitMedia\bin"
IF EXIST %GIT_MEDIA_BIN_PATH% GOTO DIRECTORY_EXISTS
mkdir %GIT_MEDIA_BIN_PATH%
set "path=%PATH%;%GIT_MEDIA_BIN_PATH:"=%"
1>NUL setx PATH "%PATH%" /M
:DIRECTORY_EXISTS
:: Delete any existing git-media programs
2>NUL del /q %GIT_MEDIA_BIN_PATH%\git-media*
1>NUL copy git-media.exe %GIT_MEDIA_BIN_PATH%\git-media.exe
git lfs init
cmd /k