Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ShellExecute fails if run from elevated process and non-default browser set in Windows 8 RTM

Set non-default browser in Windows 8 RTM (Chrome, Firefox) and try to run code like this:

ShellExecute(NULL, "open", "http://stackoverflow.com", NULL, NULL, SW_SHOWNORMAL);

It's ok. But then change manifest to require Administrative priveleges or just "run as administrator".

Code won't work.

Ok, then try to run any application using "run as administrator".

You will see the same result, links are not working.

Change default browser back to IE -> all works fine.

In Windows 8 previous builds there is no such behavour.

What is going on?

PS. It seems Microsoft experienced the same problems in their own software :) Visual Studio 2012 Web Publish on Windows 8 RTM Fails Browser Launch

like image 204
Brun Avatar asked Aug 21 '12 12:08

Brun


1 Answers

I've been seeing the same behavior with Chrome until today. Spent some time trying to figure out what was going on and couldn't for the longest time make Chrome come up with ShellExecute() under elevated rights either. Failed for elevated rights (ie. UAC dialog, or Run As Administrator) or even when turning off UAC altogether.

I ended up uninstalling and re-installing Chrome and that actually fixed it.

Also saw the behavior with other browsers, however after a few tries with FireFox I went into the Set Default Programs settings from FireFox and EXPLICITLY (ie. in Windows) set the associations for .htm file and the HTTP protocol. That worked as well.

So it looks like this is some sort of registration issue, rather than an actual problem in Windows. First thing I would try is to explicitly set the associations in Windows (rather than Set Default Browser in the browser). If that fails try reinstalling the browser...

like image 127
Rick Strahl Avatar answered Sep 20 '22 18:09

Rick Strahl