0

Following up this link, I have been trying to find a solution to handle the UAC prompt.

I need to test an application which prompts with UAC. It is a must and i need to check if it popped out and proceed further. I want to automate this thing but i found no solution yet.

I need to do it in or .

Community
  • 1
  • 1
user1102686
  • 41
  • 1
  • 1
  • 5
    You cannot do this. The whole point of UAC is that you can't automate it. If a virus could automate it, well... that completely defeats the purpose. If you need to test it, turn off UAC temporarily. – Ry- Dec 16 '11 at 20:35

4 Answers4

1

This is technically possible. You need to write a service that runs as LocalSystem. From there you launch a helper process in the secure Winlogon desktop. From there you can install a hook and check for the UAC prompt and programmatically click the appropriate button. It is a lot of work and quite a pain. Here's an answer from a while ago where I discuss it in a little more detail. I probably still have the code lying around somewhere.

Update: LOL. Just noticed that I answered the question you linked to. I guess you are trying to do this in vbscript or vb.net instead of C++; that's just not going to work.

Community
  • 1
  • 1
Luke
  • 11,211
  • 2
  • 27
  • 38
  • Luke: You say " I probably still have the code lying around somewhere" ... would you mind sharing your code with me? – divB Apr 20 '15 at 03:35
1

I wrote an application to automate UAC (including on the Secure Desktop) in VBScript and C#/VB.Net. It is only to be used in test environments for test automation (given that UAC is everywhere, it seems daft to test without it!)

You can download it (for free) here:

http://www.brekit.com/

There is also a link there on how to automate UAC "the Microsoft way" by using a Manifest and modifying your UAC Settings so that it does not appear on your Secure Desktop.

Andro Selva
  • 53,910
  • 52
  • 193
  • 240
Grey Ham
  • 11
  • 1
0

You cannot do that.

UAC is for making sure that administrative actions require a user prompt.

UAC disables your vbscript and vb.net when its active. If you find a way around it its an exploit/bug thats likely to be fixed when its discovered by microsoft.

Udo Held
  • 12,314
  • 11
  • 67
  • 93
0

Short answer was given above: no, you can't.

If you're interested in knowing why, read the following:

There is no way to 'automate' UAC. User Account Control was developed in order for malicious software (viruses, spyware, adware, etc...) to avoid being run on a target machine.

It is similar to the permission dialog on *nix-based Systems (Mac OS X, and many, many Linux distros), that ask for your password whenever they need to execute some code that requires an elevation of privileges (for example, installing an application).

The problem with Windows is that in previous versions (Windows XP), it became extremely easy for unwanted software to execute code on a target machine and compromise the whole system. This was put in place so users know when someone/something wants access to more than they can usually do by default.

So if UAC is really in your way, they only way is to disable it (Control Panel -> User and Account Settings -> User Account Control, and drag the slider to the bottom on Windows 7).

swiftcode
  • 3,039
  • 9
  • 39
  • 64