Created
April 23, 2015 11:49
-
-
Save jhenly/4e4facb3c267ddbc3bad to your computer and use it in GitHub Desktop.
Windows batch script to check three directories for Eclipse and launch it with my workspace, if it exists.
This file contains hidden or 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 | |
| :: Windows batch program to check three directories for Eclipse | |
| :: and launch it with my workspace, if it exists. | |
| SETLOCAL ENABLEEXTENSIONS | |
| SET me=%~n0 | |
| SET parent=%~dp0 | |
| SET deskEclipse="C:\Users\Public\Desktop\Eclipse\eclipse-java-luna\eclipse" | |
| SET progEclipse="%ProgramFiles:"=%\Eclipse\eclipse-java-luna\eclipse" | |
| SET remEclipse="%parent%Eclipse" | |
| SET workspace="%parent%workspace" | |
| ::-------------------------------------------------------- | |
| ::-- BEG Main Program Flow | |
| ::-------------------------------------------------------- | |
| CD /D C: | |
| IF EXIST "%deskEclipse:"=%" ( | |
| CALL :cdDirectory "%deskEclipse:"=%" | |
| GOTO :EOF | |
| ) | |
| ECHO [%me%] | |
| ECHO Folder: %deskEclipse:"=% | |
| ECHO Status: Not Found | |
| IF EXIST "%progEclipse:"=%" ( | |
| CALL :cdDirectory "%progEclipse:"=%" | |
| GOTO :EOF | |
| ) | |
| ECHO [%me%] | |
| ECHO Folder: %progEclipse:"=% | |
| ECHO Status: Not Found | |
| GOTO :remote | |
| GOTO :EOF | |
| ::-------------------------------------------------------- | |
| ::-- END Main Program Flow | |
| ::-------------------------------------------------------- | |
| ::-------------------------------------------------------- | |
| ::-- BEG Function Section | |
| ::-------------------------------------------------------- | |
| :cdDirectory | |
| ECHO [%me%] | |
| ECHO %~1 | |
| ECHO Status: Found | |
| CD "%~1" | |
| GOTO :RUN | |
| :remote | |
| ECHO [%me%] | |
| ECHO Status: All Attempts Failed | |
| ECHO Using: %remEclipse:"=% | |
| cd /D H: > NUL 2>&1 || GOTO :hNotSet | |
| cd "%remEclipse:"=%" || GOTO :noRemoteEclipse | |
| GOTO :RUN | |
| ::-------------------------------------------------------- | |
| ::-- END Function Section | |
| ::-------------------------------------------------------- | |
| ::-------------------------------------------------------- | |
| ::-- BEG RUN Function | |
| ::-------------------------------------------------------- | |
| :RUN | |
| ECHO [%me%] | |
| ECHO Status: Launching Eclipse | |
| IF NOT EXIST "%workspace:"=%" ( | |
| ECHO [%me%] | |
| ECHO Folder: %workspace:"=% | |
| ECHO Status: Not Found | |
| START "" "eclipse.exe" | |
| ) ELSE ( START "" "eclipse.exe" -data "%workspace:"=%") | |
| PAUSE | |
| GOTO :EOF | |
| ::-------------------------------------------------------- | |
| ::-- END RUN Function | |
| ::-------------------------------------------------------- | |
| ::-------------------------------------------------------- | |
| ::-- BEG Volatile Function Section | |
| ::-------------------------------------------------------- | |
| :hNotSet | |
| ECHO [%me%] | |
| ECHO Status: H:\\ Is Not Set, Exiting | |
| PAUSE | |
| GOTO :EOF | |
| :noRemoteEclipse | |
| ECHO [%me%] | |
| ECHO Folder: %parent:"=%Eclipse | |
| ECHO Status: Not Found, Exiting | |
| PAUSE | |
| GOTO :EOF | |
| ::-------------------------------------------------------- | |
| ::-- END Volatile Function Section | |
| ::-------------------------------------------------------- |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment