| Index: tools/telemetry/telemetry/core/platform/win_platform_backend.py
|
| diff --git a/tools/telemetry/telemetry/core/platform/win_platform_backend.py b/tools/telemetry/telemetry/core/platform/win_platform_backend.py
|
| index 4597c40c7c6e84918b1ee20310b09a2d963d6e6c..94f99b338687924e73339fb01cdd1d3c0ccb4051 100644
|
| --- a/tools/telemetry/telemetry/core/platform/win_platform_backend.py
|
| +++ b/tools/telemetry/telemetry/core/platform/win_platform_backend.py
|
| @@ -11,10 +11,14 @@ import time
|
| try:
|
| import pywintypes # pylint: disable=F0401
|
| import win32api # pylint: disable=F0401
|
| + from win32com.shell import shell # pylint: disable=F0401
|
| + from win32com.shell import shellcon # pylint: disable=F0401
|
| import win32con # pylint: disable=F0401
|
| import win32process # pylint: disable=F0401
|
| except ImportError:
|
| pywintypes = None
|
| + shell = None
|
| + shellcon = None
|
| win32api = None
|
| win32con = None
|
| win32process = None
|
| @@ -201,3 +205,20 @@ class WinPlatformBackend(desktop_platform_backend.DesktopPlatformBackend):
|
| ctypes.windll.psapi.GetPerformanceInfo(
|
| ctypes.byref(performance_info), performance_info.size)
|
| return performance_info
|
| +
|
| + def LaunchApplication(
|
| + self, application, parameters=None, elevate_privilege=False):
|
| + """Launch an application. Returns a PyHANDLE object."""
|
| +
|
| + # Use ShellExecuteEx() instead of subprocess.Popen()/OpenProcess() to
|
| + # elevate privileges. A new console will be created if the new process has
|
| + # different permissions than this process.
|
| + proc_info = shell.ShellExecuteEx(
|
| + fMask=shellcon.SEE_MASK_NOCLOSEPROCESS | shellcon.SEE_MASK_NO_CONSOLE,
|
| + lpVerb='runas' if elevate_privilege else '',
|
| + lpFile=application,
|
| + lpParameters=' '.join(parameters) if parameters else [],
|
| + nShow=win32con.SW_HIDE)
|
| + if proc_info['hInstApp'] <= 32:
|
| + raise Exception('Unable to launch %s' % application)
|
| + return proc_info['hProcess']
|
|
|