Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Competitor app installs to same folder as mine, without requiring admin priveleges

First off hi all, and thanks for the many times searching here has helped me out or taught me something.

I've made a custom HUD for a game I play, and am working on an installer in C#, inspired by another HUD for the same game. It downloads and overwrites all the script files to the existing directory:

C:\Program Files (x86)\Steam\steamapps\me\team fortress 2\tf

[I don't have any control over which folder to use unfortunately, since I'm modifying files which Valve installed]

In order to delete folders, add folders, or copy files, I've had to use an app manifest to increase the user permissions every time the exe is launched:

<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />

Somehow, the installer I've been inspired by is installing to the same folder that I am, without forcing a UAC prompt.

His app only shows a security warning, but if I uncheck the "always check" checkbox, I can run it over and over again without having to verify any special permissions:

http://www.trishtech.com/img_art_a/win7_publisher_not_verified_0.jpg&gt;">

Any suggestions on how I can make my app more seamless like his? I've contacted the author of the other app, and he says he is also using C#, but doesn't know of anything special he's doing to make this work.

EDIT: A few things I know we're doing differently, just in case they make a difference somehow:

  • I'm using a file browser to decide where to put my files, so the app can be run from anywhere.
    • He's just outputting them to the same directory as the exe, requiring the exe to be put in the destination folder.
  • I'm using ILMerge to bundle SharpZipLib with my app.
    • He's just leaving the dll in his zip file next to the exe.
like image 790
appski Avatar asked Sep 04 '12 18:09

appski


1 Answers

If you are trying to write to "C:\Program Files (x86)" then you need admin rights. It follows that the other app must not be creating files there, but to a directory that is not protected by UAC.

If your files are per user, then you can create a subfolder in the appdata folder and save the files there.

Convention is to create a folder to indentity the company and another to identity the product,

eg

var dir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) 
          +    "\\MyCompanyName\\MyApplicationName";
like image 194
sgmoore Avatar answered Sep 30 '22 09:09

sgmoore