Over a million developers have joined DZone.

Running The Boot Camp Control Panel Applet From Windows 8 on MacBook Pro

· Mobile Zone

As John Robbins repeatedly likes to say, Apple computers are the best hardware for running Windows. To quote, “a Mac Pro […] it's the best Windows machine money can buy”. After yesterday’s release of Windows 8 to MSDN subscribers, I went along and installed it on my new MacBook Pro.

Everything went fine—the setup was blazingly fast, all drivers were successfully installed, except for the pesky Apple trackpad settings that were way off what a Windows user comes to expect. In case you don’t know, MacBook trackpads look like this:

There’s no left or right button; just a solid sheet of multi-touch goodness. Well, not-so-goodness—the default gesture for right-click on this trackpad is the following: tap the trackpad with two fingers and simultaneously click with a third finger. (Or, you know, use Shift-F10 every time.)

Typically you’d go to the Control Panel, launch the Boot Camp control panel applet and change all these settings. When I did that, the control panel applet required UAC elevation and then refused to start, claiming that I don’t have access to my startup disk. It’s worth noting that I haven’t requested access to my startup disk.

Scouring the web for hints, I found a post indicating that if you use a standard user account to launch the Boot Camp control panel applet, it works just fine and lets you change the right-click trackpad settings. That’s what I did, only to find the changes made under the new user account do not affect my primary (“Microsoft Account”-enabled) user account.

That’s when I realized that I shouldn’t have been messing around with the secondary user account at all. In fact, it would suffice to launch the control panel applet as standard user, bypassing the elevation process, and it would work fine. So the final piece of puzzle is how to launch a process as standard user when it demands UAC elevation.

This takes me back to the first days of Windows Vista (and this blog), when I even wrote a library called UACHelpers that allows various customizations of this sort. One way or another, to determine whether the program should run elevated Windows consults its manifest. In the case the Boot Camp control panel applet, it says “highestAvailable”, which means that if the user is an administrator, he will be prompted for elevation prior to running the application. We need to modify this to “asInvoker”, so that if the current token is non-elevated, it will be used without prompting for elevation.

I made a copy of the Boot Camp control panel applet (C:\Windows\System32\AppleControlPanel.exe), extracted its manifest using the mt.exe tool, modified it to avoid requesting elevation, embedded it back into the executable, and voila!—everything worked just fine.

In other words:

> copy C:\windows\system32\AppleControlPanel.exe .
> mt.exe -inputresource:AppleControlPanel.exe;#1
> sed –i '' -e's/highestAvailable/asInvoker'
> mt.exe -outputresource:AppleControlPanel.exe;#1
         -manifest extracted.manifest

 To summarize, the days of writing Application Compatibility training kits paid off again.


Published at DZone with permission of Sasha Goldshtein , DZone MVB .

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}