I am installing Android Studio and I have by default the path C:\\Users\\Administrator\\AppData\\Local\\Android\\sdk to set my SDK. If
I use junction.exe from Sysinternals to make my Java/Android Studio fully "portable" in Windows:
PS: When I update java or upgrade Android I have to remeber to tweak the bat with the new revision numbers
Content of __init__.bat:
@echo off
@SET mySrcPath=%cd%
@rem echo "%myPath%"
@rem JAVA_HOME = D:\work\Android\Java\jdk1.8.0_77_x64\
@SET myJavaTarget=Java\jdk1.8.0_77_x64\
@SET myJavaPath=%mySrcPath%\%myJavaTarget%
@if not exist "%myJavaPath%" (
@echo CANNOT FIND myJavaPath = "%myJavaPath%"
@goto _exit_
)
@rem echo myJavaPath = "%myJavaPath%"
@setx JAVA_HOME %myJavaPath%
@SET myTargetPath=%USERPROFILE%
@SET myCopy1=.android
@SET myCopy2=.AndroidStudio2.2
@SET myCopy3=.gradle
@SET mySource1="%mySrcPath%\%myCopy1%"
@SET mySource2="%mySrcPath%\%myCopy2%"
@SET mySource3="%mySrcPath%\%myCopy3%"
@SET myTarget1="%myTargetPath%\%myCopy1%"
@SET myTarget2="%myTargetPath%\%myCopy2%"
@SET myTarget3="%myTargetPath%\%myCopy3%"
@rem echo.
@if not exist %mySource1% (
@echo CANNOT FIND mySource1 = %mySource1%
@goto _exit_
)
@if not exist %mySource2% (
@echo CANNOT FIND mySource2 = %mySource2%
@goto _exit_
)
@if not exist %mySource3% (
@echo CANNOT FIND mySource3 = %mySource3%
@goto _exit_
)
@if not exist %myTarget1% (
@echo creating myTarget1 = %myTarget1% from mySource1 = %mySource1%
@junction.exe %myTarget1% %mySource1%
) else (
@echo myTarget1 = %myTarget1% ALREADY EXISTS !!!!!!
)
@if not exist %myTarget2% (
@echo creating myTarget2 = %myTarget2% from mySource2 = %mySource2%
@junction.exe %myTarget2% %mySource2%
) else (
@echo myTarget2 = %myTarget2% ALREADY EXISTS !!!!!!
)
@if not exist %myTarget3% (
@echo creating myTarget3 = %myTarget3% from mySource3 = %mySource3%
@junction.exe %myTarget3% %mySource3%
) else (
@echo myTarget3 = %myTarget3% ALREADY EXISTS !!!!!!
)
:_exit_
@echo exiting...
@pause