@ECHO OFF
ECHO ************************
ECHO.
ECHO Behold the power of
ECHO.
ECHO \\  //    //=\\     // \\
ECHO  \\//    //   \\   //   \\
ECHO  //\\   //    //  //=====\\
ECHO //  \\ //====//  //       \\
ECHO.
ECHO Anything is possible.
ECHO Stericson
ECHO.
ECHO ************************
:input1
set OS==any
GOTO whattodo
ECHO *****************************************
ECHO ERROR! Try entering something this time!
ECHO *****************************************
GOTO %CHOICE%

:input2
ECHO.
ECHO.
ECHO *****************************************
ECHO ERROR! That was not a valid choice!
ECHO *****************************************
GOTO %CHOICE%




:whattodo
set CHOICE=whattodo
ECHO.
ECHO **************
ECHO Your choices:
ECHO **************
ECHO.
ECHO (1) Set PATH variable for SDK
ECHO (2) set CLASSPATH variable for signingtool
ECHO (3) Install registry entries
ECHO (4) Sign files manually
ECHO (5) Pull Files from phone
ECHO (6) Push files from phone
ECHO (7) Exit
ECHO.
set INPUT=
set /P INPUT=Type choice number: %=%
if "%INPUT%"=="1" goto %OS%1
if "%INPUT%"=="2" Goto %OS%2
if "%INPUT%"=="3" Goto %OS%3
if "%INPUT%"=="4" Goto %OS%4
if "%INPUT%"=="5" Goto %OS%5
if "%INPUT%"=="6" Goto %OS%6
if "%INPUT%"=="7" Goto yesend
if "%INPUT%"=="" goto input1
if not "%INPUT%"=="somestupidvaluethatnoonewilleverguessunlesstheylookinhereandtrytotypethisallout" GOTO input2






:ANY1
ECHO.
ECHO **************************
ECHO System setup, please wait...
ECHO **************************
:ANYchoice1
if not "%PATH%"=="" goto not-foundANY1
set FOUND=true
ECHO.
ECHO Currently PATH is empty! 
ECHO.
ECHO PATH will now be created!
ECHO.
ECHO %CD% will now be added to PATH
ECHO.
ECHO New PATH will be:
ECHO.
ECHO %CD%
ECHO.
GOTO acceptableANY1
:not-foundANY1
set FOUND=
ECHO.
ECHO Currently PATH is set to: 
ECHO.
ECHO %PATH%
ECHO.
ECHO %CD% will now be added to PATH
ECHO.
ECHO New PATH will be:
ECHO.
ECHO %PATH%;.;%CD%
ECHO.
:acceptableANY1
ECHO Is this acceptable? yes/no?
ECHO.


set CHOICE=ANYchoice1
set INPUT=
set /P INPUT=Type input: %=%
if "%INPUT%"=="yes" GOTO yesANY1
if "%INPUT%"=="no" GOTO noANY1
if "%INPUT%"=="" goto input1
if not "%INPUT%"=="somestupidvaluethatnoonewilleverguessunlesstheylookinhereandtrytotypethisallout" GOTO input2
ECHO.



:yesANY1
if "%found%"=="true" GOTO noaddANY1
ECHO.
ECHO ************************************
ECHO Creating PATH system variable!
ECHO ************************************
ECHO.
setx path "%PATH%;.;%CD%"
set path=%PATH%;.;%CD%
ECHO.
ECHO Path created, operation successful!
ECHO.
ECHO Path is:
ECHO.
ECHO %PATH%
Goto end
:noANY1
echo done no
GOTO end

GOTO end
:noaddANY1
ECHO.
ECHO ************************************
ECHO Creating PATH system variable!
ECHO ************************************
ECHO.
setx path "%CD%"
set path=%CD%
ECHO.
ECHO Path created, operation successful!
ECHO.
ECHO Path is:
ECHO.
ECHO %CLASSPATH%
Goto end
:noANY1
GOTO end

:ANY2
ECHO.
ECHO **************************
ECHO System setup, please wait...
ECHO **************************
:ANYchoice2
if not "%CLASSPATH%"=="" goto not-foundANY2
set FOUND=true
ECHO.
ECHO Currently CLASSPATH is empty! 
ECHO.
ECHO CLASSPATH will now be created!
ECHO.
ECHO %CD% will now be added to CLASSPATH
ECHO.
ECHO New CLASSPATH will be:
ECHO.
ECHO %CD%\testsign.jar
ECHO.
GOTO acceptableANY2
:not-foundANY2
set FOUND=
ECHO.
ECHO Currently CLASSPATH is set to: 
ECHO.
ECHO %CLASSPATH%
ECHO.
ECHO %CD% will now be added to CLASSPATH
ECHO.
ECHO New CLASSPATH will be:
ECHO.
ECHO %CLASSPATH%;.;%CD%\testsign.jar
ECHO.
:acceptableANY2
ECHO Is this acceptable? yes/no?
ECHO.


set CHOICE=ANYchoice2
set INPUT=
set /P INPUT=Type input: %=%
if "%INPUT%"=="yes" GOTO yesANY2
if "%INPUT%"=="no" GOTO noANY2
if "%INPUT%"=="" goto input1
if not "%INPUT%"=="somestupidvaluethatnoonewilleverguessunlesstheylookinhereandtrytotypethisallout" GOTO input2
ECHO.



:yesANY2
if "%found%"=="true" GOTO noaddANY2
ECHO.
ECHO ************************************
ECHO Creating CLASSPATH system variable!
ECHO ************************************
if exist testsign.jar goto existsANY2-1
ECHO.
ECHO *******
ECHO ERROR!
ECHO *******
ECHO.
ECHO testsign.jar cannot be found!
ECHO.
ECHO Please make sure it is in:
ECHO.
ECHO %CD%
ECHO.
ECHO *******
ECHO ERROR!
ECHO *******
ECHO.
goto end
:existsANY2-1
ECHO.
setx Classpath "%CLASSPATH%;.;%CD%\testsign.jar"
set Classpath=%CLASSPATH%;.;%CD%\testsign.jar
ECHO.
ECHO Classpath created, operation successful!
ECHO.
ECHO Classpath is:
ECHO.
ECHO %CLASSPATH%
Goto end
:noANY2
echo done no
GOTO end

GOTO end
:noaddANY2
ECHO.
ECHO ************************************
ECHO Creating CLASSPATH system variable!
ECHO ************************************
ECHO.
if exist testsign.jar goto existsANY2
ECHO.
ECHO *******
ECHO ERROR!
ECHO *******
ECHO.
ECHO testsign.jar cannot be found!
ECHO.
ECHO Please make sure it is in:
ECHO.
ECHO %CD%
ECHO.
ECHO *******
ECHO ERROR!
ECHO *******
ECHO.
goto end
:existsANY2
setx Classpath "%CD%\testsign.jar"
set Classpath=%CD%\testsign.jar
ECHO.
ECHO Classpath created, operation successful!
ECHO.
ECHO Classpath is:
ECHO.
ECHO %CLASSPATH%
Goto end
:noANY2
GOTO end


:ANY3
ECHO.
ECHO **************************
ECHO System setup, please wait...
ECHO **************************
:ANYchoice3
if exist testsign_apk.reg goto existsANY3
ECHO.
ECHO *******
ECHO ERROR!
ECHO *******
ECHO.
ECHO testsign_apk.reg cannot be found!
ECHO.
ECHO Please make sure it is in:
ECHO.
ECHO %CD%
ECHO.
ECHO *******
ECHO ERROR!
ECHO *******
ECHO.
goto end
:existsANY3
ECHO.
ECHO **************************************
ECHO Doing this will make it so that any
ECHO double click on any APK or ZIP
ECHO will resign that file!
ECHO Don't do this if you don't want that!
ECHO **************************************
ECHO.
ECHO Registry values from testsign_apk.reg will be added to your registry!
ECHO.
ECHO Do you want to proceed? yes/no?
ECHO.


set CHOICE=ANYchoice3
set INPUT=
set /P INPUT=Type input: %=%
if "%INPUT%"=="yes" GOTO yesANY3
if "%INPUT%"=="no" GOTO noANY3
if "%INPUT%"=="" goto input1
if not "%INPUT%"=="somestupidvaluethatnoonewilleverguessunlesstheylookinhereandtrytotypethisallout" GOTO input2
ECHO.



:yesANY3
ECHO.
ECHO ************************
ECHO Adding Registry values!
ECHO ************************
ECHO.
reg.exe import testsign_apk.reg
ECHO.
ECHO Registry values added, operation successful if you recieved a confirmation above.
ECHO now you can right click on any zip or apk and resign it with ease!
ECHO The resigning option will overwrite the old file with the new, resigned one.
ECHO.
Goto end
:noANY2
echo done no
GOTO end

:noANY3
GOTO end


:ANY4
ECHO.
ECHO **************************
ECHO System setup, please wait...
ECHO **************************
Echo.
:ANYchoice4-1
ECHO Please type the full path of the file.
set CHOICE=ANYchoice4-1
set filetosign=
set /P filetosign=Path?: %=%
if "%filetosign%"=="" goto input1
:ANYchoice4
if exist %filetosign% goto existsANY4
ECHO.
ECHO *******
ECHO ERROR!
ECHO *******
ECHO.
ECHO %filetosign% cannot be found!
ECHO.
ECHO Please make sure you typed the correct, full path to the file!
ECHO.
ECHO *******
ECHO ERROR!
ECHO *******
ECHO.
goto %CHOICE%
:existsANY4
ECHO.
ECHO %filetosign% will be resigned!
ECHO.
ECHO Do you want to proceed? yes/no?
ECHO.


set CHOICE=ANYchoice4
set INPUT=
set /P INPUT=Type input: %=%
if "%INPUT%"=="yes" GOTO yesANY4
if "%INPUT%"=="no" GOTO end
if "%INPUT%"=="" goto input1
if not "%INPUT%"=="somestupidvaluethatnoonewilleverguessunlesstheylookinhereandtrytotypethisallout" GOTO input2

ECHO.

:yesANY4
ECHO.
ECHO **************
ECHO Signing File!
ECHO **************
ECHO.
java testsign %filetosign%
ECHO.
ECHO File signed successfully if no Errors above.
ECHO.
Goto end

:ANY5
ECHO.
ECHO **************************
ECHO File pull(s) from phone...
ECHO **************************
Echo.
ECHO. 
ECHO Is you phone in recovery mode?
ECHO.
:ANYchoice5-1
set CHOICE=ANYchoice5-1
set INPUT=
set /P INPUT=Type input: %=%
if "%INPUT%"=="yes" GOTO yesANY5
if "%INPUT%"=="no" GOTO noANY5
if "%INPUT%"=="" goto input1
if not "%INPUT%"=="somestupidvaluethatnoonewilleverguessunlesstheylookinhereandtrytotypethisallout" GOTO input2
:yesANY5
ECHO.
ECHO *****************************************
ECHO Mounting system, data, and SDcard
ECHO *****************************************
Echo.
adb shell mount /system
adb shell mount /sdcard
adb shell mount /data
ECHO.
ECHO Mount completed successfully if no errors listed above.
ECHO.
ECHO.
ECHO Do you want to proceed? yes/no?
ECHO.
:ANYchoice5-1-1
set CHOICE=ANYchoice5-1-1
set INPUT=
set /P INPUT=Type input: %=%
if "%INPUT%"=="yes" GOTO noANY5
if "%INPUT%"=="no" GOTO end
if "%INPUT%"=="" goto input1
if not "%INPUT%"=="somestupidvaluethatnoonewilleverguessunlesstheylookinhereandtrytotypethisallout" GOTO input2

:noANY5
ECHO.
ECHO ************************
ECHO Path to store pulled file...
ECHO ************************
Echo.
:ANYchoice5-2
ECHO Please type the full path of where we will store the pulled file.
set CHOICE=ANYchoice5-2
set placetostore=
set /P placetostore=Path?: %=%
if "%placetostore%"=="" goto input1
if exist %placetostore%\nul goto existsANY5
ECHO.
ECHO *******
ECHO ERROR!
ECHO *******
ECHO.
ECHO %placetostore% cannot be found!
ECHO.
ECHO Please make sure you typed a valid path to store the file!
ECHO.
ECHO *******
ECHO ERROR!
ECHO *******
ECHO.
goto %CHOICE%
:existsANY5
ECHO.
ECHO Pulled file will be stored in %placetostore%
ECHO.
ECHO.
ECHO Is this correct? yes/no?
ECHO.
:ANYchoice5-1-1
set CHOICE=ANYchoice5-1-1
set INPUT=
set /P INPUT=Type input: %=%
if "%INPUT%"=="yes" GOTO ANY5pull
if "%INPUT%"=="no" GOTO noANY5
if "%INPUT%"=="" goto input1
if not "%INPUT%"=="somestupidvaluethatnoonewilleverguessunlesstheylookinhereandtrytotypethisallout" GOTO input2

:ANY5pull
ECHO.
ECHO ************************
ECHO Path to file to be pulled...
ECHO ************************
ECHO.
:ANYchoicepull-1
ECHO Please type the full path of where the filed to be pulled is located on your phone
set CHOICE=ANYchoicepull-1
set pullwhat=
set /P pullwhat=Path?: %=%
ECHO.
ECHO Pulled file is located at %pullwhat%
ECHO.
ECHO.
ECHO Is this correct? yes/no?
ECHO.
:ANYchoicepull-1-1
set CHOICE=ANYchoicepull-1-1
set INPUT=
set /P INPUT=Type input: %=%
if "%INPUT%"=="yes" GOTO ANY5pull-pull
if "%INPUT%"=="no" GOTO ANYchoicepull-1
if "%INPUT%"=="" goto input1
if not "%INPUT%"=="somestupidvaluethatnoonewilleverguessunlesstheylookinhereandtrytotypethisallout" GOTO input2

:ANY5pull-pull
ECHO.
ECHO ************************
ECHO Pulling file!
ECHO ************************
Echo.
adb pull %pullwhat% %placetostore%
ECHO adb pull %pullwhat% %placetostore%
ECHO.
ECHO ************************
ECHO File pulling finished!
ECHO Please check for accuracy!
ECHO Please check for any errors!
ECHO ************************
Echo.
GOTO end

:ANY6
ECHO.
ECHO **************************
ECHO File push to phone.....
ECHO **************************
Echo.
ECHO. 
ECHO Is you phone in recovery mode?
ECHO.
:ANYchoice6-1
set CHOICE=ANYchoice6-1
set INPUT=
set /P INPUT=Type input: %=%
if "%INPUT%"=="yes" GOTO yesANY6
if "%INPUT%"=="no" GOTO noANY6
if "%INPUT%"=="" goto input1
if not "%INPUT%"=="somestupidvaluethatnoonewilleverguessunlesstheylookinhereandtrytotypethisallout" GOTO input2
:yesANY6
ECHO.
ECHO *****************************************
ECHO Mounting system, data, and SDcard
ECHO *****************************************
Echo.
adb shell mount /system
adb shell mount /sdcard
adb shell mount /data
ECHO.
ECHO Mount completed successfully if no errors listed above.
ECHO.
ECHO.
ECHO Do you want to proceed? yes/no?
ECHO.
:ANYchoice6-1-1
set CHOICE=ANYchoice6-1-1
set INPUT=
set /P INPUT=Type input: %=%
if "%INPUT%"=="yes" GOTO ANYready
if "%INPUT%"=="no" GOTO end
if "%INPUT%"=="" goto input1
if not "%INPUT%"=="somestupidvaluethatnoonewilleverguessunlesstheylookinhereandtrytotypethisallout" GOTO input2

:noANY6
ECHO.
ECHO ************************
ECHO Phone must be in Recovery
ECHO when pushing files!
ECHO The Phone will now boot 
ECHO into Recovery!
ECHO ************************
Echo.
adb shell reboot recovery
ECHO.
ECHO.
ECHO ************************
ECHO Please allow time for
ECHO phone to reboot into
ECHO recovery mode before 
ECHO continuing on!
ECHO ************************
ECHO.
ECHO Press any key when phone is in recovery mode!
pause > nul
:retrymount
ECHO *****************************************
ECHO Mounting system, data, and SDcard
ECHO *****************************************
ECHO.
adb shell mount /system
adb shell mount /sdcard
adb shell mount /data
ECHO.
ECHO Mount completed successfully if no errors listed above.
ECHO.
ECHO.
ECHO Do we need to retry mounting? Were there any errors? yes/no?
ECHO.
:ANYchoice6-1-1-1
set CHOICE=ANYchoice6-1-1-1
set INPUT=
set /P INPUT=Type input: %=%
if "%INPUT%"=="yes" GOTO retrymount
if "%INPUT%"=="no" GOTO ANYready
if "%INPUT%"=="" goto input1
if not "%INPUT%"=="somestupidvaluethatnoonewilleverguessunlesstheylookinhereandtrytotypethisallout" GOTO input2
:ANYready
ECHO.
ECHO ************************
ECHO Path to push file...
ECHO ************************
Echo.
:ANYchoice6-2
ECHO Please type the full path of where we will push the file.
set CHOICE=ANYchoice6-2
set placetopush=
set /P placetopush=Path?: %=%
if "%placetopush%"=="" goto input1
:existsANY6
ECHO.
ECHO File will be pushed to %placetopush%
ECHO.
ECHO.
ECHO Is this correct? yes/no?
ECHO.
:ANYchoice6-1-1
set CHOICE=ANYchoice6-1-1
set INPUT=
set /P INPUT=Type input: %=%
if "%INPUT%"=="yes" GOTO ANY6push
if "%INPUT%"=="no" GOTO ANYready
if "%INPUT%"=="" goto input1
if not "%INPUT%"=="somestupidvaluethatnoonewilleverguessunlesstheylookinhereandtrytotypethisallout" GOTO input2

:ANY6push
ECHO.
ECHO ************************
ECHO Path to file to be pushed...
ECHO ************************
ECHO.
:ANYchoicepush-1
ECHO Please type the full path of where the file to be pushed is located on your computer
set CHOICE=ANYchoicepush-1
set placetostore=
set /P whattopush=Path?: %=%
if "%whattopush%"=="" goto input1
if exist %whattopush% goto ANY6push-push
ECHO.
ECHO *******
ECHO ERROR!
ECHO *******
ECHO.
ECHO %whattopush% cannot be found!
ECHO.
ECHO Please make sure you typed a valid path to the file to be pushed!
ECHO.
ECHO *******
ECHO ERROR!
ECHO *******
ECHO.
goto %CHOICE%
:ANY6push-push
ECHO.
ECHO ************************
ECHO Pushing file!
ECHO ************************
Echo.
adb push %whattopush% %placetopush%
ECHO adb push %whattopush% %placetopush%
ECHO.
ECHO ************************
ECHO File pushing finished!
ECHO Please check for accuracy!
ECHO Please check for any errors!
ECHO ************************
Echo.
GOTO end


:end
GOTO whattodo

:yesend