'--------------------------------------------------------------------------------- ' Script to check whether VMware Tools is installed or not. ' Status is OK if VMware Tools is installed, and CRITICAL if not. ' If VMware Tools is installed, Nagios will also display the product version. '--------------------------------------------------------------------------------- Option Explicit Const HKLM = &H80000002 'HKEY_LOCAL_MACHINE Dim strComputer, strKey, CurrentDirectory, Filepath strComputer = "." strKey = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\" 'Get script current folder CurrentDirectory = left(WScript.ScriptFullName,(Len(WScript.ScriptFullName))-(len(WScript.ScriptName))) 'Set result file path Filepath = "C:\Windows\Temp\InstalledSoftware.txt" Dim FSO, TextFile, objReg, strSubkey, arrSubkeys 'Create filesystem object Set FSO = CreateObject("scripting.FileSystemObject") 'Create new text file Set TextFile = FSO.CreateTextFile(Filepath) 'Get WMI object Set objReg = GetObject("winmgmts://" & strComputer & "/root/default:StdRegProv") objReg.EnumKey HKLM, strKey, arrSubkeys Textfile.WriteLine "Installed Applications: " Textfile.WriteLine 'Loop registry key. Dim DisplayName,DisplayVersion, InstallDate, EstimatedSize, UninstallString, objFSO, ToolsVersion For Each strSubkey In arrSubkeys objReg.GetStringValue HKLM, strKey & strSubkey, "DisplayName" , DisplayName If DisplayName <> "" Then Textfile.WriteLine "Display Name : " & DisplayName objReg.GetStringValue HKLM, strKey & strSubkey, "DisplayVersion" , DisplayVersion Textfile.WriteLine "Version : " & DisplayVersion objReg.GetStringValue HKLM, strKey & strSubkey, "InstallDate", InstallDate Textfile.WriteLine "InstallDate : " & InstallDate Textfile.Writeline End If Next TextFile.Close 'Search the list for VMware Tools Dim FoundIt 'as boolean FoundIt=false 'set the boolean to false With createobject("Scripting.FileSystemObject") on error resume next FoundIt = (InStr(1,.OpenTextFile("C:\Windows\Temp\InstalledSoftware.txt",1,true,-2).ReadAll,"VMware Tools",1) <> 0) on error goto 0 End With 'If VMware Tools is found, also show the product version. If FoundIt Then Set objFSO = CreateObject("Scripting.FileSystemObject") ToolsVersion = objFSO.GetFileVersion("C:\Program Files\VMware\VMware Tools\vmtoolsd.exe") wscript.echo("VMware Tools is installed. The version is " & ToolsVersion) wscript.Quit(0) Else wscript.echo("VMware Tools is NOT installed.") wscript.Quit(2) End If