Skip to content

Instantly share code, notes, and snippets.

@smourier
Created January 22, 2023 14:40
Show Gist options
  • Save smourier/88731b773e0d665743ff723bf8bd80e8 to your computer and use it in GitHub Desktop.
Save smourier/88731b773e0d665743ff723bf8bd80e8 to your computer and use it in GitHub Desktop.
$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