views:

1651

answers:

2

Is there any way to programmaticly 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.

http://stackoverflow.com/questions/252185/-net-how-do-i-disable-a-system-device has a solution using SetupDiSetClassInstallParams but it also doesn't work for Vista64.

A: 

How is devcon not working for you under the 64-bit OS? Are you not able to find the executable, or is it failing somehow? Is an error being thrown?

Doug Chase
There is a 32 and a 64bit version, the 64bit executable is not for x86 though, seems to be ia64. When i start it, it says that i need a x86 or x64 version of the program. I can start the 32bit version and list devices but when i try to disable a device it just says that it failed. Running as admin.
+1  A: 

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.

bk1e