![]() |
#1 |
Junior Member
Join Date: Jul 2009
Posts: 36
|
WMI via System plugin - query BIOS serial number
The following code demonstrates the usage of the Windows Management Instrumentation (WMI) only via the System plugin.
The sample code displays the BIOS serial number in a message box. I have not yet tried to remotely access computers via this script. Furthermore I left out a call to the CoSetProxyBlanket function because it seems that is is not needed for querying the BIOS serial number. PHP Code:
|
![]() |
![]() |
![]() |
#2 |
Major Dude
Join Date: Feb 2007
Posts: 672
|
Wow, this is a very good example of how to use the System plugin.
Anyhow, you could have used the WMIInspector plugin to get the same result code: |
![]() |
![]() |
![]() |
#3 |
Junior Member
Join Date: Jul 2009
Posts: 36
|
The WMIInspector plugin is fine as well.
The advantage of the System plugin is that it is shipped with NSIS. Somehow a backslash (\) got lost in the call to IWbemLocator->ConnectServer. It should be: PHP Code:
|
![]() |
![]() |
![]() |
#4 |
Junior Member
Join Date: Jul 2009
Posts: 36
|
The disadvantage of the System plugin is that you need to be very careful with allocating and freeing memory.
So here comes a new version which frees the previously allocated memory for the variant. PHP Code:
|
![]() |
![]() |
![]() |
#5 | |
Senior Member
Join Date: Nov 2012
Posts: 165
|
In Windows 7, the above code - does not work ...
Quote:
And how can you get other options WMI ? |
|
![]() |
![]() |
![]() |
#6 |
Moderator
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,358
|
WBEM_E_INVALID_NAMESPACE 0x8004100E
Have you tried a different Windows 7 machine? See also: http://blogs.technet.com/b/askperf/a...wmi-class.aspx IntOp $PostCount $PostCount + 1 |
![]() |
![]() |
![]() |
#7 |
Senior Member
Join Date: Nov 2012
Posts: 165
|
Anders
I tested this code on Windows 7 Pro x32 RUS and Windows 7 Pro x64 RUS. The result - the same, that is, It does not work ... |
![]() |
![]() |
![]() |
#9 | |
Moderator
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,358
|
![]() Quote:
![]() The System plugin p type has been backported to 2.51 along with some of the pointer stuff in LogicLib.nsh and Util.nsh so it should be possible to write portable system plugin code now that targets x86-ansi (v2.51 and v3.x), x86-unicode and amd64-unicode without too much pain... Use: !if "${NSIS_PTR_SIZE}" > 4 ; for 64-bit specific stuff and !if "${NSIS_CHAR_SIZE}" > 1 for Unicode. IntOp $PostCount $PostCount + 1 |
|
![]() |
![]() |
![]() |
|
Tags |
bios, plug-in, system.plug-in, wmi |
Thread Tools | Search this Thread |
Display Modes | |
|
|