UAC Prompt for Jars

bignose956

Well-Known Member
#1
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
#2
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
#3
Running it from powershell would simply be

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


bignose956

Well-Known Member
#4
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
 


Neemobeer

Windows Forum Team
Staff member
#5
Had a typo -ArugmentList
 


bignose956

Well-Known Member
#6
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
#7
Single quote the path
"-jar 'C:\Users\Firstname Lastname\Desktop\Java Program.jar'"
 


This website is not affiliated, owned, or endorsed by Microsoft Corporation. It is a member of the Microsoft Partner Program.
Top