Discussion:
Disabling hardware or services
(too old to reply)
ChrisC
2005-08-18 07:57:08 UTC
Permalink
Im having some trouble disabling hardware using WMI. I got a handle on
the device, but when I call SetPowerState I get a type mismatch. The
definition of the method says it takes an int (power level), datetime
(when to do it)


objNetCard.SetPowerState(6, Convert.ToDateTime(Now()))


:(


Seeing as that wasnt going anywhere I tried stopping the service for
the driver using StopService - but this returns 4, which apparently
means Invalid service control.... but ive got no idea what that really
means or how to fix it.


Help!
Willy Denoyette [MVP]
2005-08-18 14:09:58 UTC
Permalink
1. First two questions; what device? Is SetPower state supported and what
are the valid powerstates for the devce.
2. The Framework DateTime is not valid as second argument in WMI, datetime
must be in WBEM specific format.

Willy.
Post by ChrisC
Im having some trouble disabling hardware using WMI. I got a handle on
the device, but when I call SetPowerState I get a type mismatch. The
definition of the method says it takes an int (power level), datetime
(when to do it)
objNetCard.SetPowerState(6, Convert.ToDateTime(Now()))
:(
Seeing as that wasnt going anywhere I tried stopping the service for
the driver using StopService - but this returns 4, which apparently
means Invalid service control.... but ive got no idea what that really
means or how to fix it.
Help!
ChrisC
2005-08-18 14:18:56 UTC
Permalink
1. First two questions; what device? Is SetPower state supported and
what
are the valid powerstates for the devce.

The device is a wireless network adapter - specifically an Intel(R) PRO
/ Wireless 2915ABG Network Connection. I dont know if SetPowerState is
supported on the device specifically, I read that it isnt covered by
WMI by default. Figured id just try setting the power state to off and
see if it worked.

2. The Framework DateTime is not valid as second argument in WMI,
datetime
must be in WBEM specific format.

Figures :) I dont know off the top of my head how to get that format
from .net, but i guess its easy.
Willy Denoyette [MVP]
2005-08-18 14:41:26 UTC
Permalink
Post by Willy Denoyette [MVP]
1. First two questions; what device? Is SetPower state supported and what
are the valid powerstates for the devce.
The device is a wireless network adapter - specifically an Intel(R) PRO
/ Wireless 2915ABG Network Connection. I dont know if SetPowerState is
supported on the device specifically, I read that it isnt covered by
WMI by default. Figured id just try setting the power state to off and
see if it worked.
2. The Framework DateTime is not valid as second argument in WMI, datetime
must be in WBEM specific format.
Figures :) I dont know off the top of my head how to get that format
from .net, but i guess its easy.
WMI doesn't implement this command by default, it's up to the provider to
implement it. You can check this option if you query the
Win32_NetworkAdapter instance, one of the attributes
"PowerManagementSupported" indicates if this feature is enabled.

Willy.
ChrisC
2005-08-19 07:57:02 UTC
Permalink
Thanks for the replies so far - looks like the adapter doesnt support
the SetPowerState, as the attribute PowerManagementSupported is false.
This leaves me with my second option I guess - figuring out why I get
invalid service control when I try to stop the service....
ChrisC
2005-08-19 10:29:08 UTC
Permalink
Update - I checked the AcceptStop property which is true... so not sure
why the direct stop isnt working. I can use ChangeStartMode to disable
the driver, which works in the sense that it prevents the wireless from
functioning, but its not exactly a great solution... any ideas from
anyone?
Nispa
2007-06-04 17:15:32 UTC
Permalink
I think that it doesn't work... maybe with windows vista we can disable harwdware by code... I'm having the same problems

From http://www.developmentnow.com/g/33_2005_8_0_0_582052/Disabling-hardware-or-services.ht

Posted via DevelopmentNow.com Group
http://www.developmentnow.com

Continue reading on narkive:
Loading...