UAC Prompt for Jars

bignose956

Senior Member
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?
 

Neemobeer

Windows Forum Team
Staff member
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.
 

Neemobeer

Windows Forum Team
Staff member
Running it from powershell would simply be

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

bignose956

Senior Member
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.PNG
 

bignose956

Senior Member
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"
                        ^                     ^
 

Neemobeer

Windows Forum Team
Staff member
Single quote the path
"-jar 'C:\Users\Firstname Lastname\Desktop\Java Program.jar'"
 
Top