Last active
November 11, 2021 18:32
-
-
Save cobalthex/4fa7652737aa25650d42953e6972b880 to your computer and use it in GitHub Desktop.
Stop NVidia's USB C controller from waking machine (requires elevation)
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
| #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); | |
| } |
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
| 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