/// <summary>
        /// Installs and starts the Etw.Service so that Tests may utilize Etw Waiters.
        /// Wex.Services.exe is part of TAEF.
        /// </summary>
        public static void InstallAndStartETWService()
        {
            etwServiceWasInstalled = ServiceHelper.IsInstalled("Etw.Service");
            if (!etwServiceWasInstalled)
            {
                string wexServices = Path.Combine(TAEFHelper.GetTestDeploymentDirectory(), "Wex.Services.exe");
                if (!File.Exists(wexServices))
                {
                    throw new FileNotFoundException(wexServices);
                }

                Log.Comment("Attempting to install Etw.Service...");
                var startInfo = new ProcessStartInfo();
                startInfo.FileName  = wexServices;
                startInfo.Arguments = "/install:Etw.Service";

                var process = new Process();
                process.StartInfo = startInfo;
                if (process.Start())
                {
                    process.WaitForExit();
                    Log.Comment("Completed installation of Etw.Service");
                }
                else
                {
                    throw new Exception("ETW service was not able to be installed. Process didn't start.");
                }
            }

            Log.Comment("Attempting to start Etw.Service...");
            ServiceHelper.Start("Etw.Service");
            Log.Comment("Etw.Service started");
        }
        public static void AssemblySetup(TestContext context)
        {
            Verify.AreEqual(0, WinRTHelper_Register());
            TestHelper.Initialize();

            // Install and Start the Etw.Service service to enable the use of EtwWaiter.
            EtwHelper.InstallAndStartETWService();

            bool installApp = false;

            if (context.Properties.Contains("InstallApp") && (bool.TryParse(context.Properties["InstallApp"].ToString(), out installApp)) && installApp)
            {
                string certToDeploy = Path.Combine(TAEFHelper.GetTestDeploymentDirectory(), Constants.CertificateFileName);
                InstallHelper.InstallCertFile(certToDeploy);

                string vcLibsToDeploy = Path.Combine(TAEFHelper.GetTestDeploymentDirectory(), Constants.VCLibsPackageFileName);
                string winUIToDeploy  = Path.Combine(TAEFHelper.GetTestDeploymentDirectory(), Constants.WinUIPackageFileName);
                string appxToDeploy   = Path.Combine(TAEFHelper.GetTestDeploymentDirectory(), Constants.PackageFileName);
                Impersonater.RunAs(Impersonater.RunAsUser.RestrictedUser, () => InstallHelper.InstallPackage(appxToDeploy, vcLibsToDeploy, winUIToDeploy));
            }
        }
        /// <summary>
        /// Stops the Etw.Service.
        /// </summary>
        public static void StopAndRemoveETWService()
        {
            if (ServiceHelper.IsInstalled("Etw.Service"))
            {
                Log.Comment("Attempting to stop Etw.Service...");
                ServiceHelper.Stop("Etw.Service");
                Log.Comment("Etw.Service stopped");

                // if we installed the Etw.Service as part of this test we should also remove it.
                // This prevents cases where TDP is upgraded but the service tregistration is referencing the old
                // location that no longer exists.
                if (!etwServiceWasInstalled)
                {
                    string wexServices = Path.Combine(TAEFHelper.GetTestDeploymentDirectory(), "Wex.Services.exe");
                    if (!File.Exists(wexServices))
                    {
                        throw new FileNotFoundException(wexServices);
                    }

                    Log.Comment("Attempting to remove Etw.Service...");
                    var startInfo = new ProcessStartInfo();
                    startInfo.FileName  = wexServices;
                    startInfo.Arguments = "/remove:Etw.Service";

                    var process = new Process();
                    process.StartInfo = startInfo;
                    if (process.Start())
                    {
                        process.WaitForExit();
                        Log.Comment("Completed removal of Etw.Service");
                    }
                    else
                    {
                        throw new Exception("ETW service could not be removed. Process didn't start.");
                    }
                }
            }
        }