Created
October 11, 2019 03:46
-
-
Save leogao2/ee9db1bbeaf259a68f138611cd2b3243 to your computer and use it in GitHub Desktop.
ex2-env-setup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
:::::::::::::::::::::::::::::::::::::::::::: | |
:: Elevate.cmd - Version 4 | |
:: Automatically check & get admin rights | |
:: see "https://stackoverflow.com/a/12264592/1016343" for description | |
:::::::::::::::::::::::::::::::::::::::::::: | |
@echo off | |
CLS | |
echo AlbertaSat Development Environment Installer v1.0 | |
:init | |
setlocal DisableDelayedExpansion | |
set cmdInvoke=1 | |
set winSysFolder=System32 | |
set "batchPath=%~0" | |
for %%k in (%0) do set batchName=%%~nk | |
set "vbsGetPrivileges=%temp%\OEgetPriv_%batchName%.vbs" | |
setlocal EnableDelayedExpansion | |
:checkPrivileges | |
NET FILE 1>NUL 2>NUL | |
if '%errorlevel%' == '0' ( goto gotPrivileges ) else ( goto getPrivileges ) | |
:getPrivileges | |
if '%1'=='ELEV' (echo ELEV & shift /1 & goto gotPrivileges) | |
ECHO Set UAC = CreateObject^("Shell.Application"^) > "%vbsGetPrivileges%" | |
ECHO args = "ELEV " >> "%vbsGetPrivileges%" | |
ECHO For Each strArg in WScript.Arguments >> "%vbsGetPrivileges%" | |
ECHO args = args ^& strArg ^& " " >> "%vbsGetPrivileges%" | |
ECHO Next >> "%vbsGetPrivileges%" | |
if '%cmdInvoke%'=='1' goto InvokeCmd | |
ECHO UAC.ShellExecute "!batchPath!", args, "", "runas", 1 >> "%vbsGetPrivileges%" | |
goto ExecElevation | |
:InvokeCmd | |
ECHO args = "/c """ + "!batchPath!" + """ " + args >> "%vbsGetPrivileges%" | |
ECHO UAC.ShellExecute "%SystemRoot%\%winSysFolder%\cmd.exe", args, "", "runas", 1 >> "%vbsGetPrivileges%" | |
:ExecElevation | |
"%SystemRoot%\%winSysFolder%\WScript.exe" "%vbsGetPrivileges%" %* | |
exit /B | |
:gotPrivileges | |
setlocal & cd /d %~dp0 | |
if '%1'=='ELEV' (del "%vbsGetPrivileges%" 1>nul 2>nul & shift /1) | |
:::::::::::::::::::::::::::: | |
::START | |
:::::::::::::::::::::::::::: | |
REM Run shell as admin (example) - put here code as you like | |
REM BEGIN INSTALLER | |
git >nul 2>nul | |
if errorlevel 9009 ( | |
echo Installing git | |
powershell -Command "[Net.ServicePointManager]::SecurityProtocol = \"tls12, tls11, tls\";Invoke-WebRequest http://github.com/git-for-windows/git/releases/download/v2.23.0.windows.1/Git-2.23.0-64-bit.exe -OutFile Git-installer.exe" | |
Git-installer.exe /silent | |
) | |
dir C:\ti\ccs920\ccs\eclipse\ccstudio.exe >nul 2>nul | |
if errorlevel 1 ( | |
echo Installing Code Composer Studio | |
powershell -Command "[Net.ServicePointManager]::SecurityProtocol = \"tls12, tls11, tls\";Invoke-WebRequest https://software-dl.ti.com/ccs/esd/CCSv9/CCS_9_2_0/exports/ccs_setup_9.2.0.00013.exe -OutFile CCS-install.exe" | |
CCS-install.exe --unattendedmodeui minimal --mode unattended | |
) | |
halcogen >nul 2>nul | |
if errorlevel 9009 ( | |
echo Installing HALCoGen | |
powershell -Command "[Net.ServicePointManager]::SecurityProtocol = \"tls12, tls11, tls\";Invoke-WebRequest http://www.ti.com/lit/sw/spnc030g/spnc030g.zip -OutFile halcogen.zip" | |
rem unzip (from https://stackoverflow.com/a/47288813) | |
powershell.exe -nologo -noprofile -command "& { $shell = New-Object -COM Shell.Application; $target = $shell.NameSpace('%CD%'); $zip = $shell.NameSpace('%CD%\halcogen.zip'); $target.CopyHere($zip.Items(), 16); }" | |
HALCoGen-04.07.01-installer.exe --unattendedmodeui minimal --mode unattended | |
) | |
mkdir %HOMEPATH%\workspace_v9_2 | |
git clone https://github.com/AlbertaSat/ex2_on_board_computer %HOMEPATH%\workspace_v9_2\ex2_on_board_computer | |
echo Install done. | |
pause |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment