Skip to content

Instantly share code, notes, and snippets.

@4rzael
Last active May 24, 2018 12:00
Show Gist options
  • Save 4rzael/b65ba5880ff7d0c1106d8b3dc9d719ca to your computer and use it in GitHub Desktop.
Save 4rzael/b65ba5880ff7d0c1106d8b3dc9d719ca to your computer and use it in GitHub Desktop.
An installer for crazyflie-osc on windows
@ECHO OFF
REM ----[ This code block detects if the script is being running with admin PRIVILEGES If it isn't it pauses and then quits]-------
NET SESSION >nul 2>&1
IF %ERRORLEVEL% EQU 0 (
ECHO.
) ELSE (
ECHO 
ECHO ######## ######## ######## ####### ########
ECHO ## ## ## ## ## ## ## ## ##
ECHO ## ## ## ## ## ## ## ## ##
ECHO ###### ######## ######## ## ## ########
ECHO ## ## ## ## ## ## ## ## ##
ECHO ## ## ## ## ## ## ## ## ##
ECHO ######## ## ## ## ## ####### ## ##
ECHO.
ECHO.
ECHO ####### ERROR: ADMINISTRATOR PRIVILEGES REQUIRED #########
ECHO This script must be run as administrator to work properly!
ECHO If you're seeing this after running this script, then right click on the shortcut and select "Run As Administrator".
ECHO ##########################################################
ECHO.
ECHO 
PAUSE
EXIT /B 1
)
:: Install chocolatey
:choco_begin
set /p choco="Install chocolatey ? (y - Yes, n - No): "
IF /i "%choco%" == "y" GOTO choco_install
IF /i "%choco%" == "n" GOTO choco_end
ECHO Invalid option
GOTO choco_begin
:choco_install
powershell -NoProfile -ExecutionPolicy Bypass -Command "iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))" && SET PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin
ECHO CHOCOLATEY INSTALLED
:choco_end
:: Install python and pip
:python_begin
set /p python="Install python ? (y - Yes, n - No): "
IF /i "%python%" == "y" GOTO python_install
IF /i "%python%" == "n" GOTO python_end
ECHO Invalid option
GOTO python_begin
:python_install
choco install python -y
ECHO PYTHON INSTALLED
SET PATH=%PATH%;C:\tools\python\Scripts\
ECHO PIP INSTALLED
:python_end
:: Install virtualenv
:virtualenv_begin
set /p virtualenv="Install virtualenv ? (y - Yes, n - No): "
IF /i "%virtualenv%" == "y" GOTO virtualenv_install
IF /i "%virtualenv%" == "n" GOTO virtualenv_end
ECHO Invalid option
GOTO virtualenv_begin
:virtualenv_install
pip install virtualenv
ECHO VIRTUALENV INSTALLED
:virtualenv_end
:: Install git
:git_begin
set /p git="Install git ? (y - Yes, n - No): "
IF /i "%git%" == "y" GOTO git_install
IF /i "%git%" == "n" GOTO git_end
ECHO Invalid option
GOTO git_begin
:git_install
choco install git.install -params '"/GitOnlyOnPath"' -y
ECHO GIT INSTALLED
:git_end
:: Install project
:project_begin
set /p project="Install crazyflie-osc ? (y - Yes, n - No): "
IF /i "%project%" == "y" GOTO project_install
IF /i "%project%" == "n" GOTO project_end
ECHO Invalid option
GOTO project_begin
:project_install
set /p install_folder="Where should it be installed ? (default : Documents): "
IF /i "%install_folder%" == "" GOTO project_set_folder
GOTO project_set_folder_end
:project_set_folder
for /f "tokens=3* delims= " %%a in ('reg query "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" /v "Personal"') do (set mydocuments=%%~a)
set install_folder="%mydocuments%"
:project_set_folder_end
ECHO Install folder is %install_folder%
PAUSE
cd %install_folder%
git clone https://github.com/4rzael/crazyflie-osc
cd crazyflie-osc
virtualenv venv
venv\Scripts\activate
pip install -r requirements.txt
ECHO PROJECT INSTALLED
:project_end
:: Install zagid (crazyradio driver)
:zadig_begin
set /p zadig="Install zadig (crazyradio driver) ? (y - Yes, n - No): "
IF /i "%zadig%" == "y" GOTO zadig_install
IF /i "%zadig%" == "n" GOTO zadig_end
ECHO Invalid option
GOTO zadig_begin
:zadig_install
choco install zadig -y
ECHO ZADIG INSTALLED
ECHO Now follow the procedure here to install the crazyradio drivers (zadig is already installed, though): https://wiki.bitcraze.io/doc:crazyradio:install_windows_zadig 
:zadig_end
ECHO DONE !
PAUSE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment