Old 30th April 2008, 14:14   #1
l0k1
Junior Member
 
Join Date: Oct 2007
Posts: 24
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
Attached Files
File Type: zip wmiinspector.zip (38.2 KB, 594 views)

Last edited by l0k1; 30th April 2008 at 15:40.
l0k1 is offline   Reply With Quote
Old 6th May 2008, 13:59   #2
l0k1
Junior Member
 
Join Date: Oct 2007
Posts: 24
I've just added

* SQL Version
l0k1 is offline   Reply With Quote
Old 6th May 2008, 14:02   #3
l0k1
Junior Member
 
Join Date: Oct 2007
Posts: 24
Forgot to join file
Attached Files
File Type: zip wmiinspector.zip (124.4 KB, 785 views)
l0k1 is offline   Reply With Quote
Old 31st July 2008, 13:30   #4
l0k1
Junior Member
 
Join Date: Oct 2007
Posts: 24
Thumbs up

Added :

*UserName
*ShortUserName
*UserSID

to retrieve user name and SID from registry.
l0k1 is offline   Reply With Quote
Old 27th April 2009, 06:09   #5
southcot
Junior Member
 
Join Date: Apr 2009
Posts: 23
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:-
code:

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
southcot is offline   Reply With Quote
Old 27th April 2009, 12:07   #6
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
Those files you mention are for the source code. You just need to put the DLL file in the NSIS\Plugins folder

Stu
Afrow UK is offline   Reply With Quote
Old 27th April 2009, 12:41   #7
southcot
Junior Member
 
Join Date: Apr 2009
Posts: 23
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
southcot is offline   Reply With Quote
Old 27th April 2009, 13:10   #8
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
Looks like l0k1 forgot to put the actual plugin in the Zip!

Stu
Afrow UK is offline   Reply With Quote
Old 27th April 2009, 14:05   #9
southcot
Junior Member
 
Join Date: Apr 2009
Posts: 23
So I'm not going mad after all then
southcot is offline   Reply With Quote
Old 27th April 2009, 14:12   #10
southcot
Junior Member
 
Join Date: Apr 2009
Posts: 23
Is there a way of tracking it down?
southcot is offline   Reply With Quote
Old 27th April 2009, 14:51   #11
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
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
Afrow UK is offline   Reply With Quote
Old 28th April 2009, 05:35   #12
southcot
Junior Member
 
Join Date: Apr 2009
Posts: 23
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
southcot is offline   Reply With Quote
Old 28th April 2009, 10:37   #13
sgiusto
Member
 
Join Date: Mar 2007
Location: Italy
Posts: 99
Hello,
the .zip file CONTAINS the .dll
Please double check that you don't have it.
Regards
Stefano
sgiusto is offline   Reply With Quote
Old 28th April 2009, 10:42   #14
southcot
Junior Member
 
Join Date: Apr 2009
Posts: 23
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 is offline   Reply With Quote
Old 28th April 2009, 10:44   #15
southcot
Junior Member
 
Join Date: Apr 2009
Posts: 23
Hang on I have just cleared my cache and the second link on this thread does indeed now show the DLL Grrrrrrrrrrrrrrrrrrrr.
southcot is offline   Reply With Quote
Old 28th April 2009, 10:57   #16
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
The file on the Wiki does not contain the dll.

Stu
Afrow UK is offline   Reply With Quote
Old 28th April 2009, 11:12   #17
southcot
Junior Member
 
Join Date: Apr 2009
Posts: 23
That would fit with the cache problem I hit as it was the first one I opened.
southcot is offline   Reply With Quote
Old 6th May 2009, 17:07   #18
southcot
Junior Member
 
Join Date: Apr 2009
Posts: 23
I am trying to capture the domain or the computer using:-

Quote:
WmiInspector::Request "CIMV2" "Win32_OperatingSystem" "Domain"
gives me an error whereas:-

Quote:
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
southcot is offline   Reply With Quote
Old 6th May 2009, 20:36   #19
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
Domain and PartOfDomain are not in Win32_OperatingSystem; they are in Win32_ComputerSystem.

Stu
Afrow UK is offline   Reply With Quote
Old 7th May 2009, 06:41   #20
southcot
Junior Member
 
Join Date: Apr 2009
Posts: 23
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.
southcot is offline   Reply With Quote
Old 28th September 2009, 19:01   #21
lamprizzle
Junior Member
 
Join Date: Jan 2007
Posts: 11
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?
lamprizzle is offline   Reply With Quote
Old 16th January 2010, 09:24   #22
kriiC
Junior Member
 
Join Date: Jan 2010
Posts: 1
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
kriiC is offline   Reply With Quote
Old 19th September 2010, 19:12   #23
dougcvc
Junior Member
 
Join Date: May 2009
Posts: 16
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:


code:

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
Attached Files
File Type: nsh WMI.nsh (3.5 KB, 297 views)
dougcvc is offline   Reply With Quote
Old 20th September 2010, 17:14   #24
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
Please make a Wiki page. Also I would recommend wrapping your header in:

!ifndef __WMI_Included__
!define __WMI_Included__
...
!endif

Stu
Afrow UK is offline   Reply With Quote
Old 28th September 2010, 18:27   #25
dougcvc
Junior Member
 
Join Date: May 2009
Posts: 16
created a wiki page here.
dougcvc is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump