-1

Basically I either need to Click the UAC button with my program(which i don't believe is possible) or somehow make it so I don't need to click the button to install the software. I will also need to click buttons during the install with my program but I know how to do that. I am only concerned with the UAC things.

Cœur
  • 37,241
  • 25
  • 195
  • 267
kthompson
  • 803
  • 6
  • 16
  • The title of the question doesn't match the body. I'm unsure what you're asking for. – Mark Ransom Jan 26 '12 at 19:45
  • 2
    You can click the UAC button programatically, but in order to do so you need to install a service which requires a UAC prompt; kind of a catch-22. – Luke Jan 26 '12 at 21:40
  • Luke, if you want to comment ill give you credit. The install will be downloaded automatically as part of a build system. I could likely pre install a service that downloads the installer and runs it. – kthompson Jan 30 '12 at 17:38

3 Answers3

4

One way or the other, the user is going to have to click that button to give you permission to proceed. That's the whole point of UAC, if there were a way to work around it, it would serve absolutely no purpose.

You can either ask for permission sooner (at the beginning of your installation) or later (at the point in the installation when the privileges are first actually required), but you have to do it one of those times.

The standard course of action is to embed a manifest in your application that indicates you require administrative privileges. The applicable line looks like this:

<requestedExecutionLevel level="requireAdministrator" />

Alternatively, you could choose to rely on UAC's "Installer Detection" functionality:

The first application compatibility technology that is part of UAC is called Installer Detection. Because most installers write binaries to the Program Files directory, they overwhelmingly need administrator privileges. Installer Detection is designed to scan the name and the resources of the EXE to determine whether an application is an installer. For example, an executable would be marked as an installer if the executable name or description contained the strings "install" or "setup". So an application named setup.exe, without an application manifest, would trigger a UAC elevation if launched by a token without administrator privileges.

Clicking buttons during your install isn't a very good idea, either. If this is an installer that you're writing, code in some "silent install" flags that you can specify when executing the installer app. If this is a third-party installer that you're using, check the documentation; chances are such flags already exist. The point of these flags is that interactive UI is not displayed at all during setup, meaning that no one has to bother clicking any buttons (which is very hard to get right).

Cody Gray - on strike
  • 239,200
  • 50
  • 490
  • 574
3

you can install your program in the user's home directory or any other directories which is writable without administrator privilege.

if you're writing an installer wrapper, you can ask for UAC on the wrapper and the wrapper can start the real installer(s) with administrator privilege. Most installers also provides command line options for unattended installations, so you might want to check those instead of scripting button clicks.

Lie Ryan
  • 62,238
  • 13
  • 100
  • 144
0

You can't click button on UAC consent dialog.

Your other options depend on what you really try to achieve. So give us more details on the your task: there could be better design choices than clicking installer buttons from an application.
To avoid UAC, you can install a service which will start the installation. But user has to consent when you install the service.

Alexey Ivanov
  • 11,541
  • 4
  • 39
  • 68