473,667 Members | 2,576 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

WMI invokemethod

Hello there
Anybody used Managementobjec t.invoke method?
if yes
how do u send method parameters?
Thanks in advance
Regards
Sameh
Nov 20 '05 #1
8 7834
Hi Sameh,

Use the 'SetPropertyVal ue' on the ManagementBaseO bject...

\\\
myManagementBas eObject = .GetMethodParam eters("SomeWMIM ethod")

With myManagementBas eObject
.SetPropertyVal ue("SomeWMIStri ngProperty", "myValue")
.SetPropertyVal ue("SomeWMILong Property", 12345)
End With

With .InvokeMethod(" SomeWMIMethod", myManagementBas eObject, Nothing)
If (CType(CType(.P roperties.Item( "ReturnValue"). Value, UInt32).ToStrin g,
Integer) = 0) Then
myValue = CType(.Properti es.Item("SomeWM IOutputParamete r").Value,
String)
End If
End With
///

HTH,
Gary

"Sameh Ahmed" <es******@hotma il.com> wrote in message
news:eG******** ******@TK2MSFTN GP10.phx.gbl...
Hello there
Anybody used Managementobjec t.invoke method?
if yes
how do u send method parameters?
Thanks in advance
Regards
Sameh

Nov 20 '05 #2
Hi Sameh,

Use the 'SetPropertyVal ue' on the ManagementBaseO bject...

\\\
myManagementBas eObject = .GetMethodParam eters("SomeWMIM ethod")

With myManagementBas eObject
.SetPropertyVal ue("SomeWMIStri ngProperty", "myValue")
.SetPropertyVal ue("SomeWMILong Property", 12345)
End With

With .InvokeMethod(" SomeWMIMethod", myManagementBas eObject, Nothing)
If (CType(CType(.P roperties.Item( "ReturnValue"). Value, UInt32).ToStrin g,
Integer) = 0) Then
myValue = CType(.Properti es.Item("SomeWM IOutputParamete r").Value,
String)
End If
End With
///

HTH,
Gary

"Sameh Ahmed" <es******@hotma il.com> wrote in message
news:eG******** ******@TK2MSFTN GP10.phx.gbl...
Hello there
Anybody used Managementobjec t.invoke method?
if yes
how do u send method parameters?
Thanks in advance
Regards
Sameh

Nov 20 '05 #3
Hi,
Dim moReturn As Management.Mana gementObjectCol lection

Dim moSearch As Management.Mana gementObjectSea rcher

Dim mo As Management.Mana gementObject

moSearch = New Management.Mana gementObjectSea rcher("Select * from
Win32_Printer")

moReturn = moSearch.Get

For Each mo In moReturn

Dim objReturn As Object

Debug.WriteLine (mo("Name"))

mo.InvokeMethod ("SetDefaultPri nter", objReturn)

Next

Ken

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

"Sameh Ahmed" <es******@hotma il.com> wrote in message
news:eG******** ******@TK2MSFTN GP10.phx.gbl...
Hello there
Anybody used Managementobjec t.invoke method?
if yes
how do u send method parameters?
Thanks in advance
Regards
Sameh

Nov 20 '05 #4
Hi,
Dim moReturn As Management.Mana gementObjectCol lection

Dim moSearch As Management.Mana gementObjectSea rcher

Dim mo As Management.Mana gementObject

moSearch = New Management.Mana gementObjectSea rcher("Select * from
Win32_Printer")

moReturn = moSearch.Get

For Each mo In moReturn

Dim objReturn As Object

Debug.WriteLine (mo("Name"))

mo.InvokeMethod ("SetDefaultPri nter", objReturn)

Next

Ken

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

"Sameh Ahmed" <es******@hotma il.com> wrote in message
news:eG******** ******@TK2MSFTN GP10.phx.gbl...
Hello there
Anybody used Managementobjec t.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 ManagementObjec tSearcher
Dim queryCollection As ManagementObjec tCollection
Dim co As ConnectionOptio ns
Dim oq As System.Manageme nt.ObjectQuery
Dim ms As System.Manageme nt.ManagementSc ope
Dim mo As New ManagementObjec t
Dim path As Management.Mana gementPath
Dim strComputer, strQuery As String
strQuery = "SELECT * from Win32_process"
oq = New System.Manageme nt.ObjectQuery( strQuery)
query = New ManagementObjec tSearcher(ms, oq)
queryCollection = query.Get()
Dim i = 0
For Each mo In queryCollection

lv1.Items.Add(m o("name").ToStr ing)
lv1.Items(i).Su bItems.Add(mo(" ProcessID").ToS tring)
''''''''''''''' '''''''''
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***@bellsout h.net> wrote in message
news:uW******** ******@TK2MSFTN GP12.phx.gbl...
Hi,
Dim moReturn As Management.Mana gementObjectCol lection

Dim moSearch As Management.Mana gementObjectSea rcher

Dim mo As Management.Mana gementObject

moSearch = New Management.Mana gementObjectSea rcher("Select * from
Win32_Printer")

moReturn = moSearch.Get

For Each mo In moReturn

Dim objReturn As Object

Debug.WriteLine (mo("Name"))

mo.InvokeMethod ("SetDefaultPri nter", objReturn)

Next

Ken

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

"Sameh Ahmed" <es******@hotma il.com> wrote in message
news:eG******** ******@TK2MSFTN GP10.phx.gbl...
Hello there
Anybody used Managementobjec t.invoke method?
if yes
how do u send method parameters?
Thanks in advance
Regards
Sameh


Nov 20 '05 #6
Hi,

Dim moReturn As Management.Mana gementObjectCol lection

Dim moSearch As Management.Mana gementObjectSea rcher

Dim mo As Management.Mana gementObject

moSearch = New Management.Mana gementObjectSea rcher("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******@hotma il.com> wrote in message
news:O1******** ******@TK2MSFTN GP09.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 ManagementObjec tSearcher
Dim queryCollection As ManagementObjec tCollection
Dim co As ConnectionOptio ns
Dim oq As System.Manageme nt.ObjectQuery
Dim ms As System.Manageme nt.ManagementSc ope
Dim mo As New ManagementObjec t
Dim path As Management.Mana gementPath
Dim strComputer, strQuery As String
strQuery = "SELECT * from Win32_process"
oq = New System.Manageme nt.ObjectQuery( strQuery)
query = New ManagementObjec tSearcher(ms, oq)
queryCollection = query.Get()
Dim i = 0
For Each mo In queryCollection

lv1.Items.Add(m o("name").ToStr ing)
lv1.Items(i).Su bItems.Add(mo(" ProcessID").ToS tring)
''''''''''''''' '''''''''
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***@bellsout h.net> wrote in message
news:uW******** ******@TK2MSFTN GP12.phx.gbl...
Hi,
Dim moReturn As Management.Mana gementObjectCol lection

Dim moSearch As Management.Mana gementObjectSea rcher

Dim mo As Management.Mana gementObject

moSearch = New Management.Mana gementObjectSea rcher("Select * from
Win32_Printer")

moReturn = moSearch.Get

For Each mo In moReturn

Dim objReturn As Object

Debug.WriteLine (mo("Name"))

mo.InvokeMethod ("SetDefaultPri nter", objReturn)

Next

Ken

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

"Sameh Ahmed" <es******@hotma il.com> wrote in message
news:eG******** ******@TK2MSFTN GP10.phx.gbl...
Hello there
Anybody used Managementobjec t.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***@bellsout h.net> wrote in message
news:uR******** ******@TK2MSFTN GP10.phx.gbl...
Hi,

Dim moReturn As Management.Mana gementObjectCol lection

Dim moSearch As Management.Mana gementObjectSea rcher

Dim mo As Management.Mana gementObject

moSearch = New Management.Mana gementObjectSea rcher("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******@hotma il.com> wrote in message
news:O1******** ******@TK2MSFTN GP09.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 ManagementObjec tSearcher
Dim queryCollection As ManagementObjec tCollection
Dim co As ConnectionOptio ns
Dim oq As System.Manageme nt.ObjectQuery
Dim ms As System.Manageme nt.ManagementSc ope
Dim mo As New ManagementObjec t
Dim path As Management.Mana gementPath
Dim strComputer, strQuery As String
strQuery = "SELECT * from Win32_process"
oq = New System.Manageme nt.ObjectQuery( strQuery)
query = New ManagementObjec tSearcher(ms, oq)
queryCollection = query.Get()
Dim i = 0
For Each mo In queryCollection

lv1.Items.Add(m o("name").ToStr ing)
lv1.Items(i).Su bItems.Add(mo(" ProcessID").ToS tring)
''''''''''''''' '''''''''
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***@bellsout h.net> wrote in message
news:uW******** ******@TK2MSFTN GP12.phx.gbl...
Hi,
Dim moReturn As Management.Mana gementObjectCol lection

Dim moSearch As Management.Mana gementObjectSea rcher

Dim mo As Management.Mana gementObject

moSearch = New Management.Mana gementObjectSea rcher("Select * from
Win32_Printer")

moReturn = moSearch.Get

For Each mo In moReturn

Dim objReturn As Object

Debug.WriteLine (mo("Name"))

mo.InvokeMethod ("SetDefaultPri nter", objReturn)

Next

Ken

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

"Sameh Ahmed" <es******@hotma il.com> wrote in message
news:eG******** ******@TK2MSFTN GP10.phx.gbl...
> Hello there
> Anybody used Managementobjec t.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
1350
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 class... what if i don't even know the class...
2
2207
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() { ... log4net.Debug("something to log"); ...
2
11400
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, OpenProcessToken, LookupPrivilegeValue, AdjustTokenPrivilegese, ExitWindowsEx. I am trying to avoid using any API calls if possible and to use managed code instead. I couldn't find any easy way of doing this but searching the Internet with...
4
1537
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 different for each class passed in. I've been using InvokeMethod to do this and it works, but, it's TOO slow. I've used the "eval" method in Jscript to do this sort of thing and it doesn't seem to be as slow.
6
768
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
1475
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 (Type.InvokeMethod) is used to dynamically invoke a "command-object" in a list. The list of objects are created when server is started (in UI-thread). Each entry in the command list stores a Type reference, an object reference and the method name.
1
1603
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: MyObj.setSolConnection(ref ADOConn) Because clients may have different versions of our app though, I need to adjust to using late binding. Originally I was getting unknown name type exceptions, but if I InvokeMember on SolConnection instead of...
0
8457
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8365
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8883
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8563
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8646
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7390
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6203
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4200
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2776
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.