Enable/disable devices

(imported topic written by SystemAdmin)

Hi guys…

I’m working on some relevance to check to see if the onboard wired NIC is enabled or not. If it’s disabled, then I’m figuring on using devcon.exe to enable/disable it (see: http://support.microsoft.com/kb/311272).

I’m not entirely close to it yet, but I’m looking at “active devices whose (class of it = “Net” and description of it ends with “Controller” and status of it = ???)”

Anyone have any info on the status bits of the device driver status? I can see on this laptop that enabled it’s 25174026 and disabled it’s 25175040. Referencing "status of " in the BES inspector docs.

Paul

(imported comment written by SystemAdmin)

I might have found my own info. Looking at the Configuration Manager status on MSDN, via CM_Get_DevNode_Status (

http://msdn.microsoft.com/en-us/library/ff538514(v=vs.85).aspx

)

It references “… any combination of the DN_-prefixed bit flags defined in Cfg.h”.

So, if I’m reading this correctly, my values decode as:

Status = 25174026 (enabled)

DN_NT_DRIVER + DN_NT_ENUMERATOR + DN_DISABLEABLE + DN_STARTED + DN_DRIVER_LOADED

(0x01000000 + 0x00800000 + 0x00002000 + 0x00000008 + 0x00000002)

Status = 25175040 (disabled)

DN_NT_DRIVER + DN_NT_ENUMERATOR + DN_DISABLEABLE + DN_HAS_PROBLEM

(0x01000000 + 0x00800000 + 0x00002000 + 0x00000400)

Man, I seem to give myself the complex problems. :stuck_out_tongue:

Paul

(imported comment written by MattBoyd)

It sounds like you found a solutoin, but if not you could also try looking under HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum for your device. If it’s enabled, ConfigFlags should be set to 0x0. If it’s disabled, I think ConfigFlags is set to 0x1.

I’ve used ConfigFlags before to determine when devices weren’t “completely” installed… http://iboyd.net/index.php/2010/06/29/ati-radeon-causes-a-uac-prompt-at-user-logon/

(imported comment written by SystemAdmin)

Thanks boyd, that’s a bigger help than using the active device object.

Using my previous method I suppose either would work:

exists active device whose (class of it = “Net” and description of it contains “Gigabit” and not bit 1 of status of it)

or

exists problem id of active device whose (class of it = “Net” and description of it contains “Gigabit” and not bit 1 of status of it)

Bit in both cases it takes 184ms to 235ms to determine (ouch!)

This was much faster at only .82ms to 1.21ms:

exists key whose (exists key whose (value “Class” of it = “Net” and value “DeviceDesc” of it as string contains “Gigabit” and value “ConfigFlags” of it = 1) of it) of key “HKEY_LOCAL_MACHINE\System\CurrentControlSet\Enum\PCI” of registry

-Paul

(imported comment written by MattBoyd)

No problem, Paul. Glad I could help!