what's available in WMI

C

cj

I found this code online and it works fine but I don't understand
exactly how and am trying to. Can someone help me?

Public Class Form1
Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim t As Single
Dim WMIService, Computer As Object
WMIService =
GetObject("Winmgmts:{impersonationLevel=impersonate,(Debug,Shutdown)}")
For Each Computer In
WMIService.InstancesOf("Win32_OperatingSystem")
t = Computer.Win32Shutdown(8 + 4, 0)
If t <> 0 Then
MsgBox("Error")
End If
Next
End Sub

#1 GetObject requires a file name or a class. As winmgmts is not a
file on my computer I assume it is a class. How can I view it? I
understand the impersonationlevel but not the debug, shutdown.

#2 when it says for each computer in WMIService.InstancesOf
("Win32_OperatingSystem") what other things can I get to instead of
win32_operating sytem? Where or how can I find out my other options?
 
C

cj

Been there done that. I can see the examples but beyond them is dark.
What else exists? How can I find out? Since that is VB script it
doesn't address the {impersonationlevel=impersonate, (debug, shutdown)}.
It doesn't even address Win32_OperatingSystem. But it does tell me
Win32_Service, Win32_Process, Win32_LogicalMemoryConfiguration and
Win32_NTLogEvent exist. I have to figure there are more. How can I
find out what they are and what they do? I ran those examples and if
they tell me I'm too dumb to understand. I also looked at WMI Scripting
Primer: parts 2 and 3 and still no help.
 
P

Peter Proost

If your going to use wmi, wbemtest is a very handy
tool that comes with windows to find out what info you can get from cimv2
(all the win32 classes are listed there).
So I would also do some reading on wbemtest.

If you want I can send you and example app that uses wmi to get all sort of
pc info which I made a couple of months ago

you can mail me @ pproost at the google mail name (gmail.com)
 
C

cj

Hi Peter, actually I tried wbemtest yesterday. Way too many buttons.
Connection? Credentials? Locale? Then Enum Classes or instances or
namespaces? Classes I guess. Superclass name????? Whew! Method
Invocation Options????? I gave up to look for something that made more
sense to me. I found Scriptomatic today on a Microsoft web site but it
seems to show only settings and not methods.

I've been looking at

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/wmi_reference.asp
http://msdn.microsoft.com/library/d...en-us/wmisdk/wmi/operating_system_classes.asp
http://msdn.microsoft.com/library/d...ry/en-us/wmisdk/wmi/win32_operatingsystem.asp

for an hour or two now and while I find microsoft sites very confusing
I'm making headway. I can't seem to find the organization between the
pages and the pane on the left never seems to follow along as I click
links. But the stuff I'm looking for is in here somewhere. I have to
bookmark anything that looks interesting or I might not be able to find
it again.
 
C

cj

If they did I didn't get it. I know they mentioned it but I don't think
they explained it--well at least they didn't enough for me.

Yea, the scriptomatic tool is pretty good.

I think I'm ok for now. I appreciate the help Mike and Peter.
 
C

Cor Ligthert [MVP]

cj,

Why don't you than not accept Peters offer to sent the program he made. I
think that most of us made such a kind of program. The one of my is to old
and probably to clumsy to make the same offer as Peter.

Remember for WMI that is is just a bunch of collections holding collections
which can hold collections again. If something does not exist can be because
the hard or software is just not giving the information that is needed
because it does not exist. Let say by instance a mainboard serial number.

I hope this helps,

Cor
 

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