Skip to main content
Participant
October 13, 2017
Question

Run AIR application with admin privileges

  • October 13, 2017
  • 1 reply
  • 1313 views

I have an AIR Application that needs the Administrator privileges to use some files of Windows. When I run as Administrator all my code works. But when I run as user who doesn't have the admin privileges my code fails. I put exename.exe.manifest file in exe path that also not work.

This topic has been closed for replies.

1 reply

IGZN
Inspiring
October 13, 2017

Well, there are a few ways to achieve this, but each of them is a bit hacky.

First, you should ask yourself if you really need your app to run as Administrator. Maybe if you describe what your app does with the Windows files, someone can help you with finding other solutions. Maybe what you're trying to do can be achieved using embedded files installed in applicationStorageDir or documentsDir.

If you really need the Administrator privileges you can do one of the followings:

  • Use an Installer Maker software (like Inno Setup or NSIS, but there are plenty out there) and configure the installed files to run as administrator (Creating an installer is always a good approach when you're distributing software to desktop computers)
  • You can also create a shortcut file right next to your executable and set it to run as Administrator, and include this shortcut file in your application installer, but in this case, you have to make sure the app is always installed in the same directory, and users can't change it
  • You can also try using a launcher.exe for your app, which is created either in a desktop IDE (like Visual Studio, should be pretty easy to create a program like this with a few lines of code) or any other software that acts as a "launcher app for other apps", requires admin privileges and its sole purpose is only to launch your app. Package it with your app installer, set it as the default app, and I think you're good to go.