Skip to content

Instantly share code, notes, and snippets.

@Aetopia
Created June 18, 2024 06:15
Show Gist options
  • Save Aetopia/26ac2b48a2a9e9746b02122450b05c88 to your computer and use it in GitHub Desktop.
Save Aetopia/26ac2b48a2a9e9746b02122450b05c88 to your computer and use it in GitHub Desktop.
Bypass Process Lifecycle Manager.

PLMBypass

This gist features a pure PowerShell/C# implementation of AppLifecycleOptOut.

Usage

  1. Obtain the names of the packages that shouldn't be affected by the Process Lifecycle Manager.

  2. Edit the $Names variable with the names of the desired packages:

    $Names = @("Microsoft.MinecraftUWP", "Microsoft.XboxIdentityProvider")
  3. Add the script to startup.

<# ::
@echo off
powershell -c "iex (gc -Raw '%~f0')"
goto :eof
#>
$Names = @()
Add-Type -TypeDefinition @"
using System;
using System.Runtime.InteropServices;
public static class PackageDebugSettings
{
[Guid("F27C3930-8029-4AD1-94E3-3DBA417810C1"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
interface IPackageDebugSettings { int EnableDebugging(string packageFullName, string debuggerCommandLine = null, string environment = null); }
static readonly IPackageDebugSettings packageDebugSettings = (IPackageDebugSettings)Activator.CreateInstance(Type.GetTypeFromCLSID(new Guid("B1AEC16F-2383-4852-B0E9-8F0B1DC66B4D")));
public static void EnableDebugging(string packageFullName) { Marshal.ThrowExceptionForHR(packageDebugSettings.EnableDebugging(packageFullName)); }
}
"@
Get-AppxPackage | ForEach-Object { if ($_.Name -in $Names) { [PackageDebugSettings]::EnableDebugging($_.PackageFullName) } }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment