Disable serial port via WMI

T

TDM

Is there any way to use WMI to disable a COM port similar to a right
click/Disable from the Device Manager ?

TIA

TDM
 
W

Walter

Hi there,

Look for SetPowerState() inside Win32_SerialPOrt.

But you have to use the CIM_SerialController namespace to trigger this
action

Thank you

From
Walter
 
T

TDM

Walter,

I actually already tried that, but when trying to use the SetPowerState
Method, I get a type mismatch. The documentation I have on this method comes
from the WMI Object browser from M$ and fails to elaborate on the
definintion for "Time", nor have I found any samples via google, they simply
say DateTime format, but everything I have tried is failing. Perhaps you can
elaborate some ?

uint32 SetPowerState(

[in] uint16 PowerState,

[in] datetime Time

);

SetPowerState defines the desired power state for a logical device and when
a device should be put into that state. The desired power state is specified
by setting the PowerState parameter to one of the following integer values:
1="Full Power", 2="Power Save - Low Power Mode", 3="Power Save - Standby",
4="Power Save - Other", 5="Power Cycle" or 6="Power Off". The Time parameter
(for all state changes, except 5, "Power Cycle") indicates when the power
state should be set, either as a regular date-time value or as an interval
value (where the interval begins when the method invocation is received).
When the PowerState parameter is equal to 5, "Power Cycle", the Time
parameter indicates when the device should power on again. Power off is
immediate. SetPowerState should return 0 if successful, 1 if the specified
PowerState and Time request is not supported, and some other value if any
other error occurred. In a subclass, the set of possible return codes could
be specified, using a ValueMap qualifier on the method. The strings to which
the ValueMap contents are 'translated' may also be specified in the subclass
as a Values array qualifier.

PowerState

<description missing>

Time

<description missing>
 
W

Walter

Hi there,

you exec the method under CIM_SerialController or Win32_SerialPort?


TDM said:
Walter,

I actually already tried that, but when trying to use the SetPowerState
Method, I get a type mismatch. The documentation I have on this method
comes from the WMI Object browser from M$ and fails to elaborate on the
definintion for "Time", nor have I found any samples via google, they
simply say DateTime format, but everything I have tried is failing.
Perhaps you can elaborate some ?

uint32 SetPowerState(

[in] uint16 PowerState,

[in] datetime Time

);

SetPowerState defines the desired power state for a logical device and
when a device should be put into that state. The desired power state is
specified by setting the PowerState parameter to one of the following
integer values: 1="Full Power", 2="Power Save - Low Power Mode", 3="Power
Save - Standby", 4="Power Save - Other", 5="Power Cycle" or 6="Power Off".
The Time parameter (for all state changes, except 5, "Power Cycle")
indicates when the power state should be set, either as a regular
date-time value or as an interval value (where the interval begins when
the method invocation is received). When the PowerState parameter is equal
to 5, "Power Cycle", the Time parameter indicates when the device should
power on again. Power off is immediate. SetPowerState should return 0 if
successful, 1 if the specified PowerState and Time request is not
supported, and some other value if any other error occurred. In a
subclass, the set of possible return codes could be specified, using a
ValueMap qualifier on the method. The strings to which the ValueMap
contents are 'translated' may also be specified in the subclass as a
Values array qualifier.

PowerState

<description missing>

Time

<description missing>



Walter said:
Hi there,

Look for SetPowerState() inside Win32_SerialPOrt.

But you have to use the CIM_SerialController namespace to trigger this
action

Thank you

From
Walter
 
P

Peter Falz

Hi Walter,

Walter said:
Look for SetPowerState() inside Win32_SerialPOrt.
But you have to use the CIM_SerialController namespace to trigger this
action

CIM Studio doesn't allow neither with CIM_SerialController nor with
Win32_SerialPOrt to execute Method "SetPowerState" for
existing instances.

Take a look at:
http://msdn.microsoft.com/library/d...tate_method_in_class_cim_serialcontroller.asp

You will see, that MSDN writes under "Remarks", that this method is
not implemented.

Don't worry, be happy :)

Bye
Peter
 
T

TDM

Peter,

I was able to validate this as well. Anybody else got any other suggestions
?

TDM
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top