Firefox cannot be launched by ShellExecute from UAC elevated process
Categories
(Firefox :: Shell Integration, defect)
Tracking
()
People
(Reporter: dantmnf2, Unassigned)
Details
User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:103.0) Gecko/20100101 Firefox/103.0
Steps to reproduce:
Attempt to open a URL with default browser (Firefox) via ShellExecute from a UAC elevated process.
Example (from Python console):
Python 3.10.3 (tags/v3.10.3:a342a49, Mar 16 2022, 13:07:40) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
import ctypes
ctypes.windll.shell32.IsUserAnAdmin()
1
ctypes.windll.shell32.ShellExecuteW(None, 'open', 'http://www.example.com/', None, None, 0)
42
Actual results:
Firefox is not launched.
Expected results:
The user should get a new window or tab navigating to http://www.example.com/ .
It works as expected if I change the default browser to Chrome, so it is unlikely an OS issue.
Updated•3 years ago
|
Comment 1•3 years ago
|
||
I can reproduce this. GetLastError returns 6, which I think is ERROR_INVALID_HANDLE. I tried a couple of other things as well:
- Running the same code unelevated
ctypes.windll.shell32.ShellExecuteW(None, 'open', 'C:\\Program Files\\Firefox Nightly\\firefox.exe', None, None, 0)
Both of these opened Firefox and returned the same "error" code. This smells like either a problem with the launcher process, or somehow with our default browser registration. I will dig into it a bit more when I can.
Comment 2•3 years ago
|
||
Well, we can probably rule out ERROR_INVALID_HANDLE being meaningful:
Python 3.9.10 (tags/v3.9.10:f2f3f53, Jan 17 2022, 15:14:21) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import ctypes
>>> ctypes.GetLastError()
6
>>> ctypes.windll.kernel32.SetLastError(0)
0
>>> ctypes.GetLastError()
6
>>> def f():
... ctypes.windll.shell32.ShellExecuteW(None, 'open', 'http://www.example.com/', None, None, 0)
... return ctypes.GetLastError()
...
>>> f()
0
I can also confirm that, if you aren't running as admin, Firefox will open the URL.
Updated•3 years ago
|
Description
•