473,387 Members | 1,464 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

WMI invokemethod

Hello there
Anybody used Managementobject.invoke method?
if yes
how do u send method parameters?
Thanks in advance
Regards
Sameh
Nov 20 '05 #1
8 7804
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
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
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
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: tascien | last post by:
I think invoke method is good. but it is not 'great'... I need a way to invoke the class... ex: t = getType(myClass) t.InvokeMethod(....) That is if i don't know the method, but I know the...
2
by: julien | last post by:
Hello, I have an assembly with a static variable: private static readonly ILog log4net = LogManager.GetLogger(typeof(Core)); In one of the methods, I use this variable: private void myMethod()...
2
by: Brian Worth | last post by:
I have just upgraded from VB 4.0 to VB .NET 2002. One program under VB 4.0 was able to shut down or restart the (windows XP) machine using a series of API calls. (Getlasterror, GetCurrentProcess,...
4
by: Ringo | last post by:
I've created a component that takes a class as an input and executes methods on the class based on a set of text instructions. The instructions are the names of the methods to be executed and are...
6
by: Sameh Ahmed | last post by:
Hello there Anybody used Managementobject.invoke method? if yes how do u send method parameters? Thanks in advance Regards Sameh
0
by: Jan | last post by:
I just started using .NET Remoting. I have a test system (client) which connects to our device (server) running XP Embedded. When my server object is called it uses a library where reflection...
1
by: JamesB | last post by:
I am trying to access a method in another VB6 application from my C# app. If I add a reference to the relevant DLL it all works, and one bit where I need to set a DB connection works by doing: ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.