WmiInspector plug-in: Difference between revisions

From NSIS Wiki
Jump to navigationJump to search
No edit summary
No edit summary
Line 8: Line 8:


This plugin sends request to the system using MS WMI API and returns the value on the stack.
This plugin sends request to the system using MS WMI API and returns the value on the stack.
Plugin first returns "OK" if successfull, "error" if failed then the requested value or the error description.
''Rem: An empty string might be returned as a result for the requested value. This doesn't mean that an error occurs but that there's not information for this value. See Antivirus exemple.''


== Command line ==
== Command line ==
Line 19: Line 22:
</highlight-nsis>
</highlight-nsis>


This call returns "OK" string and value if successful, "error" and error description string if failed.
If successful, this call returns "OK" string and value, "error" and error description string otherwise.


=== OS DLL Function ===
=== OS DLL Function ===
Line 27: Line 30:
</highlight-nsis>
</highlight-nsis>


This call returns "OK" string and OS caption if successful, "error" and error description string if failed.
If successful, this call returns "OK" string and OS caption, "error" and error description string otherwise.
 
This function is equivalent to '''''WmiInspector::Request "CIMV2" "Win32_OperatingSystem" "Caption"'''''.
This function is equivalent to '''''WmiInspector::Request "CIMV2" "Win32_OperatingSystem" "Caption"'''''.


Line 36: Line 40:
</highlight-nsis>
</highlight-nsis>


This call returns "OK" string and OS version number if successful, "error" and error description string if failed.
If successful, this call returns "OK" string and OS version number, "error" and error description string otherwise.
 
This function is equivalent to '''''WmiInspector::Request "CIMV2" "Win32_OperatingSystem" "Version"'''''.
This function is equivalent to '''''WmiInspector::Request "CIMV2" "Win32_OperatingSystem" "Version"'''''.


Line 56: Line 61:


If successful, this call returns "OK" string and installed antivirus name, "error" and error description string otherwise.
If successful, this call returns "OK" string and installed antivirus name, "error" and error description string otherwise.
This function is equivalent to '''''WmiInspector::Request "SecurityCenter" "AntiVirusProduct" "DisplayName"'''''.
This function is equivalent to '''''WmiInspector::Request "SecurityCenter" "AntiVirusProduct" "DisplayName"'''''.


Line 65: Line 71:


If successful, this call returns "OK" string and installed firewallname, "error" and error description string otherwise.
If successful, this call returns "OK" string and installed firewallname, "error" and error description string otherwise.
This function is equivalent to '''''WmiInspector::Request "SecurityCenter" "FirewallProduct" "DisplayName"'''''.
This function is equivalent to '''''WmiInspector::Request "SecurityCenter" "FirewallProduct" "DisplayName"'''''.


Line 74: Line 81:


If successful, this call returns "OK" string and CPU name, "error" and error description string otherwise.
If successful, this call returns "OK" string and CPU name, "error" and error description string otherwise.
This function is equivalent to '''''WmiInspector::Request "CIMV2" "Win32_Processor" "Caption"'''''.
This function is equivalent to '''''WmiInspector::Request "CIMV2" "Win32_Processor" "Caption"'''''.


Line 89: Line 97:


<highlight-nsis>
<highlight-nsis>
;Show OS name
START:
START:
     WmiInspector::Request "CIMV2" "Win32_OperatingSystem" "Caption"
     WmiInspector::Request "CIMV2" "Win32_OperatingSystem" "Caption"
Line 103: Line 112:
</highlight-nsis>
</highlight-nsis>


== Credits ==
<highlight-nsis>
;Show Antivirus name
START:
    WmiInspector::AntiVirus
    Pop $0
    StrCmp $0 "ok" SHOWVALUE SHOWERROR
SHOWVALUE:
    Pop $1
    StrCmp $1 "" SHOWAVNAME NOAV
SHOWAVNAME:
    MessageBox MB_OK "Antivirus detected: $1"
    GoTo END
NOAV:
    MessageBox MB_OK "No antivirus found."
    GoTo END
SHOWERROR:
    Pop $1
    MessageBox MB_OK "Error: $1"
END:
 
</highlight-nsis>
 


[[Category:Plugins]]
[[Category:Plugins]]

Revision as of 13:54, 30 April 2008

Work in progress...

Links

Download:

Description

This plugin sends request to the system using MS WMI API and returns the value on the stack. Plugin first returns "OK" if successfull, "error" if failed then the requested value or the error description.

Rem: An empty string might be returned as a result for the requested value. This doesn't mean that an error occurs but that there's not information for this value. See Antivirus exemple.

Command line

Plug-in DLL functions (entry points): Request, OS, OSVersion, FullOS, AntiVirus, FireWall, CPU, Resolution

Request DLL Function

WmiInspector::Request DomainName TableName ValueName

If successful, this call returns "OK" string and value, "error" and error description string otherwise.

OS DLL Function

WmiInspector::OS

If successful, this call returns "OK" string and OS caption, "error" and error description string otherwise.

This function is equivalent to WmiInspector::Request "CIMV2" "Win32_OperatingSystem" "Caption".

OSVersion DLL Function

WmiInspector::OSVersion

If successful, this call returns "OK" string and OS version number, "error" and error description string otherwise.

This function is equivalent to WmiInspector::Request "CIMV2" "Win32_OperatingSystem" "Version".

FullOS DLL Function

WmiInspector::FullOS

If successful, this call returns "OK" string and full OS informations (including version number and service pack), "error" and error description string otherwise.

This function is a combination of several WmiInspector::Request "CIMV2" "Win32_OperatingSystem" "Xxx" calls.

AntiVirus DLL Function

WmiInspector::AntiVirus

If successful, this call returns "OK" string and installed antivirus name, "error" and error description string otherwise.

This function is equivalent to WmiInspector::Request "SecurityCenter" "AntiVirusProduct" "DisplayName".

FireWall DLL Function

WmiInspector::FireWall

If successful, this call returns "OK" string and installed firewallname, "error" and error description string otherwise.

This function is equivalent to WmiInspector::Request "SecurityCenter" "FirewallProduct" "DisplayName".

CPU DLL Function

WmiInspector::CPU

If successful, this call returns "OK" string and CPU name, "error" and error description string otherwise.

This function is equivalent to WmiInspector::Request "CIMV2" "Win32_Processor" "Caption".

Resolution DLL Function

WmiInspector::Resolution

If successful, this call returns "OK" string and desktop resolution, "error" and error description string otherwise.

This function is a combination of several WmiInspector::Request "CIMV2" "Win32_Win32_DesktopMonitor" "Xxx" calls.

Examples

;Show OS name
START:
     WmiInspector::Request "CIMV2" "Win32_OperatingSystem" "Caption"
     Pop $0
     StrCmp $0 "ok" SHOWVALUE SHOWERROR
SHOWVALUE:
     Pop $1
     MessageBox MB_OK "Value: $1"
     GoTo END
SHOWERROR:
     Pop $1
     MessageBox MB_OK "Error: $1"
END:
;Show Antivirus name
START:
     WmiInspector::AntiVirus
     Pop $0
     StrCmp $0 "ok" SHOWVALUE SHOWERROR
SHOWVALUE:
     Pop $1
     StrCmp $1 "" SHOWAVNAME NOAV
SHOWAVNAME:
     MessageBox MB_OK "Antivirus detected: $1"
     GoTo END
NOAV:
     MessageBox MB_OK "No antivirus found."
     GoTo END
SHOWERROR:
     Pop $1
     MessageBox MB_OK "Error: $1"
END: