Right, but this is not what the OP was asking about. The OP asked if it was
possible to programatically enable/disable a device, what you are suggesting
is changing the startmode, but this only takes effect after a reboot, which
is IMO not what the OP is looking for. Note also that it highly depends on
the device, some do not allow to change the startmode and others simply
ignore it.
Willy.
"mabra" <***@home> wrote in message news:%23p4P$***@TK2MSFTNGP06.phx.gbl...
| Hi Willy and All,
|
| I feel, you're probably wrong. The "Win32_SystemDriver"
| class has a "ChangeStartMode" method.
| I scripted, years ago, the following:
|
| Set objLocator = WScript.CreateObject("WbemScripting.SWbemLocator")
| Set objServices = objLocator.ConnectServer(".", "root/CIMV2")
| strWMIObjectID = "Win32_SystemDriver.Name=""Cdrom""" 'Be excact here!
| Set objService = objServices.Get(strWMIObjectID)
| objService.ChangeStartMode strStartMode
|
| This will become active, after the box re-starts.
| I think, the same method should o in C# ;-)
|
| Best regards,
| Manfred
|
| Willy Denoyette [MVP] wrote:
| > No, this is not provided through WMI, all you can do is stop and start
the
| > (device driver) service (provided the device is startable/stoppable),
take a
| > look at the Win32_SystemDriver class and it's StartService and
StopService
| > commands.
| >
| >
| > Willy.
| >
| > "Michael" <***@domain.com> wrote in message
| > news:%***@TK2MSFTNGP05.phx.gbl...
| > | I'm exploring how to programmatically disable/enable devices in a
system
| > | using C#.
| > |
| > |
| > | -MH
| > |
| > |
| >
| >