Last active
October 13, 2015 05:18
-
-
Save djangofan/4144970 to your computer and use it in GitHub Desktop.
Batch file to associate .jar files as self-executing.
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 | |
SETLOCAL ENABLEDELAYEDEXPANSION | |
:: this .bat script creates a file association for executable .jar files | |
:: so that you can double click them to run | |
ECHO Creating .jar file association... | |
ECHO JAVA_HOME is %JAVA_HOME% | |
IF NOT DEFINED JAVA_HOME GOTO :FAIL | |
REG ADD "HKCR\jarfile" /ve /t REG_SZ /d "Executable Jar File" /f | |
REG ADD "HKCR\jarfile\shell" /ve /f | |
REG ADD "HKCR\jarfile\shell\open" /ve /f | |
ECHO REG ADD "HKCR\jarfile\shell\open\command" /ve /t REG_SZ /d "\"%JAVA_HOME%\bin\javaw.exe\" -jar \"%%1\" %%*" /f | |
REG ADD "HKCR\jarfile\shell\open\command" /ve /t REG_SZ /d "\"%JAVA_HOME%\bin\javaw.exe\" -jar \"%%1\" %%**" /f | |
REG ADD "HKLM\jarfile" /ve /t REG_SZ /d "Executable Jar File" /f | |
REG ADD "HKLM\SOFTWARE\Classes\jarfile\shell" /ve /f | |
REG ADD "HKLM\SOFTWARE\Classes\jarfile\shell\open" /ve /f | |
REG ADD "HKLM\SOFTWARE\Classes\jarfile\shell\open\command" /ve /t REG_SZ /d "\"%JAVA_HOME%\bin\javaw.exe\" -jar \"%%1\" %%*" /f | |
ECHO Finished creating .jar file association for executable .jar files. | |
PAUSE | |
GOTO EOF | |
:FAIL | |
ECHO Script failed. JAVA_HOME not defined. | |
PAUSE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment