Jump to content
Sign in to follow this  
mattw112

WMI and put

Recommended Posts

mattw112

I've tried searching on this and not really found much.

I want to edit a value of a property of an instance in a WMI Class.

I see lots of posts on reading WMI but not really much on editing an existing value.

I did find a couple posts where people rename drives or create printers but I'm still not getting it to work.

; Set the WMI-Service
$o_WMIService  = ObjGet("winmgmts:\\.\root\N1E\WakeUp")

$o_Agents = $o_WMIService.ExecQuery("SELECT * FROM Agents", "WQL")

For $o_Agent in $o_Agents
    MsgBox(0, "TEST",  $o_Agent.AgentNameAlt)

    If $o_Agent.IP_Subnet = "192.168.12.0" Then
                $o_Agent.AgentNameAlt = "S01-DC1"
        $o_Agent.Put_
        MsgBox(0, "TEST", "After Put")
    EndIf

Next

Using this code I get the first message box with the current values. When it gets to the value which has the IP_Subnet specified then I get an error (80020009) no description??

Are there better examples of how I can edit a Instance in WMI for just one property?

Thanks,

Terry

Share this post


Link to post
Share on other sites
PsaltyDS

I've tried searching on this and not really found much.

I want to edit a value of a property of an instance in a WMI Class.

I see lots of posts on reading WMI but not really much on editing an existing value.

I did find a couple posts where people rename drives or create printers but I'm still not getting it to work.

; Set the WMI-Service
$o_WMIService  = ObjGet("winmgmts:\\.\root\N1E\WakeUp")

$o_Agents = $o_WMIService.ExecQuery("SELECT * FROM Agents", "WQL")

For $o_Agent in $o_Agents
    MsgBox(0, "TEST",  $o_Agent.AgentNameAlt)

    If $o_Agent.IP_Subnet = "192.168.12.0" Then
                $o_Agent.AgentNameAlt = "S01-DC1"
        $o_Agent.Put_
        MsgBox(0, "TEST", "After Put")
    EndIf

Next

Using this code I get the first message box with the current values. When it gets to the value which has the IP_Subnet specified then I get an error (80020009) no description??

Are there better examples of how I can edit a Instance in WMI for just one property?

Thanks,

Terry

Post a link to the "N1E\Wakeup" interface description. Does it include the .put method? Is the .AgentNameAlt property read/write?

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites
mattw112

Hmm... I dont know if there is one.

Is there a way I can tell? I'm using WMIExplorer and it has a lot of features.

So I was thinking the put_ was just a WMI thing? After you make changes you use put to make them stick... so you are saying that maybe that isn't the case?

Also I was thinking anything could be read or write? How would I change this? I saw some flags Which I also tried using with the put_(0x0)

Which means for changes I think.

Thanks,

Terry

Edited by mattw112

Share this post


Link to post
Share on other sites
mattw112

FYI: From looking at the ObjectProviderRegistration it says it SupportsPut.

Terry

Share this post


Link to post
Share on other sites
mattw112

Actually just found out it is read only.

Hmm.. there's got to be a way to change the items though since I can do it through the GUI...

Thanks,

Terry

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×