By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,626 Members | 2,169 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,626 IT Pros & Developers. It's quick & easy.

WMI invokemethod

P: n/a
Hello there
Anybody used Managementobject.invoke method?
if yes
how do u send method parameters?
Thanks in advance
Regards
Sameh
Nov 20 '05 #1
Share this Question
Share on Google+
8 Replies


P: n/a
Hi Sameh,

Use the 'SetPropertyValue' on the ManagementBaseObject...

\\\
myManagementBaseObject = .GetMethodParameters("SomeWMIMethod")

With myManagementBaseObject
.SetPropertyValue("SomeWMIStringProperty", "myValue")
.SetPropertyValue("SomeWMILongProperty", 12345)
End With

With .InvokeMethod("SomeWMIMethod", myManagementBaseObject, Nothing)
If (CType(CType(.Properties.Item("ReturnValue").Value , UInt32).ToString,
Integer) = 0) Then
myValue = CType(.Properties.Item("SomeWMIOutputParameter").V alue,
String)
End If
End With
///

HTH,
Gary

"Sameh Ahmed" <es******@hotmail.com> wrote in message
news:eG**************@TK2MSFTNGP10.phx.gbl...
Hello there
Anybody used Managementobject.invoke method?
if yes
how do u send method parameters?
Thanks in advance
Regards
Sameh

Nov 20 '05 #2

P: n/a
Hi Sameh,

Use the 'SetPropertyValue' on the ManagementBaseObject...

\\\
myManagementBaseObject = .GetMethodParameters("SomeWMIMethod")

With myManagementBaseObject
.SetPropertyValue("SomeWMIStringProperty", "myValue")
.SetPropertyValue("SomeWMILongProperty", 12345)
End With

With .InvokeMethod("SomeWMIMethod", myManagementBaseObject, Nothing)
If (CType(CType(.Properties.Item("ReturnValue").Value , UInt32).ToString,
Integer) = 0) Then
myValue = CType(.Properties.Item("SomeWMIOutputParameter").V alue,
String)
End If
End With
///

HTH,
Gary

"Sameh Ahmed" <es******@hotmail.com> wrote in message
news:eG**************@TK2MSFTNGP10.phx.gbl...
Hello there
Anybody used Managementobject.invoke method?
if yes
how do u send method parameters?
Thanks in advance
Regards
Sameh

Nov 20 '05 #3

P: n/a
Hi,
Dim moReturn As Management.ManagementObjectCollection

Dim moSearch As Management.ManagementObjectSearcher

Dim mo As Management.ManagementObject

moSearch = New Management.ManagementObjectSearcher("Select * from
Win32_Printer")

moReturn = moSearch.Get

For Each mo In moReturn

Dim objReturn As Object

Debug.WriteLine(mo("Name"))

mo.InvokeMethod("SetDefaultPrinter", objReturn)

Next

Ken

--------------------

"Sameh Ahmed" <es******@hotmail.com> wrote in message
news:eG**************@TK2MSFTNGP10.phx.gbl...
Hello there
Anybody used Managementobject.invoke method?
if yes
how do u send method parameters?
Thanks in advance
Regards
Sameh

Nov 20 '05 #4

P: n/a
Hi,
Dim moReturn As Management.ManagementObjectCollection

Dim moSearch As Management.ManagementObjectSearcher

Dim mo As Management.ManagementObject

moSearch = New Management.ManagementObjectSearcher("Select * from
Win32_Printer")

moReturn = moSearch.Get

For Each mo In moReturn

Dim objReturn As Object

Debug.WriteLine(mo("Name"))

mo.InvokeMethod("SetDefaultPrinter", objReturn)

Next

Ken

--------------------

"Sameh Ahmed" <es******@hotmail.com> wrote in message
news:eG**************@TK2MSFTNGP10.phx.gbl...
Hello there
Anybody used Managementobject.invoke method?
if yes
how do u send method parameters?
Thanks in advance
Regards
Sameh

Nov 20 '05 #5

P: n/a
Thanks people for your time
I am an administrator!!! who's quite interested in WMI develepoment.
Can you please give me an idea on how to use the GetOwner of the W32_process
Class?
here's the code I use.....
Dim query As ManagementObjectSearcher
Dim queryCollection As ManagementObjectCollection
Dim co As ConnectionOptions
Dim oq As System.Management.ObjectQuery
Dim ms As System.Management.ManagementScope
Dim mo As New ManagementObject
Dim path As Management.ManagementPath
Dim strComputer, strQuery As String
strQuery = "SELECT * from Win32_process"
oq = New System.Management.ObjectQuery(strQuery)
query = New ManagementObjectSearcher(ms, oq)
queryCollection = query.Get()
Dim i = 0
For Each mo In queryCollection

lv1.Items.Add(mo("name").ToString)
lv1.Items(i).SubItems.Add(mo("ProcessID").ToString )
''''''''''''''''''''''''
need to get the owner of the process here and add a sub item to the list
view
''''''''''''''''''''''''
i = i + 1

End Sub


"Ken Tucker [MVP]" <vb***@bellsouth.net> wrote in message
news:uW**************@TK2MSFTNGP12.phx.gbl...
Hi,
Dim moReturn As Management.ManagementObjectCollection

Dim moSearch As Management.ManagementObjectSearcher

Dim mo As Management.ManagementObject

moSearch = New Management.ManagementObjectSearcher("Select * from
Win32_Printer")

moReturn = moSearch.Get

For Each mo In moReturn

Dim objReturn As Object

Debug.WriteLine(mo("Name"))

mo.InvokeMethod("SetDefaultPrinter", objReturn)

Next

Ken

--------------------

"Sameh Ahmed" <es******@hotmail.com> wrote in message
news:eG**************@TK2MSFTNGP10.phx.gbl...
Hello there
Anybody used Managementobject.invoke method?
if yes
how do u send method parameters?
Thanks in advance
Regards
Sameh


Nov 20 '05 #6

P: n/a
Hi,

Dim moReturn As Management.ManagementObjectCollection

Dim moSearch As Management.ManagementObjectSearcher

Dim mo As Management.ManagementObject

moSearch = New Management.ManagementObjectSearcher("Select * from
Win32_Process")

moReturn = moSearch.Get

For Each mo In moReturn

Dim arOwner(2)

mo.InvokeMethod("GetOwner", arOwner)

Debug.WriteLine(String.Format("{0} Owner {1} Domain {2}", mo("Name"),
arOwner(0), arOwner(1)))

Next

Ken

---------------------------

"Sameh Ahmed" <es******@hotmail.com> wrote in message
news:O1**************@TK2MSFTNGP09.phx.gbl...
Thanks people for your time
I am an administrator!!! who's quite interested in WMI develepoment.
Can you please give me an idea on how to use the GetOwner of the W32_process Class?
here's the code I use.....
Dim query As ManagementObjectSearcher
Dim queryCollection As ManagementObjectCollection
Dim co As ConnectionOptions
Dim oq As System.Management.ObjectQuery
Dim ms As System.Management.ManagementScope
Dim mo As New ManagementObject
Dim path As Management.ManagementPath
Dim strComputer, strQuery As String
strQuery = "SELECT * from Win32_process"
oq = New System.Management.ObjectQuery(strQuery)
query = New ManagementObjectSearcher(ms, oq)
queryCollection = query.Get()
Dim i = 0
For Each mo In queryCollection

lv1.Items.Add(mo("name").ToString)
lv1.Items(i).SubItems.Add(mo("ProcessID").ToString )
''''''''''''''''''''''''
need to get the owner of the process here and add a sub item to the list
view
''''''''''''''''''''''''
i = i + 1

End Sub


"Ken Tucker [MVP]" <vb***@bellsouth.net> wrote in message
news:uW**************@TK2MSFTNGP12.phx.gbl...
Hi,
Dim moReturn As Management.ManagementObjectCollection

Dim moSearch As Management.ManagementObjectSearcher

Dim mo As Management.ManagementObject

moSearch = New Management.ManagementObjectSearcher("Select * from
Win32_Printer")

moReturn = moSearch.Get

For Each mo In moReturn

Dim objReturn As Object

Debug.WriteLine(mo("Name"))

mo.InvokeMethod("SetDefaultPrinter", objReturn)

Next

Ken

--------------------

"Sameh Ahmed" <es******@hotmail.com> wrote in message
news:eG**************@TK2MSFTNGP10.phx.gbl...
Hello there
Anybody used Managementobject.invoke method?
if yes
how do u send method parameters?
Thanks in advance
Regards
Sameh



Nov 20 '05 #7

P: n/a
Thanks a lot for an easy way.
I tried it and it works fine:)

"Ken Tucker [MVP]" <vb***@bellsouth.net> wrote in message
news:uR**************@TK2MSFTNGP10.phx.gbl...
Hi,

Dim moReturn As Management.ManagementObjectCollection

Dim moSearch As Management.ManagementObjectSearcher

Dim mo As Management.ManagementObject

moSearch = New Management.ManagementObjectSearcher("Select * from
Win32_Process")

moReturn = moSearch.Get

For Each mo In moReturn

Dim arOwner(2)

mo.InvokeMethod("GetOwner", arOwner)

Debug.WriteLine(String.Format("{0} Owner {1} Domain {2}", mo("Name"),
arOwner(0), arOwner(1)))

Next

Ken

---------------------------

"Sameh Ahmed" <es******@hotmail.com> wrote in message
news:O1**************@TK2MSFTNGP09.phx.gbl...
Thanks people for your time
I am an administrator!!! who's quite interested in WMI develepoment.
Can you please give me an idea on how to use the GetOwner of the

W32_process
Class?
here's the code I use.....
Dim query As ManagementObjectSearcher
Dim queryCollection As ManagementObjectCollection
Dim co As ConnectionOptions
Dim oq As System.Management.ObjectQuery
Dim ms As System.Management.ManagementScope
Dim mo As New ManagementObject
Dim path As Management.ManagementPath
Dim strComputer, strQuery As String
strQuery = "SELECT * from Win32_process"
oq = New System.Management.ObjectQuery(strQuery)
query = New ManagementObjectSearcher(ms, oq)
queryCollection = query.Get()
Dim i = 0
For Each mo In queryCollection

lv1.Items.Add(mo("name").ToString)
lv1.Items(i).SubItems.Add(mo("ProcessID").ToString )
''''''''''''''''''''''''
need to get the owner of the process here and add a sub item to the list
view
''''''''''''''''''''''''
i = i + 1

End Sub


"Ken Tucker [MVP]" <vb***@bellsouth.net> wrote in message
news:uW**************@TK2MSFTNGP12.phx.gbl...
Hi,
Dim moReturn As Management.ManagementObjectCollection

Dim moSearch As Management.ManagementObjectSearcher

Dim mo As Management.ManagementObject

moSearch = New Management.ManagementObjectSearcher("Select * from
Win32_Printer")

moReturn = moSearch.Get

For Each mo In moReturn

Dim objReturn As Object

Debug.WriteLine(mo("Name"))

mo.InvokeMethod("SetDefaultPrinter", objReturn)

Next

Ken

--------------------

"Sameh Ahmed" <es******@hotmail.com> wrote in message
news:eG**************@TK2MSFTNGP10.phx.gbl...
> Hello there
> Anybody used Managementobject.invoke method?
> if yes
> how do u send method parameters?
> Thanks in advance
> Regards
> Sameh
>
>



Nov 20 '05 #8

P: n/a
I was looking for this information and you gave me the right example. "now I understand" Thank you for being helpfull to us Newbies :

Regards

Braulio
Nov 20 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.