PDA

View Full Version : WMI module: some preview vaporware



ErosOlmi
12-09-2007, 22:20
Ok, guy. I say here about "Stay tuned" (http://community.thinbasic.com/index.php?topic=1184.msg8206#msg8206).
So some preview is needed.

We were experimenting about possibility to natively add WMI to thinBasic using a dedicated module.
Please find attached to this post what we was getting so far. WMI module contains just one function called WMI_GetData with the following syntax:


TWMI_GetData(sComputername, NameSpace, UserName, Password, sClassName [, sWhere [, sFields]]) AS STRING


WMI_GetData function returns a string full of tokens separated by $CRLF that is the list of all properties found inside the specified WMI class.
Unzip into a new directory under \thinBasic\SampleScripts\WMI\ and executed the test script. Experiment changing the class name and see.

For a list of WMI classes, please have a look at http://msdn2.microsoft.com/en-us/library/aa394554.aspx Attention, it is a huge huge area so quite easy to get lost.

Please test it and report any error or whatever you can think it can be useful to the development.

Important

WMI module is experimenting
Many sub-informations are still not available
produced list contains informations not part of the actual data. Those info are visible in between { and }
WMI module is only informative, so it just read data
any help is appreciated



ADDED note:

for Win95/Win98 if module does not report any info, you need to install Windows Management Instrumentation (WMI) CORE 1.5 (Windows 95/98) or above: http://www.microsoft.com/downloads/details.aspx?FamilyID=98a4c5ba-337b-4e92-8c18-a63847760ea5&DisplayLang=en
WMI works also on the net using RPC protocol
Other reference: http://www.dmtf.org/standards/wbem


CHANGED:

2007.10.13: added namespace, username, password to function TWMI_GetData. Attached updated.

kryton9
12-09-2007, 22:51
Thanks Eros for this preview, it is a little over my head, but the example ran fine on the few tests I ran. I commented the current test and tried another by uncommenting and it seems to report back lots of information. So seems to work fine so far!

Petr Schreiber
13-09-2007, 08:43
Thanks a lot Eros,

this seems to be highly valuable tool to extract various info !


VolumeDirty=0

... uff :)

It is nice to be able to retrieve processor info without using assembly.
Is WMI only for 2000/XP ?


Thanks,
Petr

ErosOlmi
13-09-2007, 10:53
No, it is also available for Win95 and Win98 but not in native way.

See "ADDED note" in first post of this thread for info on where to download WMI for Win95/Win98 OSs.

I've personally installed it under Win98 (emulated under VMWare).
Seems no problem. During installation it takes 1 minute or so to collect data and create repository. But it can take mode depending on HW type. At the end of the instalaltion process you will have to restart you machine.
After that, thinBasic script will start to give results.


Ciao
Eros

Petr Schreiber
13-09-2007, 11:25
Great :),

thanks for the info


Petr

ErosOlmi
13-09-2007, 11:45
Also remember that WMI works also on the lan, so just indicate the name of anohter computer in your lan and you will get remote info (if your authorization level permits)

ErosOlmi
19-09-2007, 13:10
Last update of experimental WMI module before release in next preview.
Module file and example has been updated in first post of this thread.
_________________________________________________
What have been changed. New syntax of TWMI_GetData is the following:



sBuffer = WMI_GetData(sComputername, "", "", "", sClassName [, sWhere [, sFields]])


sWhere: can be used to add more selection in class names items
sFields: can be used to insidate to return only few info items from the class.

Some usage examples:


'---This will return only Name and Size of logical disk whose DevideID is called C:
sBuffer = WMI_GetData(ComputerName, "", "", "", "CIM_LogicalDisk", "DeviceID = 'C:'", "Name, Size" )

'---This will return only the command line of the startup command info
sBuffer = WMI_GetData(ComputerName, "", "", "", "Win32_StartupCommand", "", "Command" )


Note that even if you specify some specific field names, some additional info are returned by the engine. I'm investigating the reasons.
See example included in zipped file.

Regards
Eros

mhillmer
11-10-2007, 22:19
Any way to pass credentials to authenticate with this if your current security level doesn't allow access? (like the WMIC.EXE command line WMI tool allows you to specify a /USER and /PASSWORD)?

Thanks
Matt

ErosOlmi
12-10-2007, 10:40
I will check in the week-end what I can do on this.

Ciao
Eros

ErosOlmi
13-10-2007, 08:21
Matt,

see first post in this thread.
I've updated attached example and module adding: NameSpace, UserName, Password. I've not tested it because I'm at home and I have no domain here but should work.

New syntax of TWMI_GetData is the following:



sBuffer = WMI_GetData(sComputername, NameSpace, UserName, Password, sClassName [, sWhere [, sFields]])



NameSpace: name of the namespace that provides support for the needed class
UserName: better to specify it in the form "domain\user"
Password: ok, password of the specified user

Leave all those fields blank when connecting to local computer.

Let me know.
Eros

mhillmer
15-10-2007, 16:33
Cool, that works great! Thanks!