Windows – Programmatically disable device in device manager (Vista x64)

64-bitdevicewindows-vista

Is there any way to programmatically disable a device? (preferably in .net, win32, or batch).

Most hits on google suggest using devcon but it does not seem to be working on Windows Vista/7 64bit.

How do I disable a system device? has a solution using SetupDiSetClassInstallParams but it also doesn't work for Vista64.

Best Answer

The 32-bit version of devcon doesn't completely work in WoW64 emulation; I've seen it fail to disable devices as well. The Windows Driver Kit includes a 64-bit version of devcon, which works. It also includes the source code to devcon, so you can see that devcon is just a wrapper for the Setup API.

When you tried calling into the Setup API directly, was it from a 32-bit or 64-bit process? Based on experiences using devcon, I suspect that you need to call into the Setup API from a 64-bit process.