Skip to content

Instantly share code, notes, and snippets.

@cobalthex
Last active November 11, 2021 18:32
Show Gist options
  • Select an option

  • Save cobalthex/4fa7652737aa25650d42953e6972b880 to your computer and use it in GitHub Desktop.

Select an option

Save cobalthex/4fa7652737aa25650d42953e6972b880 to your computer and use it in GitHub Desktop.
Stop NVidia's USB C controller from waking machine (requires elevation)
#define UNICODE
#include <Windows.h>
#include <PowrProf.h>
#pragma comment(lib, "PowrProf.lib")
const wchar_t szDeviceName[] = L"NVIDIA USB Type-C Port Policy Controller";
int main()
{
return DevicePowerSetDeviceState(szDeviceName, DEVICEPOWER_CLEAR_WAKEENABLED, nullptr);
}
function Disable-NvidiaUsbCWake {
$Win32Type = Add-Type -MemberDefinition @'
[DllImport("PowrProf.dll", CharSet=CharSet.Unicode)]
public static extern uint DevicePowerSetDeviceState(string DeviceDescription, uint SetFlags, IntPtr SetData);
'@ -Name PowrProf -Namespace Win32 -PassThru
$Win32Type::DevicePowerSetDeviceState('NVIDIA USB Type-C Port Policy Controller', 0x00000002, [IntPtr]::Zero)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment