Page 2 of 2

Re: Nagios captures only a single line output from VB script

Posted: Fri Nov 10, 2017 1:34 pm
by rifelixd
[/settings/NSCA/client/targets/default]
payload length = 4096

@mcapra, Thank you for sharing on payload length. Now that I have added 4096 on the client side, I am getting all listed software versions.

@npolovenko, I still have an issue :(. This seems to be pulling the 32-bit applications only. Is there something I am missing to retrieve the 64-bit applications as well ?

Re: Nagios captures only a single line output from VB script

Posted: Fri Nov 10, 2017 1:46 pm
by npolovenko
@rifelixd, Glad I could help! Keep us updated.

Re: Nagios captures only a single line output from VB script

Posted: Fri Nov 10, 2017 3:10 pm
by mcapra
I'd double check the namespace. I'm not 100% sure if Win32_Product would include 64bit apps by default. This TechNet article has some logic in it regarding the OS architecture, unsure of it's related and can't test since I'm on mobile

https://gallery.technet.microsoft.com/s ... d-70d0c0f4

Re: Nagios captures only a single line output from VB script

Posted: Fri Nov 10, 2017 3:53 pm
by kyang
Thanks @mcapra,

@rifelixd, Let us know how it goes!

Re: Nagios captures only a single line output from VB script

Posted: Sat Nov 18, 2017 11:03 pm
by rifelixd
@npolovenko @mcapra,

I have finally managed to pull the the required software. If I am using WMI class, some software were missing. I have then tried to pull from registry but then some software which being pulled from WMI are not listed. Therefore I have just combined both and managed to pull all needed software versions. I am attaching the script here.

Code: Select all

const HKEY_LOCAL_MACHINE = &H80000002
Dim strComputer, strKeyPath
Dim Name, Version, Publisher
Dim objReg, strSubkey, arrSubkeys
Dim myString

strComputer = "."

' WMI class search for installed programs
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\cimv2")
Set colSoftware = objWMIService.ExecQuery _
("Select * from Win32_Product where Vendor <> 'Microsoft Corporation'")

' Registry key path of Control panel items for installed programs
strKeyPath = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\" 

Set objReg=GetObject( _ 
    "winmgmts:{impersonationLevel=impersonate}!\\" & _
   strComputer & "\root\default:StdRegProv")

objReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubkeys 

'Enumerate registry keys 
For Each strSubkey In arrSubkeys 
	objReg.GetStringValue HKEY_LOCAL_MACHINE, strKeyPath & strSubkey, "DisplayName" , Name
	If Name <> "" Then 
		objReg.GetStringValue HKEY_LOCAL_MACHINE, strKeyPath & strSubkey, "DisplayVersion" , Version
		objReg.GetStringValue HKEY_LOCAL_MACHINE, strKeyPath & strSubkey, "Publisher" , Publisher
		myString = myString & "Name= " 
		myString = myString & Name 
		myString = myString & ", Version= " 
		myString = myString & Version 
		myString = myString & ", Publisher= " 
		myString = myString & Publisher
		myString = myString & vbCr
	End If 
Next

For Each objSoftware in colSoftware
myString = myString & "Name= " 
myString = myString & objSoftware.Name 
myString = myString & ", Version= " 
myString = myString & objSoftware.Version
myString = myString & ", Vendor= " 
myString = myString & objSoftware.Vendor
myString = myString & vbCr
Next
WScript.Echo myString
Thank you so much to both of you.

Re: Nagios captures only a single line output from VB script

Posted: Mon Nov 20, 2017 10:03 am
by kyang
Sounds good! Thanks for sharing! I'll be closing this thread.

If you have any more questions, feel free to create another thread.

Thanks for using the Nagios Support Forum!