On Windows 7, my copy of gVim has suddenly triggered the User Account Control popup "Do you want the following program from an unknown publisher to make changes on this computer?"

As far as I can tell, this began for no apparent reason:

  • Windows Update last ran 3 days ago.
  • I have used gVim many times since then.
  • I previously used the same copy of gVim without this happening for 6+ months.
  • I don't think I've changed any Control panel type settings

This is a problem because: If I select "Yes", then gVim launches and seems to work ... except AutoHotkey breaks. I was using AutoHotkey to remap Caps Lock to Escape (very useful for vim), which stops working inside gVim. The key remapping continues to work in other programs including terminal vim in Mingw.

Does anyone know what might be happening?

  • Have you tried to run AHK as admin? – MCL Jan 15 '14 at 15:01
  • Thanks... yes, running autohotkey as admin makes it work with gVim. Still a mystery why this started happening. If you resubmit comment as answer I'd be happy to accept it. – mjeppesen Jan 16 '14 at 0:26

The UAC window runs in its own protected process and on a desktop that's separate from the regular user's desktop. Any programs already running in that user's space can't, for instance, spoof keystrokes or mouse gestures to it.

(Copied from here)

Consequentially, if you want AHK to interact with an UAC elevated window, you'll have to run the script itself as an administator. An easy way to achieve this in AHK_L is to put this code at the top of your script:

if not A_IsAdmin
    Run *RunAs "%A_ScriptFullPath%"

This will work with both compiled and uncompiled scripts.
Although clean and short, you can't pass parameters using this method. If you would like to find another approach, there are plenty of examples listed in the AHK forums.

|improve this answer|||||

Upgrading to vim version 8 has solved the problem on my computer -- UAC is no longer triggered and vim can run as a non-Administrator.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.