0

I have developed some classes to auto-update my program. The main program (program.jar) will check for updates, then download the new files, and prepare the list of what should be replaced, created or deleted.

I have another jar (updater.jar) that will take care of replacing the files. The issue is that the program is installed into Program Files and thus this second jar needs to have administration rights in order to move the files.

I don't want my main program to need administration rights. I just need to ask the administrator permission before copying the files.

I made an .exe wrapper (updater.exe) with a manifest to request for administration rights. But when I call it with ProcessBuilder(jarFolder+"Updater.exe"), I get something like "need elevated privileges"...

I guess that it is not the good approach. What should I do ?

This is the manifest :

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel level="highestAvailable"   uiAccess="False" />
</requestedPrivileges>
</security>
</trustInfo>
</assembly>  
Sharcoux
  • 5,546
  • 7
  • 45
  • 78
  • Install your application in a sub directory of the root. Easiest way to avoid all that Program Files restriction nonsense. – ManoDestra Jul 06 '16 at 17:37
  • I agree with you about the nonsense, BUT, I cannot prevent my users to choose Program Files as their install directory (I use Inno Setup installer). – Sharcoux Jul 06 '16 at 17:47
  • You can, if you wish. Simply add that requirement to your user's release notes. Then, if they go against your instructions, then they have violated your product's requirements. Simple. – ManoDestra Jul 06 '16 at 17:53
  • Ah ah ah ! I like the idea. Not very professional though... ^^ – Sharcoux Jul 06 '16 at 18:00
  • It is an entirely reasonable installation requirement. The restrictions on Program Files mean that you can't write to that location. The recommendation is to only write files, such as config, etc, elsewhere (e.g. AppData). For this kind of requirement of an auto-updating application, then installation to Program Files makes no realistic sense given the restrictions on that location. So, you can quite reasonably expect a self-updating application to be written to a location that does not have this restriction. I've worked on military standard apps and this was expected. Up to yourself though :) – ManoDestra Jul 06 '16 at 18:30
  • In my opinion, it goes against the spirit of the OS. Isn't there any way to just prompt for administration rights when starting updater.exe? – Sharcoux Jul 07 '16 at 05:56
  • Who says that everything must be installed under Program Files? Users can install their applications wherever they wish. The default recommended by MS is Program Files, but there's no requirement for users or developers to honor that, except as a default installation directory only as part of an installer. There may well be a way round your issue, but it's not something I would get too concerned about, personally. It's no biggie IMO, but good luck with it. – ManoDestra Jul 07 '16 at 06:30
  • I just feel that, as you just said, the user should be able to install wherever they wish, including the default recommended location of the platform... Anyway, as it seems ridiculously complex to do so, I might follow your advice. – Sharcoux Jul 07 '16 at 06:35
  • That all said, if you run your Java program in with Administrator privileges to begin with, then it should already have sufficient access. See this for some pointers: http://stackoverflow.com/questions/19037339/run-java-file-as-administrator-with-full-privileges – ManoDestra Jul 07 '16 at 06:49

0 Answers0