Created
January 22, 2023 14:40
-
-
Save smourier/88731b773e0d665743ff723bf8bd80e8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $Source = @" | |
| using System; | |
| using System.Runtime.InteropServices; | |
| namespace wuapi | |
| { | |
| [ComImport, Guid("ef8208ea-2304-492d-9109-23813b0958e1"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] | |
| public interface IUpdateInstaller4 | |
| { | |
| void _VtblGap0_29(); // skip 4 (IDispatch) + 25 IUpdateInstaller4 methods | |
| [PreserveSig] | |
| int Commit(uint dwFlags); | |
| } | |
| public static class UpdateCommitter | |
| { | |
| public static int Commit(object comObject, uint dwFlags) | |
| { | |
| var updateInstaller = (IUpdateInstaller4)comObject; | |
| return updateInstaller.Commit(dwFlags); | |
| } | |
| } | |
| } | |
| "@ | |
| Add-Type -TypeDefinition $Source | |
| $CommitResult=[wuapi.IUpdateInstaller4].InvokeMember('Commit',[Reflection.BindingFlags]::InvokeMethod, $null, $UpdateInstaller, @(0)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment