Strawberry Perl, patch.exe and UAC

I work a lot with Perl 5 under Windows and have loved Strawberry Perl so much. I’ve been using ActiveState’s ActivePerl since 2001 and welcomed the UNIX-like experience Strawberry Perl gave me, especially because it was sometimes very hard to get some modules for ActivePerl.

Anyhow, in Windows Vista and up the User Account Control feature has a backwards-compatibility feature where for programs that don’t contain manifest files (presumably because they aren’t UAC-aware) Windows will look at certain characteristics of the file to determine if it needs Administrative privileges to run properly. One of the ways it determines this is by file name. The utility that comes with the C tool chain in Strawberry Perl patch.exe triggers this detection mechanism because of the word “patch” in the file name. Because of this it is pretty much impossible to install modules like Math::Pari that make use of the patch.exe program.

A few days ago I saw a new development release of Win32::Exe (0.12_03) was released and saw it supported viewing and modifying of embedded manifests! I decided to use this on the patch.exe file in Strawberry Perl to set the required privilege level to asInvoker (so that UAC is not needed) and it worked! Though you no longer need to do this for the April 2010 and up Strawberry Perl releases, anyone running an older version and not planning to upgrade soon may want to modify their path.exe with the following commands:

C:\> cpan MDOOTSON/Win32-Exe-0.12_03.tar.gz
C:\> perl -MWin32::Exe -e "$e=Win32::Exe->new('c:/strawberry/c/bin/patch.exe'); $m=$e->get_manifest; $m->set_execution_level('asInvoker'); $e->set_manifest($m); $e->write;"

Leave a Reply