Created
August 1, 2020 22:41
-
-
Save LesterLian/7f43f6c784216b4d134a3e7712432bc2 to your computer and use it in GitHub Desktop.
Run jupyter lab within Anaconda when open .ipynb file.
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
@echo off | |
@REM To associate extension with file type | |
@REM assoc [<.ext>[=[<filetype>]]] | |
@REM To set open command for file type | |
@REM ftype [<filetype>[=[<opencommandstring>]]] | |
@REM To set up Anaconda environment. Replace PATH at the end. | |
@REM cmd.exe "/K" PATH:to\Anaconda3\Scripts\activate.bat PATH:to\env | |
@REM Get admin | |
@REM Check for permissions | |
if "%PROCESSOR_ARCHITECTURE%" EQU "amd64" ( | |
>nul 2>&1 "%SYSTEMROOT%\SysWOW64\cacls.exe" "%SYSTEMROOT%\SysWOW64\config\system" | |
) else ( | |
>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system" | |
) | |
@REM If error flag set, we do not have admin. | |
if '%errorlevel%' neq '0' ( | |
echo Requesting administrative privileges... | |
goto UACPrompt | |
) else ( | |
goto gotAdmin | |
) | |
:UACPrompt | |
echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs" | |
set params= %* | |
echo UAC.ShellExecute "cmd.exe", "/c ""%~s0"" %params:"=""%", "", "runas", 1 >> "%temp%\getadmin.vbs" | |
"%temp%\getadmin.vbs" | |
del "%temp%\getadmin.vbs" | |
exit /B | |
:gotAdmin | |
pushd "%CD%" | |
CD /D "%~dp0" | |
@REM Get admin end | |
assoc .ipynb=jupyter | |
ftype jupyter=cmd.exe /k "PATH:to\Anaconda3\Scripts\activate.bat PATH:to\env& jupyter lab" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment