Windows 7 UAC Prompt for Jars

Cardinal System

Honorable Member
Joined
Jan 24, 2016
Messages
87
Is it possible to show a UAC prompt for a Java jar file? I am aware that one can edit an executable's manifest to require an elevated process, but there seems to be no way to do so with a Jar file. I do not want to edit javaw.exe's manifest.

Is there a specific file that that can take file path arguments to show a UAC prompt? Or do I have to learn powershell? Or is there a better solution?
 


Can't do it with straight up java. You'll either want to use a script (powershell or vb script) or create a wrapper executable with a manifest requiring elevation.
 


Running it from powershell would simply be

Start-Process -FilePath "C:\path\to\java.exe" -ArguementList "-jar path\to\file.jar" -Verb "RunAs"
 


Running it from powershell would simply be

Start-Process -FilePath "C:\path\to\java.exe" -ArguementList "-jar path\to\file.jar" -Verb "RunAs"
I've never used powershell, so I'm not sure how to resolve this error:
Capture.webp
 


Had a typo -ArugmentList
Ohhh! I see it now. One more problem. The path to said Jar has spaces in it, thus it is getting split in half as separate arguments. How should I change it?
Code:
"-jar C:\Users\Firstname Lastname\Desktop\Java Program.jar"
                        ^                     ^
 


Single quote the path
"-jar 'C:\Users\Firstname Lastname\Desktop\Java Program.jar'"
 


Solution
Back
Top