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
WMI plug-in
25 posts
I've just added
* SQL Version
* SQL Version
Forgot to join file 😳
Added :
*UserName
*ShortUserName
*UserSID
to retrieve user name and SID from registry.
*UserName
*ShortUserName
*UserSID
to retrieve user name and SID from registry.
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:-
Charlie
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:-
I am unsure how to go about this and would be grateful for some pointers.
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
Charlie
Those files you mention are for the source code. You just need to put the DLL file in the NSIS\Plugins folder
Stu
Stu
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
TestWmiInspector.exe
TestWmiInspector..nsi
WmiInspector.cpp
WmiInspector.vcproj
WmiInspector.sln
No DLL. Same for the files attached to this message.
Charlie
Looks like l0k1 forgot to put the actual plugin in the Zip!
Stu
Stu
So I'm not going mad after all then 🙂
Is there a way of tracking it down?
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/
I cannot build for you as I am running Windows Vista (I can only install the Windows Server 2008 PSDK).
Stu
http://www.microsoft.com/Express/
download, software, update, Microsoft, product, computer, PC, Windows, Office, server, MSN, Live, game, Xbox, security, driver, install, trial, preview, demo, popular
I cannot build for you as I am running Windows Vista (I can only install the Windows Server 2008 PSDK).
Stu
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
Charlie
Hello,
the .zip file CONTAINS the .dll
Please double check that you don't have it.
Regards
Stefano
the .zip file CONTAINS the .dll
Please double check that you don't have it.
Regards
Stefano
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?
TestWmiInspector.exe
TestWmiInspector..nsi
WmiInspector.cpp
WmiInspector.vcproj
WmiInspector.sln
What URL are you using?
Hang on I have just cleared my cache and the second link on this thread does indeed now show the DLL Grrrrrrrrrrrrrrrrrrrr.
The file on the Wiki does not contain the dll.
Stu
Stu
That would fit with the cache problem I hit as it was the first one I opened.
I am trying to capture the domain or the computer using:-
Also how do I recover a boolean value - in particular the WMI value "PartOfDomain"
Can anyone give me some pointers?
Charlie
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
Domain and PartOfDomain are not in Win32_OperatingSystem; they are in Win32_ComputerSystem.
Stu
Stu
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.
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?
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?
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
---
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
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:
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
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:
Usage ${GetWMI} namespace classes property callback_Function
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
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
Please make a Wiki page. Also I would recommend wrapping your header in:
!ifndef __WMI_Included__
!define __WMI_Included__
...
!endif
Stu
!ifndef __WMI_Included__
!define __WMI_Included__
...
!endif
Stu
created a wiki page here.