- NSIS Discussion
- WMI plug-in
Archive: WMI plug-in
l0k1
30th April 2008 15:14 UTC
WMI plug-in
Attached plugin supports wmi request from MS API call.
I have included script sample.
For now it can retrieve :
* OS Name
* OS Version
* AntiVirus Name
* FireWall Name
* CPU Name
* Desktop resolution
* Any information if you provide correct parameters
Any suggestion are welcomed.
More info could be found at the NSIS Wiki plugin page
http://nsis.sourceforge.net/WmiInspector_plug-in
l0k1
6th May 2008 14:59 UTC
I've just added
* SQL Version
l0k1
6th May 2008 15:02 UTC
Forgot to join file :o
l0k1
31st July 2008 14:30 UTC
Added :
*UserName
*ShortUserName
*UserSID
to retrieve user name and SID from registry.
southcot
27th April 2009 07:09 UTC
I'm very much a newbie to NSIS. I have two questions regarding this plugin:-
1
I can't get the examples to work I get an error:-
"WmiInspector::Request"
I am guessing that it is something to do with where I place the plugin files which I assume are WmiInspector.vcproj, WmiInspector.cpp and WmiInspector.sln? Can anyone advise?
2
The WMI call I want to replicate in NSIS is contained in the following:-
Set objWMISvc = GetObject( "winmgmts:\\" & strComputerName & "\root\cimv2" )
Set colItems = objWMISvc.ExecQuery( "Select * from Win32_ComputerSystem", , 48 )
For Each objItem in colItems
strComputerDomain = objItem.Domain
If objItem.PartOfDomain Then
WScript.Echo "Computer Domain: " & strComputerDomain
Else
WScript.Echo "Workgroup: " & strComputerDomain
End If
Next
I am unsure how to go about this and would be grateful for some pointers.
Charlie
Afrow UK
27th April 2009 13:07 UTC
Those files you mention are for the source code. You just need to put the DLL file in the NSIS\Plugins folder
Stu
southcot
27th April 2009 13:41 UTC
Thanks for the speedy response. I open the zip at http://nsis.sourceforge.net/WmiInspector_plug-in and the only files there are:-
TestWmiInspector.exe
TestWmiInspector..nsi
WmiInspector.cpp
WmiInspector.vcproj
WmiInspector.sln
No DLL. Same for the files attached to this message.
Charlie
Afrow UK
27th April 2009 14:10 UTC
Looks like l0k1 forgot to put the actual plugin in the Zip!
Stu
southcot
27th April 2009 15:05 UTC
So I'm not going mad after all then :)
southcot
27th April 2009 15:12 UTC
Is there a way of tracking it down?
Afrow UK
27th April 2009 15:51 UTC
You will need to build the plugin yourself using Visual Studio. If you are using Windows XP or 2000 you can build with Visual Studio Express Editions C++ 2008 and the Windows Server 2003 PSDK.
http://www.microsoft.com/Express/
http://www.microsoft.com/downloads/d...displaylang=en
I cannot build for you as I am running Windows Vista (I can only install the Windows Server 2008 PSDK).
Stu
southcot
28th April 2009 06:35 UTC
Hmm uncharted territory for me but I'll give it a go. The blurb on http://www.microsoft.com/Express/ tells me I also need the Microsoft MSDN Express Library. Presumably that's correct. Could you give me pointers what I do when I have these all installed?
Charlie
sgiusto
28th April 2009 11:37 UTC
Hello,
the .zip file CONTAINS the .dll
Please double check that you don't have it.
Regards
Stefano
southcot
28th April 2009 11:42 UTC
Nope when I click on any of the zips I just get the five files listed:-
TestWmiInspector.exe
TestWmiInspector..nsi
WmiInspector.cpp
WmiInspector.vcproj
WmiInspector.sln
What URL are you using?
southcot
28th April 2009 11:44 UTC
Hang on I have just cleared my cache and the second link on this thread does indeed now show the DLL Grrrrrrrrrrrrrrrrrrrr.
Afrow UK
28th April 2009 11:57 UTC
The file on the Wiki does not contain the dll.
Stu
southcot
28th April 2009 12:12 UTC
That would fit with the cache problem I hit as it was the first one I opened.
southcot
6th May 2009 18:07 UTC
I am trying to capture the domain or the computer using:-
WmiInspector::Request "CIMV2" "Win32_OperatingSystem" "Domain"
gives me an error whereas:-
WmiInspector::Request "CIMV2" "Win32_OperatingSystem" "Caption"
works fine yet both values are stings. Am I missing something here?
Also how do I recover a boolean value - in particular the WMI value "PartOfDomain"
Can anyone give me some pointers?
Charlie
Afrow UK
6th May 2009 21:36 UTC
Domain and PartOfDomain are not in Win32_OperatingSystem; they are in Win32_ComputerSystem.
Stu
southcot
7th May 2009 07:41 UTC
Aha so often the answer to something that has bugged me for days proves to be frustatingly simple. Thanks for the help on all of this.
lamprizzle
28th September 2009 20:01 UTC
wmi calls returning arrays
Hey l0k1, I noticed the plugin doesn't support any WMI calls that return an array of ints...
WmiInspector::Request "CIMV2" "Win32_SystemEnclosure" "ChassisTypes"
; see http://msdn.microsoft.com/en-us/library/aa394474(VS.85).aspx
Internally, I need to handle the case where var.vt is VT_ARRAY|VT_I4, but I haven't figured that out yet. Have you?
kriiC
16th January 2010 10:24 UTC
how can i read all values (not just one) from request? How can i add loop to walk throw all values?
---
And there is problem with Unicode NSIS. i compiled with ANSI NSIS and its ok, Unicode NSIS gives me request return in chinese ot smth
dougcvc
19th September 2010 20:12 UTC
Wmi
Im not sure if its possible to read through all results using this plug in but i created a macro based on the wmic command that reads through all results.
Download WMI.nsh attached to this post and see the following file as an example:
Name WMI
OutFile WMI.exe
RequestExecutionLevel Admin
OutFile "fileread.exe"
!include WMI.nsh
!include LogicLib.nsh
Section ""
${GetWMI} root\CIMV2 Win32_DiskDrive model callback_Function
${GetWMI} root\CIMV2 Win32_NetworkAdapter name callback_Function
${GetWMI} root\CIMV2 Win32_UserAccount name callback_Function
SectionEnd
Function callback_Function
#$R0 = result number, $R1 = total results, $R2 = result name
detailprint "$R0/$R1=$R2"
FunctionEnd
Usage ${GetWMI} namespace classes property callback_Function
In the callback function results are $R0 = result number, $R1 = total results, $R2 = Result name.
Theres a WMI code creator tool which is useful for finding out the namespaces, classes , and properties which can be downloaded here
http://www.microsoft.com/downloads/e...displaylang=en
Afrow UK
20th September 2010 18:14 UTC
Please make a Wiki page. Also I would recommend wrapping your header in:
!ifndef __WMI_Included__
!define __WMI_Included__
...
!endif
Stu
dougcvc
28th September 2010 19:27 UTC
created a wiki page here.