To make it easy for others to run the JAR installer without having to make changes to all their computers, you'll probably want to wrap it with a batch script that elevates and runs the JAR file. You can do this easily with the Elevation PowerToys from Microsoft. They include a useful utility that lets you launch anything as administrator by simply prefixing it with the
Once you've downloaded them, extract them to a folder and copy the
elevate.vbs to the folder with the JAR file. Then, write a new batch script with a
.cmd extension with the following contents:
elevate cmd /c start "%CD%\installer.jar"
That will launch the JAR file with the default handler for such files on their system (using the
start command of
%CD% points to the current working directory of the script, and is necessary because the elevated command line will start in
If, for some reason Java is not properly configured as the default handler for JAR files, that would fail though. If you can count on Java being in the same place on all systems, you could instead do it this way:
elevate "c:\Program Files\Java\jre\bin\java.exe" -jar "%CD%\installer.jar"
Once you've done either of those, just run the batch file and Windows will prompt for administrator elevation and launch the installer.
Include the elevation scripts, your script, and the installer files in a self-extracting archive that launches the script and you can wrap it up in one nice little
.exe file. (7-Zip is a great open-source tool for creating such archives.)
For more information on the Elevation PowerToys, consult the linked article or the README file included with the download.