6
votes

I have an installer I'd like to run from a script. The installer requests UAC elevation but it doesn't need elevation because I'm installing to a user directory. Is there some way to run the installer so that it doesn't request UAC elevation?

The script is written in Python so I can access the Windows API through ctypes.

Changing the installer is not an option.

1
What installer is it? This might be a duplicate of: stackoverflow.com/questions/252871/… - John Zwinck
@John it's an exe created by Inno Setup. - Peter Graham
I've heard that the Microsoft Application Compatibility Toolkit can disable UAC elevation for a specific executable. However, while this doesn't involve modifying the executable, it does involve modifying the operating system so I'm guessing this isn't a good option for you. - Harry Johnston
Have you tried to run the installation under limited user account with UAC turned off or on XP/2003? The installer could be writing uninstall info into HKLM, and therefore requires elevation. - Alexey Ivanov

1 Answers

4
votes

You have to set the enviromnet variable __compat_layer for your process to RunAsInvoker. Then you can run the executable without any UAC prompt.

You can use the Windows API function SetEnvironmentVariable for this purpose.