sdpondemand.manageengine.com Open in urlscan Pro
136.143.190.55  Public Scan

URL: https://sdpondemand.manageengine.com/scanscript/ae_scan.vbs
Submission: On December 04 via api from DE — Scanned from DE

Form analysis 0 forms found in the DOM

Text Content

'********** DO NOT MODIFY ANY CODE BELOW THIS **********
protocol="http"

'Script Mode Details
'===================
isAgentMode=false
agentTaskID="NO_AGENT_TASK_ID"
if(WScript.Arguments.Count>0) Then
	isAgentMode = true
	agentTaskID=WScript.Arguments(0)
end if

islocalScan=true
Dim remoteUser 
Dim remotePassword
strComputer="."
serviceTag=""
nodeName=""
macAddress=""

if(WScript.Arguments.Count>3) Then
	strComputer=WScript.Arguments(1)
 	remoteUser = WScript.Arguments(2)
	remotePassword=WScript.Arguments(3)
	Set objNTInfo = CreateObject("WinNTSystemInfo")
	GetComputerName = lcase(objNTInfo.ComputerName)
	fqdnName = getFQDN(GetComputerName)
    if(strComputer <> GetComputerName and strComputer <> fqdnName) Then
		islocalScan=false
	else
		islocalScan=true
	end if
end if


'Save Settings File Configuration
'================================
saveXMLFile=false
computerNameForFile="NO_COMPUTER_NAME"

'XML Version/Encoding Information
'================================
xmlVersion="1.0"
xmlEncoding="UTF-8"

strComputer = "."
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set objWMIService2 = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\wmi")

set adobeSoftHavingLicKeys = CreateObject("Scripting.Dictionary")

const HKEY_LOCAL_MACHINE = &H80000002
Const HKEY_CURRENT_USER = &H80000001
const HKEY_USERS = &H80000003

const doubleQuote=""""
const backSlash="\"
newLineConst = VBCrLf
spaceString = " "
equalString = "=" 
supportMailID="support@servicedeskplus.com"

xmlInfoString = "<?xml"
xmlInfoString = addCategoryData(xmlInfoString, "version",xmlVersion)
xmlInfoString = addCategoryData(xmlInfoString, "encoding",xmlEncoding)
xmlInfoString = xmlInfoString & "?>"

outputText = xmlInfoString & newLineConst
outputText = outputText &  "<DocRoot> NODE_TAG "

'Adding Agent Scan Key Info
'==========================
if(isAgentMode) Then
	agentTaskInfo  = "<agentTaskInfo  "
	agentTaskInfo  = addCategoryData(agentTaskInfo, "AgentTaskID",agentTaskID)
	agentTaskInfo  = agentTaskInfo & "/>"
	outputText = outputText & agentTaskInfo 
end if

'Adding Script Information
'=========================
scriptVersion="5000"
scriptVersionInfo = "<scriptVersion "
scriptVersionInfo = addCategoryData(scriptVersionInfo, "Version",scriptVersion)
scriptVersionInfo = scriptVersionInfo & "/>"
outputText = outputText & scriptVersionInfo


set licenseKeys = CreateObject("Scripting.Dictionary")
set adobeSoftHavingLicKeys = CreateObject("Scripting.Dictionary")

On Error Resume Next
connected=true

Dim objWMIService 
if(islocalScan) then
	Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
else
	Set objWbemLocator = CreateObject("WbemScripting.SWbemLocator")
	Set objWMIService = objwbemLocator.ConnectServer (strComputer, strNamespace, remoteUser, remotePassword)
	if(Err.Number <> 0) then
		errorText = "<ErrorLog "
		errorText = addCategoryData(errorText,"errNo", Err.Number)
		errorText = addCategoryData(errorText,"errDesc", Err.Description)
		errorText = errorText & "/>"
		outputText = outputText & errorText
		connected=false
	end if
	Wscript.Echo "Connect Server Error Number : " & Err.Number
	objWMIService.Security_.authenticationLevel = WbemAuthenticationLevelPktPrivacy
end if

Err.clear

if(connected) then

'Data Fetching Starts 
'====================
outputText = outputText & "<Hardware_Info>"
dataText = ""

'Compuer System Info
'===================
dataText = "<Computer " 
getDomainName=true

'Get domain name from registry
'------------------------------
On Error Resume Next
Dim objRej
if(islocalScan) then
	Set objReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")
else
	Set objReg = objwbemLocator.ConnectServer (strComputer, "\root\default", remoteUser, remotePassword).Get("StdRegProv")
end if

is64BitOS = false
objReg.GetStringValue HKEY_LOCAL_MACHINE, "SYSTEM\CurrentControlSet\Control\Session Manager\Environment", "PROCESSOR_ARCHITECTURE", osArch
if not isNULL(osArch) then
	pos=InStr(osArch,"64")
	if pos>0 Then
		is64BitOS = true
	End if
End if

domainKeyRoot = "SYSTEM\ControlSet001\Services\Tcpip\parameters\"
objReg.GetStringValue HKEY_LOCAL_MACHINE, domainKeyRoot, "Domain", domainName

if not ISNULL(domainName) then
	if (domainName <> "") then
		getDomainName = false
	end if
end if
getmodel=true
model=""
query="Select * from Win32_ComputerSystem"
Set queryResult = objWMIService.ExecQuery (query)
For Each iterResult in queryResult
	computerNameForFile = iterResult.Caption & ""
	nodeName = computerNameForFile
	dataText = addCategoryData(dataText, "Name", computerNameForFile)
	manufacturer = iterResult.Manufacturer
	dataText = addCategoryData(dataText, "Manufacturer", manufacturer)
	dataText = addCategoryData(dataText, "PrimaryOwnerName", iterResult.PrimaryOwnerName)
	model = iterResult.Model
	'dataText = addCategoryData(dataText, "Model", iterResult.Model)
        lastLoggedUser = GetLastLoggedUser()
	dataText = addCategoryData(dataText, "UserName", lastLoggedUser)
	dataText = addCategoryData(dataText, "WorkGroup", iterResult.WorkGroup)
	dataText = addCategoryData(dataText, "TotalPhysicalMemory", iterResult.TotalPhysicalMemory)
	if(getDomainName) Then
		domainName = iterResult.Domain & ""
	end if
	dataText = addCategoryData(dataText, "DomainName", domainName)
Next
' to handle LENOVO laptops
if (StrComp(manufacturer,"LENOVO",1)<>0) then
	dataText = addCategoryData(dataText, "Model", model)
	getModel = false
End if

if (getModel) then
	query="Select * from Win32_ComputerSystemProduct"
	Set queryResult = objWMIService.ExecQuery (query)
	For Each iterResult in queryResult
		model = iterResult.Version
	Next
	dataText = addCategoryData(dataText, "Model", model)
End if

query="Select * from Win32_BIOS"
Set queryResult = objWMIService.ExecQuery (query)
For Each iterResult in queryResult
	dataText = addCategoryData(dataText, "BiosName", iterResult.Caption)
	dataText = addCategoryData(dataText, "BiosManufacturer", iterResult.Manufacturer)
	dataText = addCategoryData(dataText, "SMBiosVersion", iterResult.SMBIOSBIOSVersion)
	dataText = addCategoryData(dataText, "BiosVersion", iterResult.Version)
	dataText = addCategoryData(dataText, "BiosDate", iterResult.ReleaseDate)
	serviceTag = iterResult.SerialNumber
	dataText = addCategoryData(dataText, "ServiceTag", 	serviceTag)
Next

query="select DNSDomain,DNSHostName from Win32_NetworkAdapterConfiguration where DNSDomain!=null AND DNSHostName!=null"
Set queryResult = objWMIService.ExecQuery (query)
For Each iterResult in queryResult
	dnsdomain = iterResult.DNSDomain
	dnshost = iterResult.DNSHostName
Next
if (isNULL(dnsdomain) or dnsdomain="") then
	dnsdomain = GetDNSDomain(nodeName)
end if

dataText = addCategoryData(dataText, "DNSDomain", dnsdomain)
dataText = addCategoryData(dataText, "DNSHostName", dnshost)

query="Select MemoryDevices from Win32_PhysicalMemoryArray where Use=3"
Set queryResult = objWMIService.ExecQuery (query)
memorySlotCount=0
For Each iterResult in queryResult
    memorySlotCount = iterResult.MemoryDevices
Next
dataText = addCategoryData(dataText, "MemorySlotsCount", memorySlotCount)

query="Select ChassisTypes from Win32_SystemEnclosure"
Set queryResult = objWMIService.ExecQuery (query)

isLaptop=""
outerLoopContinue=true
For Each iterResult in queryResult
	labtopIterator = iterResult.ChassisTypes
	for each laptop in labtopIterator
		isLaptop = laptop
        if (NOT ISNULL(isLaptop) AND (isLaptop=8 OR isLaptop=9 OR isLaptop=10)) Then
            outerLoopContinue=false
            Exit For
        End if
	Next
    if not outerLoopContinue Then Exit For
Next
dataText = addCategoryData(dataText, "isLaptop", isLaptop)
dataText = dataText & "/>"
outputText = outputText & dataText
Err.clear

'Operating System Info
'=====================
On Error Resume Next
	getComputerName=true
	query="select * from Win32_OperatingSystem"
	Set queryResult = objWMIService.ExecQuery (query)
	dataText = "<OperatingSystem " 
	For Each iterResult in queryResult
		dataText = addCategoryData(dataText, "Name", iterResult.Caption)
		dataText = addCategoryData(dataText, "Version", iterResult.Version)
		dataText = addCategoryData(dataText, "BuildNumber", iterResult.BuildNumber)
		dataText = addCategoryData(dataText, "ServicePackMajorVersion", iterResult.ServicePackMajorVersion)
		dataText = addCategoryData(dataText, "ServicePackMinorVersion", iterResult.ServicePackMinorVersion)
		dataText = addCategoryData(dataText, "SerialNumber", iterResult.SerialNumber)
		dataText = addCategoryData(dataText, "TotalVisibleMemorySize", iterResult.TotalVisibleMemorySize)
		dataText = addCategoryData(dataText, "FreePhysicalMemory", iterResult.FreePhysicalMemory)
		dataText = addCategoryData(dataText, "TotalVirtualMemorySize", iterResult.TotalVirtualMemorySize)
		dataText = addCategoryData(dataText, "FreeVirtualMemory", iterResult.FreeVirtualMemory)
	Next
	dataText = dataText & "/>"
	outputText = outputText & dataText
Err.clear

'CPU Info
'========
On Error Resume Next
	query="Select * from Win32_Processor"
	Set queryResult = objWMIService.ExecQuery (query)
	procCount=0
	cpuData = ""
	dataText = "<CPU "
	For Each iterResult in queryResult
		procCount=procCount+1
		cpuData = cpuData & "<CPU_Info "
		objReg.GetStringValue HKEY_LOCAL_MACHINE, "HARDWARE\DESCRIPTION\System\CentralProcessor\0", "ProcessorNameString", cpuName
		if (not isNULL(cpuName) and cpuName<>"") then
			processorName = cpuName
		else
			processorName = iterResult.Name
		end if
		cpuData = addCategoryData(cpuData, "DeviceID",iterResult.DeviceID)
		cpuData = addCategoryData(cpuData, "CPUName", processorName)
		cpuData = addCategoryData(cpuData, "CPUSpeed", iterResult.MaxClockSpeed)
		cpuData = addCategoryData(cpuData, "CPUStepping", iterResult.Stepping)
		cpuData = addCategoryData(cpuData, "CPUManufacturer", iterResult.Manufacturer)
		cpuData = addCategoryData(cpuData, "CPUModel", iterResult.Family)
		cpuData = addCategoryData(cpuData, "CPUSerialNo", iterResult.UniqueId)
		cpuData = addCategoryData(cpuData, "NumberOfCores", iterResult.NumberOfCores)
		cpuData = cpuData & "/>"
	Next
	dataText = addCategoryData(dataText, "CPUCount", procCount)
	dataText = dataText &  " >" & cpuData & "</CPU>"
	outputText = outputText & dataText
Err.clear

'MemoryModule Info
'=================
On Error Resume Next
	query="Select * from Win32_PhysicalMemory"
	Set queryResult = objWMIService.ExecQuery (query)
	dataText = "<MemoryModule>" 
	For Each iterResult in queryResult
		dataText = dataText & "<MemoryModule_Info "
		dataText = addCategoryData(dataText, "Name", iterResult.Tag)
		dataText = addCategoryData(dataText, "Capacity", iterResult.Capacity)
		dataText = addCategoryData(dataText, "BankLabel", iterResult.BankLabel)
		dataText = addCategoryData(dataText, "DeviceLocator", iterResult.DeviceLocator)
		dataText = addCategoryData(dataText, "MemoryType", iterResult.MemoryType)
		dataText = addCategoryData(dataText, "TypeDetail", iterResult.TypeDetail)
		dataText = dataText & "/>"
	Next
	dataText = dataText & "</MemoryModule>"
	outputText = outputText & dataText
Err.clear


'HardDisc Info
'=============
On Error Resume Next
	query="Select * from Win32_DiskDrive"
	Set queryResult = objWMIService.ExecQuery (query)
	dataText = "<HardDisk>" 
	For Each iterResult in queryResult
		dataText = dataText & "<HardDisk_Info "
		dataText = addCategoryData(dataText, "HDName", iterResult.Caption)
		dataText = addCategoryData(dataText, "HDModel", iterResult.Model)
		dataText = addCategoryData(dataText, "HDSize", iterResult.Size)
		HDSerialNumberId = iterResult.DeviceID
		HDSerialNumberId = Replace(HDSerialNumberId,"\","\\")
		query="Select SerialNumber from  CIM_PhysicalMedia where Tag = " & doubleQuote & HDSerialNumberId & doubleQuote 
		Set queryResultForSN = objWMIService.ExecQuery (query)
		For Each iterResultSN in queryResultForSN
			serialNo = iterResultSN.SerialNumber
		Next
		if not ISNULL(serialNo) then
			dataText = addCategoryData(dataText, "HDSerialNumber", serialNo)
		else
			dataText = addCategoryData(dataText, "HDSerialNumber", "HardDiskSerialNumber")
		End if 
		dataText = addCategoryData(dataText, "HDDescription", iterResult.Description)
		dataText = addCategoryData(dataText, "HDManufacturer", iterResult.Manufacturer)
		dataText = addCategoryData(dataText, "TotalCylinders", iterResult.TotalCylinders)
		dataText = addCategoryData(dataText, "BytesPerSector", iterResult.BytesPerSector)
		dataText = addCategoryData(dataText, "SectorsPerTrack", iterResult.SectorsPerTrack)
		dataText = dataText & "/>"
	Next
	dataText = dataText & "</HardDisk>"
	outputText = outputText & dataText
Err.clear

'LogicalDisk Info
'================
On Error Resume Next
	query="Select * from Win32_LogicalDisk"
	Set queryResult = objWMIService.ExecQuery (query)
	dataText = "<LogicDrive>" 
	For Each iterResult in queryResult
		dataText = dataText & "<LogicDrive_Info "
		dataText = addCategoryData(dataText, "Name", iterResult.Caption)
		dataText = addCategoryData(dataText, "Description", iterResult.Description)
		discType = getDiskType(iterResult.DriveType)
		dataText = addCategoryData(dataText, "Type", discType)
		dataText = addCategoryData(dataText, "Size", iterResult.Size)
		dataText = addCategoryData(dataText, "FreeSpace", iterResult.FreeSpace)
		dataText = addCategoryData(dataText, "SerialNumber", iterResult.VolumeSerialNumber)
		dataText = addCategoryData(dataText, "FileSystem", iterResult.FileSystem)
		dataText = dataText & "/>"
	Next
	dataText = dataText & "</LogicDrive>"
	outputText = outputText & dataText
Err.clear

'PhysicalDrive Info
'==================
On Error Resume Next
	query="Select * from CIM_MediaAccessDevice"
	Set queryResult = objWMIService.ExecQuery (query)
	dataText = "<PhysicalDrive>" 
	For Each iterResult in queryResult
		dataText = dataText & "<PhysicalDrive_Info "
		dataText = addCategoryData(dataText, "Name", iterResult.Caption)
		dataText = addCategoryData(dataText, "Description", iterResult.Description)
		'dataText = addCategoryData(dataText, "Manufacturer", iterResult.Manufacturer)
		dataText = dataText & "/>"
	Next
	dataText = dataText & "</PhysicalDrive>"
	outputText = outputText & dataText
Err.clear



'KeyBoard Info
'=============
On Error Resume Next
	query="Select * from Win32_KeyBoard"
	Set queryResult = objWMIService.ExecQuery (query)
	dataText = ""
	For Each iterResult in queryResult
		dataText = ""  'Only last iteration will get added into the XML...
		dataText = dataText & "<KeyBoard " 
		dataText = addCategoryData(dataText, "Name", iterResult.Caption)
		dataText = dataText & "/>"
	Next
	outputText = outputText & dataText
Err.clear

'Mouse Info
'===========
On Error Resume Next
	query="Select * from Win32_PointingDevice"
	Set queryResult = objWMIService.ExecQuery (query)
	dataText = ""
	For Each iterResult in queryResult
		dataText = ""  'Only last iteration will get added into the XML...
		dataText = dataText & "<Mouse " 
		dataText = addCategoryData(dataText, "Name", iterResult.Name)
		dataText = addCategoryData(dataText, "ButtonsCount", iterResult.NumberOfButtons)
		dataText = addCategoryData(dataText, "Manufacturer", iterResult.Manufacturer)
		dataText = dataText & "/>"
	Next
	outputText = outputText & dataText
Err.clear


'Monitor Info
'============
Dim sMultiStrings()
On Error Resume Next
    query="SELECT * FROM Win32_PnPEntity where deviceid like 'DISPLAY%'"
    Set queryResult = objWMIService.ExecQuery (query)
        dataText = "<Monitors>"
        For Each iterResult in queryResult          
            MonitorType = iterResult.Caption
            Manufacturer = iterResult.Manufacturer      
            pnpDeviceId = iterResult.PNPDeviceID
            subKey = "SYSTEM\CurrentControlSet\Enum\" & pnpDeviceId & "\Device Parameters"
            objReg.GetBinaryValue HKEY_LOCAL_MACHINE, subKey, "EDID", arrRawEDID
            If(Not isNull(arrRawEDID))Then
                productCode = getProductCode(arrRawEDID)
                manufacturerCode = getManufacturerCode(arrRawEDID)
                monitorSize = getMonitorSize(arrRawEDID)
                monitorMode = isAnalog(arrRawEDID)
                matchingArray = Split( "0 0 0 255")
                indexArray = Split( "54 72 90 108" )
                serialNumber = readValueFromEDID(matchingArray,indexArray,arrRawEDID) 
		IF(isNULL(serialNumber) or serialNumber = "") Then
                    serialNumber = "-"
	        END IF   
                matchingArray = Split( "0 0 0 252")
                indexArray = Split( "54 72 90 108" )
                MonitorName = readValueFromEDID(matchingArray,indexArray,arrRawEDID)        
                IF(Not isNULL(MonitorName) and MonitorName <> "") Then
                    MonitorType = MonitorName
                END IF
                If (InStr(MonitorType,monitorMode)=0 and (not isNull(monitorMode)) and monitorMode <> "") Then
                    MonitorType = MonitorType & " (" & monitorMode & ")"
                End IF
            End If
            productID = manufacturerCode & productCode
            If(not IsNull(productID) and productID <> "")Then               
                MonitorType = MonitorType & " (" & productID & ")"
            End If
            IF(NOT ISNULL(MonitorType)) Then
                dataText = dataText & "<Monitor_Info"
                dataText = addCategoryData(dataText, "Name", MonitorType)
                dataText = addCategoryData(dataText, "DisplayType", MonitorType)
                dataText = addCategoryData(dataText, "MonitorType", MonitorType)
                dataText = addCategoryData(dataText, "Manufacturer", Manufacturer)
                dataText = addCategoryData(dataText, "Resolution", monitorSize)
                dataText = addCategoryData(dataText, "Height", iterResult.ScreenHeight)
                dataText = addCategoryData(dataText, "Width", iterResult.ScreenWidth)
                dataText = addCategoryData(dataText, "XPixels", iterResult.PixelsPerXLogicalInch)
                dataText = addCategoryData(dataText, "YPixels", iterResult.PixelsPerYLogicalInch)
                dataText = addCategoryData(dataText, "SerialNumber", serialNumber) 
                dataText = dataText & "/>"   
            END IF    
        Next   
    dataText = dataText & "</Monitors>"
    outputText = outputText & dataText
Err.clear

'Network Info
'=============
On Error Resume Next
	query="Select * from Win32_NetworkAdapterConfiguration where IPEnabled = True"
	Set queryResult = objWMIService.ExecQuery (query)
	dataText = "<Network>" 
	For Each iterResult in queryResult
                dhcpEnabled = "false"
		dataText = dataText & "<Network_Info "
		'To Remove the NIC Index from the NIC Caption
		nwCaption = getNetworkCaption(iterResult.Caption)
		dataText = addCategoryData(dataText, "Name", nwCaption)
		dataText = addCategoryData(dataText, "Index", iterResult.Index)
		macAddress = macAddress & iterResult.MACAddress & "###"
		dataText = addCategoryData(dataText, "MACAddress", iterResult.MACAddress)
		dataText = addCategoryData(dataText, "DNSDomain", iterResult.DNSDomain)
		dataText = addCategoryData(dataText, "DNSHostName", iterResult.DNSHostName)
                if iterResult.DHCPEnabled then
                   dhcpEnabled = "true"
                end if
		dataText = addCategoryData(dataText, "DHCPEnabled", getBooleanStr(dhcpEnabled))
		dataText = addCategoryData(dataText, "DHCPLeaseObtained", iterResult.DHCPLeaseObtained)
		dataText = addCategoryData(dataText, "DHCPLeaseExpires", iterResult.DHCPLeaseExpires)
		dataText = addCategoryData(dataText, "DHCPServer", iterResult.DHCPServer)
		ipIterator = iterResult.IPAddress
		ipAddress=""
		for each ipaddr in ipIterator
                    if (NOT IsNull(ipaddr) and Len(ipaddr) > 3 and InStr(ipaddr,":")=0) then
				ipAddress = Left(ipaddr,24)
			end if
		Next
		dataText = addCategoryData(dataText, "IpAddress", ipAddress)
		ipIterator = iterResult.DefaultIPGateway
		ipAddress=""
		for each ipaddr in ipIterator
                    if (NOT IsNull(ipaddr) and Len(ipaddr) > 3 and InStr(ipaddr,":")=0) then
				ipAddress = Left(ipaddr,24)
			end if
		Next
		dataText = addCategoryData(dataText, "Gateway", ipAddress)
		ipIterator = iterResult.DNSServerSearchOrder
		ipAddress=""
		for each ipaddr in ipIterator
                    if (NOT IsNull(ipaddr) and Len(ipaddr) > 3 and InStr(ipaddr,":")=0) then
				ipAddress = Left(ipaddr,24)
			end if
		Next
		dataText = addCategoryData(dataText, "DnsServer", ipAddress)
		ipIterator = iterResult.IPSubnet
		ipAddress=""
		for each ipaddr in ipIterator
                    if (NOT IsNull(ipaddr) and Len(ipaddr) > 3 and InStr(ipaddr,":")=0) then
				ipAddress = Left(ipaddr,24)
			end if
		Next
		dataText = addCategoryData(dataText, "Subnet", ipAddress)
		dataText = dataText & "/>"
	Next
	dataText = dataText & "</Network>"
	outputText = outputText & dataText
Err.clear

'SoundCard Info
'============
On Error Resume Next
	query="Select * from Win32_SoundDevice"
	Set queryResult = objWMIService.ExecQuery (query)
	dataText = ""
	For Each iterResult in queryResult
		dataText = ""  'Only last iteration will get added into the XML...
		dataText = dataText & "<SoundCard " 
		dataText = addCategoryData(dataText, "SoundCardName", iterResult.Caption)
		dataText = addCategoryData(dataText, "SoundCardManufacturer", iterResult.Manufacturer)
		dataText = dataText & "/>"
	Next
	outputText = outputText & dataText
Err.clear

'VideoCard Info
'==================
On Error Resume Next
	query="Select * from Win32_VideoController where VideoProcessor!=null"
	Set queryResult = objWMIService.ExecQuery (query)
	dataText = "<VideoCard>" 
	For Each iterResult in queryResult
		dataText = dataText & "<VideoCard_Info "
		dataText = addCategoryData(dataText, "VideoCardName", iterResult.Caption)
		dataText = addCategoryData(dataText, "VideoCardChipset", iterResult.VideoProcessor)
		dataText = addCategoryData(dataText, "VideoCardMemory", iterResult.AdapterRAM)
		dataText = dataText & "/>"
	Next

	dataText = dataText & "</VideoCard>"
	outputText = outputText & dataText
Err.clear

'SerialPort Info
'==================
On Error Resume Next
	query="Select * from Win32_SerialPort"
	Set queryResult = objWMIService.ExecQuery (query)
	dataText = "<SerialPort>" 
	For Each iterResult in queryResult
		dataText = dataText & "<SerialPort_Info "
		dataText = addCategoryData(dataText, "Name", iterResult.Caption)
		dataText = addCategoryData(dataText, "BaudRate", iterResult.MaxBaudRate)
		dataText = addCategoryData(dataText, "Status", iterResult.Status)
		dataText = dataText & "/>"
	Next
	dataText = dataText & "</SerialPort>"
	outputText = outputText & dataText
Err.clear

'ParallelPort Info
'==================
On Error Resume Next
	query="Select * from Win32_ParallelPort"
	Set queryResult = objWMIService.ExecQuery (query)
	dataText = "<ParallelPort>" 
	For Each iterResult in queryResult
		dataText = dataText & "<ParallelPort_Info "
		dataText = addCategoryData(dataText, "Name", iterResult.Caption)
		dataText = addCategoryData(dataText, "Status", iterResult.Status)
		dataText = dataText & "/>"
	Next
	dataText = dataText & "</ParallelPort>"
	outputText = outputText & dataText
Err.clear

'USB Info
'========
On Error Resume Next
	query="Select * from Win32_USBController"
	Set queryResult = objWMIService.ExecQuery (query)
	dataText = "<USB>" 
	For Each iterResult in queryResult
		dataText = dataText & "<USB_Info "
		dataText = addCategoryData(dataText, "Name", iterResult.Caption)
		dataText = addCategoryData(dataText, "Manufacturer", iterResult.Manufacturer)
		dataText = dataText & "/>"
	Next
	dataText = dataText & "</USB>"
	outputText = outputText & dataText
Err.clear

'Hyper-V Details
'===============
Err.clear
if(StrComp(Wscript.Arguments(1),"no_vm_scan")<>0)then
isHyperV = false
On Error Resume Next
Set objWbemLocator = CreateObject("WbemScripting.SWbemLocator")
Set hypWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\virtualization")
if(isNull(hypWMIService))then
	'printLog "Error while connect root\virtualization - "&getErrorMessage(Err)
else
	query="Select Caption from Msvm_ComputerSystem"
	Set queryResult = hypWMIService.ExecQuery (query)
	rowsCount = queryResult.Count
	if(Err)then
		'printLog "Error after execute the query of class Msvm_ComputerSystem - "&getErrorMessage(Err)
	else
		isHyperV = true
	end if
end if
Err.clear
if(not isHyperV) then
	Set hypWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\virtualization\v2")
	If(isNull(hypWMIService))then
		'printLog "Error while connect root\virtualization\v2 - "&getErrorMessage(Err)
	else
		query="Select Caption from Msvm_ComputerSystem"
		Set queryResult = hypWMIService.ExecQuery (query)
		rowsCount = queryResult.Count
		if(Err)then
			'printLog "Error after execute the query of class Msvm_ComputerSystem - "&getErrorMessage(Err)
		else
			isHyperV = true
		end if
	end if
end if

'Wscript.Echo "Is HyperV? - "&isHyperV


if(isHyperV)then
	set objXMLDoc = CreateObject("Microsoft.xmldom") 
    objXMLDoc.async = False 
	
	if(not isNull(hypWMIService)) then
		query="Select Caption,Name,ElementName from Msvm_ComputerSystem where Caption!='Hosting Computer System'"
		Set queryResult = hypWMIService.ExecQuery (query)
		rowsCount = queryResult.Count
		if(Err)then
			isHyperV = False
		Else
			vmData = "<HyperV>"
			For Each iterResult in queryResult
				if(uCase(iterResult.ElementName) <> uCase(nodeName)) then
					vmData = vmData&"<VirtualMachine "
					vmData = addCategoryData(vmData, "VMElementId", iterResult.Name)
					vmData = addCategoryData(vmData, "VMName", iterResult.ElementName)
					elementName = iterResult.ElementName
					procQuery = "select instanceId,Limit,Reservation,Weight from MsVM_ProcessorSettingData where instanceId like '%"&iterResult.Name&"%'"
					Set procResult = hypWMIService.ExecQuery (procQuery)
					For Each vmProc In procResult
						vmData = addCategoryData(vmData, "CPULimit", (vmProc.Limit/1000))
						vmData = addCategoryData(vmData, "CPUReservation", (vmProc.Reservation/1000))
						vmData = addCategoryData(vmData, "CPUShares", vmProc.Weight)
					Next
					memQuery = "select Limit,VirtualQuantity,DynamicMemoryEnabled,Weight from MSVM_MemorySettingData where instanceId like "&doubleQuote&"%"&iterResult.Name&"%"&doubleQuote
					Set memResult = hypWMIService.ExecQuery (memQuery)
					For Each vmMem In memResult
						vmData = addCategoryData(vmData, "MemoryReservation", vmMem.VirtualQuantity)
						if (vmMem.DynamicMemoryEnabled = True) Then
							vmData = addCategoryData(vmData, "MemoryLimit", vmMem.Limit)
						End if
						vmData = addCategoryData(vmData, "MemoryShares", vmMem.Weight)
					Next
					vmData = vmData&"/>"
				End if
			Next
			vmData=vmData&"</HyperV>"
			outputText = outputText&vmData
		end if
	end if
end If
end if
'Printer Info
'=================
On Error Resume Next
    set printersList = CreateObject("Scripting.Dictionary")
	dataText = "<Printer>" 
	count=0
    query="Select * from Win32_Printer Where Network=False"
    Set queryResult = objWMIService.ExecQuery (query)
    For Each iterResult in queryResult
        printerName = iterResult.Caption
        printerName = checkAndRemoveServerName(printerName)
        if(Not isNULL(printerName) and printerName<>"" and (Not printersList.Exists(printerName))) then
            printersList.add printerName,printerName
            On Error Resume Next
            dataText = dataText & "<Printer_Info "
            dataText = addCategoryData(dataText, "Name", printerName)
            dataText = addCategoryData(dataText, "Model", iterResult.DriverName)
            dataText = addCategoryData(dataText, "Default", getBooleanStr(iterResult.Default))
            dataText = addCategoryData(dataText, "Network", iterResult.Network)
            dataText = addCategoryData(dataText, "Local", iterResult.Local)
            dataText = addCategoryData(dataText, "PortName", iterResult.PortName)
            dataText = addCategoryData(dataText, "Location", iterResult.Location)
            dataText = addCategoryData(dataText, "Comment", iterResult.Comment)
            dataText = addCategoryData(dataText, "ServerName", iterResult.ServerName)
            Err.clear
            dataText = dataText & "/>"
        end if
    Next

    query="Select * from Win32_Printer Where Network=True"
    Set queryResult = objWMIService.ExecQuery (query)
    For Each iterResult in queryResult
        printerName = iterResult.Caption
        printerName = checkAndRemoveServerName(printerName)
        if(Not isNULL(printerName) and printerName<>"" and (Not printersList.Exists(printerName))) then
            printersList.add printerName,printerName
            On Error Resume Next
            dataText = dataText & "<Printer_Info "
            dataText = addCategoryData(dataText, "Name", printerName)
            dataText = addCategoryData(dataText, "Model", iterResult.DriverName)
            dataText = addCategoryData(dataText, "Default", getBooleanStr(iterResult.Default))
            dataText = addCategoryData(dataText, "Network", iterResult.Network)
            dataText = addCategoryData(dataText, "Local", iterResult.Local)
            dataText = addCategoryData(dataText, "PortName", iterResult.PortName)
            dataText = addCategoryData(dataText, "Location", iterResult.Location)
            dataText = addCategoryData(dataText, "Comment", iterResult.Comment)
            dataText = addCategoryData(dataText, "ServerName", iterResult.ServerName)
            Err.clear
            dataText = dataText & "/>"
        end if
    Next
    if(queryResult.Count = 0) then
    	dataText = getPrinterInfo(dataText,count)
    End if
	dataText = dataText & "</Printer>"
	outputText = outputText & dataText
Err.clear

'HotFix Info
'===========
On Error Resume Next
	query="Select * from Win32_QuickFixEngineering"
	Set queryResult = objWMIService.ExecQuery (query)
	dataText = "<HotFix>" 
	For Each iterResult in queryResult
		dataText = dataText & "<HotFix_Info "
		dataText = addCategoryData(dataText, "HotFixID", iterResult.HotFixID)
		dataText = addCategoryData(dataText, "InstalledBy", iterResult.InstalledBy)
		dataText = addCategoryData(dataText, "InstalledOn", iterResult.InstalledOn)
        hotfixDesc = iterResult.Description
		dataText = addCategoryData(dataText, "Description", Left(hotfixDesc,248))
		dataText = dataText & "/>"
	Next
	dataText = dataText & "</HotFix>"
	outputText = outputText & dataText
Err.clear


outputText = outputText & "</Hardware_Info>"

'Microsoft Keys
'=================
On Error Resume Next
softwareDataText="<Software_Info>"
softwareDataText = softwareDataText & "<MicrosoftOfficeKeys>"
strKeyPath = "SOFTWARE\Microsoft\Office"

for itr=1 to 2
    continue = true
    Set objCtx = CreateObject("WbemScripting.SWbemNamedValueSet")
	if(itr=2) then
		objCtx.Add "__ProviderArchitecture", 32
	elseif (is64BitOS) then
		objCtx.Add "__ProviderArchitecture", 64
	else
		continue = false
	end if
	objCtx.Add "__RequiredArchitecture", TRUE
    if(continue)then
		Set objLocator = CreateObject("Wbemscripting.SWbemLocator")
		Set objServices = objLocator.ConnectServer("localhost","root\default","","",,,,objCtx)
		Set objReg1 = objServices.Get("StdRegProv") 
        objReg1.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys
        If NOT ISNULL(arrSubKeys) then
            For Each subkey In arrSubKeys
                subkeyPath = strKeyPath & "\" & subkey & "\Registration" 
                objReg1.EnumKey HKEY_LOCAL_MACHINE, subkeyPath, productSubKeys
                If NOT ISNULL(productSubKeys) then
                    For Each productsubkey In productSubKeys
                        softwareDataText = softwareDataText & "<Key "
                        softwareDataText = addCategoryData(softwareDataText, "Key", productsubkey)
                        productsubkeyPath = subkeyPath & "\" &  productsubkey
                        objReg1.GetStringValue HKEY_LOCAL_MACHINE, productsubkeyPath, "ProductID", productId
                        objReg1.GetBinaryValue HKEY_LOCAL_MACHINE, productsubkeyPath, "DigitalProductID", productKey
                        if NOT ISNULL(productId) then
                            softwareDataText = addCategoryData(softwareDataText, "ProductID", productId)
    			    	end if
				        if NOT ISNULL(productKey) then
					        key = getLicenceKey(productKey, subkey)
                            if (NOT ISNULL(key) and key<>"") then
					            softwareDataText = addCategoryData(softwareDataText, "ProductKey", key)
                                licenseKeys.add productsubkey,key
                            end if
				        end if
                        softwareDataText = softwareDataText &  " />"
                    Next
                end if	
	        Next
        end if
    end if
Next
softwareDataText = softwareDataText & "</MicrosoftOfficeKeys>"
Err.clear
'Windows Key
'===========
On Error Resume Next
softwareDataText = softwareDataText & "<WindowsKey " 
windowsKeyRoot = "SOFTWARE\Microsoft\Windows NT\CurrentVersion\"
Set objCtx = CreateObject("WbemScripting.SWbemNamedValueSet")
if(is64BitOS) then
    objCtx.Add "__ProviderArchitecture", 64
else
   objCtx.Add "__ProviderArchitecture", 32
end if
objCtx.Add "__RequiredArchitecture", TRUE
Set objLocator1 = CreateObject("Wbemscripting.SWbemLocator")
Set objServices1 = objLocator1.ConnectServer("localhost","root\default","","",,,,objCtx)
Set objReg1 = objServices1.Get("StdRegProv") 
objReg1.GetStringValue HKEY_LOCAL_MACHINE, windowsKeyRoot, "ProductID", windowsId
if not ISNULL(windowsId) then
    softwareDataText = addCategoryData(softwareDataText, "ProductID", windowsId)
end if
objReg1.GetBinaryValue HKEY_LOCAL_MACHINE, windowsKeyRoot, "DigitalProductID", windowsKeyData
if not ISNULL(windowsKeyData)then
    windowsKey = ConvertToKey(windowsKeyData)
End if	
If not InStr(windowsKey, "BBBBB-BBBBB") > 0 Then
       softwareDataText = addCategoryData(softwareDataText, "ProductKey", windowsKey)
     Else
	   query = "Select * from softwarelicensingproduct where partialproductkey != NULL and description like '%operating system%'"
            Set queryResult = objWMIService.ExecQuery (query)
            count=0
            For Each iterResult in queryResult              
                partialproductkey = iterResult.PartialProductKey
            Next            
            if not ISNULL(partialproductkey) then
                windowsKey = "XXXXX-XXXXX-XXXXX-XXXXX-" & partialproductkey
                softwareDataText = addCategoryData(softwareDataText, "ProductKey", windowsKey)
				Else
                 Dim key
                 Dim oShell
                 Set oShell = WScript.CreateObject ("WScript.Shell")
                 Set key=oShell.Exec("wmic path SoftwareLicensingService get OA3xOriginalProductKey")
                 KeyFromWmic = key.StdOut.ReadLine
                 KeyFromWmic = key.StdOut.ReadLine 
	             if not ISNULL(KeyFromWmic) then
                   softwareDataText = addCategoryData(softwareDataText, "ProductKey", KeyFromWmic)	
                 end if
            end if  	  
 end if
	
softwareDataText = softwareDataText & "/>"
Err.clear


'SoftwareList Info
'=================
set softList = CreateObject("Scripting.Dictionary")
On Error Resume Next
softwareDataText = softwareDataText & "<InstalledProgramsList>"


strKeyPath = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"
objReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys

'Softwares installed under different users
'=========================================
objReg.EnumKey HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList",profileSIDs

If NOT ISNULL(profileSIDs) then
	For Each profileSID In profileSIDs
		objReg.EnumKey HKEY_USERS, profileSID&"\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall",arrSubKeys
		If NOT ISNULL(arrSubKeys) then
			For Each subkey In arrSubKeys
				isAddSoftware = true
				subkeyPath = profileSID&"\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\"& subkey
				objReg.GetStringValue HKEY_USERS, subkeyPath, "DisplayName", softwareName
				objReg.GetStringValue HKEY_USERS, subkeyPath, "ParentKeyName", parentKeyName
				objReg.GetStringValue HKEY_USERS, subkeyPath, "DisplayVersion", softwareVersion
				objReg.GetStringValue HKEY_USERS, subkeyPath, "Publisher", softwarePublisher
				objReg.GetStringValue HKEY_USERS, subkeyPath, "InstallLocation", softwareLocation
				objReg.GetStringValue HKEY_USERS, subkeyPath, "InstallDate", softwareInstallDate
				keyForSoftwareUsage = "SOFTWARE\Microsoft\Windows\CurrentVersion\App Management\ARPCache\" & subkey
				objReg.GetBinaryValue HKEY_USERS, keyForSoftwareUsage, "SlowInfoCache", usageData
				swUsage = getSoftwareUsage(usageData)
				If (NOT ISNULL(softwareName) And (ISNULL(parentKeyName) OR parentKeyName="" ) And (InStr(Lcase(softwareName),"windows internet explorer") = 0)) then
					if(softwareName <> "" and (not softList.Exists(softwareName) or licenseKeys.Exists(subkey))) then
						if ((InStr(Lcase(softwareName),"adobe") > 0) or (InStr(Lcase(softwareName),"acrobat") > 0)) then
                            licenseKey = getAdobeLicenseKey(objReg,subkeyPath,softwareName)
							objReg.GetDWORDValue HKEY_USERS, subkeyPath, "SystemComponent", systemComponent
							systemComponent=""&systemComponent
							if (licenseKey="" and systemComponent="1") then
								isAddSoftware = false
							else
								if (licenseKey="") then
									tmpCheck = adobeSoftHavingLicKeys.Item(softwareName)
									if((Not isNULL(tmpCheck)) and (tmpCheck<>""))then
										isAddSoftware = false
									End if
								end if
							End if
							if ((licenseKey<> "") and (Not adobeSoftHavingLicKeys.Exists(softwareName)))then
								adobeSoftHavingLicKeys.add softwareName,licenseKey
							end if
                        elseif ((StrComp(softwareName,"microsoft sql server 2000",1) = 0) or (StrComp(softwareName,"microsoft sql server 2005",1) = 0) or (StrComp(softwareName,"microsoft sql server 2008",1) = 0) or (StrComp(softwareName,"microsoft sql server 2008 R2",1) = 0))then
							softwareName = updateSQLEdition(softwareName,HKEY_LOCAL_MACHINE,"SOFTWARE\Microsoft",objReg1)
						End if	
						if(isAddSoftware=true) then
						
                                                        softList.add softwareName,softwareName
							softwareDataText = softwareDataText & "<Software "
							softwareDataText = addCategoryData(softwareDataText, "Name", Left(softwareName,248))
							softwareDataText = addCategoryData(softwareDataText, "Version", Left(softwareVersion,28))
							softwareDataText = addCategoryData(softwareDataText, "Vendor", Left(softwarePublisher,98))
							softwareDataText = addCategoryData(softwareDataText, "Location", Left(softwareLocation,98))
							softwareDataText = addCategoryData(softwareDataText, "InstallDate", softwareInstallDate)
							softwareDataText = addCategoryData(softwareDataText, "Usage", swUsage)
							softwareDataText = addCategoryData(softwareDataText, "Key", subkey)
							softwareDataText = softwareDataText &  "/>"
						End if
					end if
				end if

			Next
		end if
	Next
End if


'Softwares installed
'=============================================
for itr=1 to 2
	continue = true
	Set objCtx = CreateObject("WbemScripting.SWbemNamedValueSet")
	if(itr=2) then
		objCtx.Add "__ProviderArchitecture", 32
	elseif (is64BitOS) then
		objCtx.Add "__ProviderArchitecture", 64
	else
		continue = false
	end if
	objCtx.Add "__RequiredArchitecture", TRUE
    if(continue)then
        Set objLocator = CreateObject("Wbemscripting.SWbemLocator")
        Set objServices = objLocator.ConnectServer("localhost","root\default","","",,,,objCtx)
        Set objReg1 = objServices.Get("StdRegProv") 
        objReg1.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys

        If NOT ISNULL(arrSubKeys) then
            For Each subkey In arrSubKeys
			    subkeyPath = strKeyPath & "\" & subkey
                objReg1.GetStringValue HKEY_LOCAL_MACHINE, subkeyPath, "DisplayName", softwareName
				objReg1.GetStringValue HKEY_LOCAL_MACHINE, subkeyPath, "ParentKeyName", parentKeyName
                objReg1.GetStringValue HKEY_LOCAL_MACHINE, subkeyPath, "DisplayVersion", softwareVersion
                objReg1.GetStringValue HKEY_LOCAL_MACHINE, subkeyPath, "Publisher", softwarePublisher
                objReg1.GetStringValue HKEY_LOCAL_MACHINE, subkeyPath, "InstallLocation", softwareLocation
                objReg1.GetStringValue HKEY_LOCAL_MACHINE, subkeyPath, "InstallDate", softwareInstallDate
                keyForSoftwareUsage = "SOFTWARE\Microsoft\Windows\CurrentVersion\App Management\ARPCache\" & subkey
                objReg1.GetBinaryValue HKEY_LOCAL_MACHINE, keyForSoftwareUsage, "SlowInfoCache", usageData
			    swUsage = getSoftwareUsage(usageData)
    			If (NOT ISNULL(softwareName) And (ISNULL(parentKeyName) OR parentKeyName="") And (InStr(Lcase(softwareName),"windows internet explorer") = 0)) then
					if(softwareName <> "" and (not softList.Exists(softwareName) or licenseKeys.Exists(subkey))) then
					    if ((InStr(Lcase(softwareName),"adobe") > 0) or (InStr(Lcase(softwareName),"acrobat") > 0)) then
						  	 licenseKey = getAdobeLicenseKey(objReg,subkeyPath,softwareName)
							 objReg.GetDWORDValue HKEY_LOCAL_MACHINE, subkeyPath, "SystemComponent", systemComponent
							 systemComponent=""&systemComponent
							 if (licenseKey="" and systemComponent="1") then
							     isAddSoftware = false
							 else
								 if (licenseKey="") then
								  	 tmpCheck = adobeSoftHavingLicKeys.Item(softwareName)
									 if((Not isNULL(tmpCheck)) and (tmpCheck<>""))then
										isAddSoftware = false
									 End if
								 end if
							 End if
							 if ((licenseKey<> "") and (Not adobeSoftHavingLicKeys.Exists(softwareName)))then
								adobeSoftHavingLicKeys.add softwareName,licenseKey
							 end if
                        elseif ((StrComp(softwareName,"microsoft sql server 2000",1) = 0) or (StrComp(softwareName,"microsoft sql server 2005",1) = 0) or (StrComp(softwareName,"microsoft sql server 2008",1) = 0) or (StrComp(softwareName,"microsoft sql server 2008 R2",1) = 0))then
                            softwareName = updateSQLEdition(softwareName,HKEY_LOCAL_MACHINE,"SOFTWARE\Microsoft",objReg1)
                        End if	

                        softList.add softwareName,softwareName
                        softwareDataText = softwareDataText & "<Software "
                        softwareDataText = addCategoryData(softwareDataText, "Name", Left(softwareName,248))
                        softwareDataText = addCategoryData(softwareDataText, "Version", Left(softwareVersion,28))
                        softwareDataText = addCategoryData(softwareDataText, "Vendor", Left(softwarePublisher,98))
                        softwareDataText = addCategoryData(softwareDataText, "Location", Left(softwareLocation,98))
                        softwareDataText = addCategoryData(softwareDataText, "InstallDate", softwareInstallDate)
                        softwareDataText = addCategoryData(softwareDataText, "Usage", swUsage)
                        softwareDataText = addCategoryData(softwareDataText, "Key", subkey)
                        softwareDataText = softwareDataText &  "/>"
                    end if
	    		end if
	    	Next
    	end if
    End if
Next 
Err.clear

'Enumerate IE in vista and later OS
'==================================

objReg.GetStringValue HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\Internet Explorer\", "Version", ieVersion
if not isNULL(ieVersion) then
	idx = InStr(ieVersion,".")
	If(idx>0) Then
		ieMajorVersion = Trim(Left(ieVersion,idx-1))
        if(ieMajorVersion > 8) Then
             objReg.GetStringValue HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\Internet Explorer\", "svcVersion", ieNewVersion
             if not isNULL(ieNewVersion) then
                 idx = InStr(ieNewVersion,".")
                 If(idx>0) Then
                     ieMajorVersion = Trim(Left(ieNewVersion,idx-1))
                     ieVersion = ieNewVersion
                 End If
             End If
         End If        
         softwareName = "Windows Internet Explorer " & ieMajorVersion
	End If
	softwareDataText = softwareDataText & "<Software "
	softwareDataText = addCategoryData(softwareDataText, "Name", Left(softwareName,248))
	softwareDataText = addCategoryData(softwareDataText, "Version", ieVersion)
	softwareDataText = softwareDataText &  "/>"
End  if

softwareDataText = softwareDataText & "</InstalledProgramsList>"
Err.clear

'Oracle Info
'===========
On Error Resume Next
softwareDataText = softwareDataText & "<OracleInfo>" 
oracleKeyRoot = "SOFTWARE\ORACLE"
objReg.EnumKey HKEY_LOCAL_MACHINE, oracleKeyRoot, arrSubKeys
If NOT ISNULL(arrSubKeys) then
	For Each subkey In arrSubKeys
		if(Left(subkey,4)="HOME" Or Left(subkey,7)="KEY_Ora") then
			
			subkeyPath = oracleKeyRoot & "\" & subkey
			objReg.GetStringValue HKEY_LOCAL_MACHINE, subkeyPath, "SQLPATH", sqlPath
			objReg.GetStringValue HKEY_LOCAL_MACHINE, subkeyPath, "ORACLE_GROUP_NAME", groupName
			objReg.GetStringValue HKEY_LOCAL_MACHINE, subkeyPath, "ORACLE_HOME_NAME", homeName
			objReg.GetStringValue HKEY_LOCAL_MACHINE, subkeyPath, "ORACLE_BUNDLE_NAME", bundleName
			objReg.GetStringValue HKEY_LOCAL_MACHINE, subkeyPath, "VERSION", version
			objReg.GetStringValue HKEY_LOCAL_MACHINE, subkeyPath, "ORACLE_HOME", home
			softwareDataText = softwareDataText & "<Software "
			softwareDataText = addCategoryData(softwareDataText, "sqlPath", sqlPath)
			softwareDataText = addCategoryData(softwareDataText, "groupName", groupName)
			softwareDataText = addCategoryData(softwareDataText, "homeName", homeName)
			softwareDataText = addCategoryData(softwareDataText, "bundleName", bundleName)
			softwareDataText = addCategoryData(softwareDataText, "version", version)
			softwareDataText = addCategoryData(softwareDataText, "home", home)
			softwareDataText = addCategoryData(softwareDataText, "Key", subkey)
			softwareDataText = softwareDataText &  "/>"
		end if
	Next
end if
softwareDataText = softwareDataText & "</OracleInfo>"
softwareDataText = softwareDataText & "</Software_Info>"
outputText = outputText  & softwareDataText
Err.clear

end if

'Adding node info so that it helps in parsing fast
'=================================================
nodeInfo = "<Node "
scanTime = "" & Now
nodeInfo = addCategoryData(nodeInfo,"ComputerName",nodeName)
nodeInfo = addCategoryData(nodeInfo,"ServiceTag", Left(serviceTag,49))
nodeInfo  = addCategoryData(nodeInfo, "TaskId",agentTaskID)
nodeInfo  = addCategoryData(nodeInfo, "MacAddress",macAddress)
nodeInfo  = addCategoryData(nodeInfo, "LastScanTime",scanTime)
nodeInfo = nodeInfo & " >" 
outputText = Replace(outputText,"NODE_TAG", nodeInfo)
outputText = outputText  & "</Node> </DocRoot>"
'Converting Data to XML
'======================
set xml = CreateObject("Microsoft.xmldom")
xml.async = false
loadResult = xml.loadxml(outputText)

On Error Resume Next

hexErrorCode = ""
errordescription = ""
succesMsg = ""
errorMessage = ""
cause = ""
resolution = ""

'Sending Data via http
'=====================
if(isAgentMode) Then
	saveXMLFile=true
	computerNameForFile=agentTaskID
end if

if Err Then
	handleError(Err)
	saveXMLFile=true	
end if

'Saving XML File
'===============
if(saveXMLFile=true) then
	'Saving the Inventory Data as XML File - will be useful to troubleshoot the Error
	fileName=".\result.txt" 
	' agent task id 10 represents invocation through activex component. for activex it should be result.txt
	if computerNameForFile <> "10" then
		fileName = ".\" & computerNameForFile & ".xml"
	end if	
	xml.save fileName
end if

'To check PrinterName
'===================
Function checkAndRemoveServerName(pname)
        if isNull(pname) Then
            retStr = ""
        else
	    retStr = pname
        end if
	pos = InStr(pname,"Microsoft XPS Document Writer")
	if  InStr(pname,"Microsoft XPS Document Writer") > 0 Then
		retStr=""
	end if
	' for handling printer Fax
	if InStr(pname,"Fax")>0 Then
		retStr=""
	elseif InStr(pname,"PDF995") > 0 Then
		retStr=""
	elseif InStr(pname,"PDF-XChange 3.0") > 0 Then
		retStr=""
	elseif InStr(pname,"WebEx Document Loader") > 0 Then
		retStr=""
	elseif InStr(pname,"Symantec Fax Starter Edition") > 0 Then
		retStr=""
	elseif InStr(pname,"Microsoft Office Live Meeting Document Writer") > 0 Then
		retStr=""
	elseif InStr(pname,"QuickBooks PDF Converter")>0 Then
		retStr=""
	elseif InStr(pname,"Microsoft Office Document Image Writer")>0 Then
		retStr=""
	elseif InStr(pname,"CutePDF Writer")>0 Then
		retStr=""
	elseif InStr(pname,"SolidPDF XChange")>0 Then
		retStr=""
	elseif InStr(pname,"FRx Document Image Writer")>0 Then
		retStr=""
	elseif InStr(pname,"ActiveTouch Document Loader")>0 Then
		retStr=""
    elseif InStr(pname,"PageManager PDF Writer")>0 Then
		retStr=""
	elseif InStr(pname,"Send To OneNote 2010")>0 Then
		retStr=""    
	'checking for server name
	elseif InStr(pname,"\\") > 0 Then
		startPos = InStr(pname,"\\")
		endpos = InStr(startPos+2,pname,"\")
		if endpos > 0 Then
			retStr = Right(pname,(len(pname)-(endpos)))
		else
			retStr = Right(pname,(len(pname)-(startPos+1)))
		end if
	end if
	checkAndRemoveServerName = retStr
End Function
'To Add Data
'===========
Function addCategoryData(outputText, category, data)
	'For handling problem when data contains &
	pos=InStr(data,"&")
	if pos>0 Then
		data = Replace(data,"&","&amp;")
	end if
	'For handling problem when data contains <
	pos=InStr(data,"<")
	if pos>0 Then
		data = Replace(data,"<","&lt;")
	end if
	'For handling problem when data contains >
	pos=InStr(data,">")
	if pos>0 Then
		
		data = Replace(data,">","&gt;")
		
	end if
	'For handling problem when data contains DOUBLEQUOTE
	pos=InStr(data,doubleQuote)
	if pos>0 Then
		data = Replace(data,doubleQuote,"&quot;")
	end if
	data = removeInvalidXMLChar(data)
	retStr = outputText 
	if NOT ISNULL(data) then
		retStr = retStr & spaceString 
		retStr = retStr & category 
		retStr = retStr & equalString 
		retStr = retStr & doubleQuote 
		retStr = retStr &  Trim(data) 
		retStr = retStr & doubleQuote
	end if
	addCategoryData=retStr
End Function

'To get the licence Key
'======================
Public Function getLicenceKey(bDigitalProductID,version)
    Dim bProductKey()
    Dim bKeyChars(24)
    Dim ilByte
    Dim nCur
    Dim sCDKey
    Dim ilKeyByte
    Dim ilBit
    ReDim Preserve bProductKey(14)
    Set objShell = CreateObject("WScript.Shell")
    Set objShell = Nothing
    
    if isNull(version)then
	    version = 0 ' number less than 14, so that it detects the key for lower versions of office and OS
    end if
    if (version<14) then
	    For ilByte = 52 To 66
		    bProductKey(ilByte - 52) = bDigitalProductID(ilByte)
	    Next
    else
	    i=0
	    For ilByte = CLng("&h"&328) To CLng("&h"&328)+14
		    bProductKey(i) = bDigitalProductID(ilByte)
		    i=i+1
	    Next
    end if
    
    bKeyChars(0) = Asc("B")
    bKeyChars(1) = Asc("C")
    bKeyChars(2) = Asc("D")
    bKeyChars(3) = Asc("F")
    bKeyChars(4) = Asc("G")
    bKeyChars(5) = Asc("H")
    bKeyChars(6) = Asc("J")
    bKeyChars(7) = Asc("K")
    bKeyChars(8) = Asc("M")
    bKeyChars(9) = Asc("P")
    bKeyChars(10) = Asc("Q")
    bKeyChars(11) = Asc("R")
    bKeyChars(12) = Asc("T")
    bKeyChars(13) = Asc("V")
    bKeyChars(14) = Asc("W")
    bKeyChars(15) = Asc("X")
    bKeyChars(16) = Asc("Y")
    bKeyChars(17) = Asc("2")
    bKeyChars(18) = Asc("3")
    bKeyChars(19) = Asc("4")
    bKeyChars(20) = Asc("6")
    bKeyChars(21) = Asc("7")
    bKeyChars(22) = Asc("8")
    bKeyChars(23) = Asc("9")
    For ilByte = 24 To 0 Step -1
      nCur = 0
      For ilKeyByte = 14 To 0 Step -1
        nCur = nCur * 256 Xor bProductKey(ilKeyByte)
        bProductKey(ilKeyByte) = Int(nCur / 24)
        nCur = nCur Mod 24
      Next
      sCDKey = Chr(bKeyChars(nCur)) & sCDKey
      If ilByte Mod 5 = 0 And ilByte <> 0 Then sCDKey = "-" & sCDKey
    Next
    getLicenceKey = sCDKey
End Function

'To get windows key
'=====================
Function ConvertToKey(Key) 
    Const KeyOffset = 52 
    Dim isWin8, Maps, i, j, Current, KeyOutput, Last, keypart1, insert 
    'Check if OS is Windows 8 
    isWin8 = (Key(66) \ 6) And 1 
    Key(66) = (Key(66) And &HF7) Or ((isWin8 And 2) * 4) 
    i = 24 
    Maps = "BCDFGHJKMPQRTVWXY2346789" 
    Do 
           Current= 0 
        j = 14 
        Do 
           Current = Current* 256 
           Current = Key(j + KeyOffset) + Current 
           Key(j + KeyOffset) = (Current \ 24) 
           Current=Current Mod 24 
            j = j -1 
        Loop While j >= 0 
        i = i -1 
        KeyOutput = Mid(Maps,Current+ 1, 1) & KeyOutput 
        Last = Current 
    Loop While i >= 0  
     
    If (isWin8 = 1) Then 
        keypart1 = Mid(KeyOutput, 2, Last) 
        insert = "N" 
        KeyOutput = Replace(KeyOutput, keypart1, keypart1 & insert, 2, 1, 0) 
        If Last = 0 Then KeyOutput = insert & KeyOutput 
    End If     
     
 
    ConvertToKey = Mid(KeyOutput, 1, 5) & "-" & Mid(KeyOutput, 6, 5) & "-" & Mid(KeyOutput, 11, 5) & "-" & Mid(KeyOutput, 16, 5) & "-" & Mid(KeyOutput, 21, 5)  
End Function 

'To get Software usage
'=====================
Function getSoftwareUsage(softwareUsageData)
	getSoftwareUsage = "Not Known" 
	if not ISNULL(softwareUsageData) then
		usageLevel = CLng(softwareUsageData(24))
		if(usageLevel<3) then
			getSoftwareUsage = "Rarely" 
		elseif (usageLevel<9) then
			getSoftwareUsage = "Occasionally" 
		elseif (usageLevel<>255) then
			getSoftwareUsage = "Frequently" 
		end if
	end if
End Function


'To get the Logical Disk Type
'============================
Function getDiskType(diskType)
	getDiskType="Unknown"
	if(diskType="1") then
		getDiskType="No Root Directory"
	elseif (diskType="2") then
		getDiskType="Removable Disk"
	elseif (diskType="3") then
		getDiskType="Local Disk"
	elseif (diskType="4") then
		getDiskType="Network Drive"
	elseif (diskType="5") then
		getDiskType="Compact Disc"
	elseif (diskType="6") then
		getDiskType="RAM Disk"
	end if
End Function


'To Remove the Index in Network Caption
'======================================
Function getNetworkCaption(captionString)
	getNetworkCaption = captionString
	idx = InStr(captionString," ")
	If(idx>0) Then
		getNetworkCaption = Trim(Mid(captionString,idx))
	End If
End Function

'To Get Monitor Serial number
'============================

Function readValueFromEDID(matchingArray,indexArray,rawEDIDArray)
  Dim idx, matchFound, strTemp
  For i=0 To UBOUND(indexArray)
	  matchFound  = True
	  For idx = 0 To 3
		If CInt( matchingArray( idx )  ) <> CInt( rawEDIDArray( idx + indexArray(i) ) ) Then matchFound  = False
	  Next
	  If matchFound Then
		For idx = 4 To 17
		  Select Case rawEDIDArray( indexArray(i) + idx )
			Case 0
			  strTemp = strTemp & " "
			Case 7
			  strTemp = strTemp & " "
			Case 10
			  strTemp = strTemp & " "
			Case 13
			  strTemp = strTemp & " "
			Case Else
			  strTemp = strTemp & Chr( rawEDIDArray( indexArray(i) + idx ) )
		  End Select
		Next
		strTemp = Trim( strTemp )
		readValueFromEDID = strTemp
	  End If
	Next
End Function

Function GetMonitorSerialNumber(EDID)
	
	sernumstr=""
	sernum=0
	for i=0 to ubound(EDID)-4
		if EDID(i)=0 AND EDID(i+1)=0 AND EDID(i+2)=0 AND EDID(i+3)=255 AND EDID(i+4)=0 Then
			' if sernum<>0 then
				'sMsgString = "a second serial number has been found!"
				'WScript.ECho sMsgString
				'suspicious=1
			'end if
			sernum=i+4
		end if
	next
	if sernum<>0 then
		endstr=0
		sernumstr=""
		for i=1 to 13
			if EDID(sernum+i)=10 then 
    			endstr=1
			end if
			if endstr=0 then
				sernumstr=sernumstr & chr(EDID(sernum+i))
			end if

		next
		'sMsgString = "Monitor serial number: " & sernumstr
		'WScript.Echo sMsgString
	else
	sernumstr="-"
	'sMsgString = "No monitor serial number found. Possibly the computer is a laptop."
	'WScript.Echo sMsgString
	end if
	GetMonitorSerialNumber = sernumstr

End Function

'To Handle Error
'===============
Function handleError(Err)
	if Err Then
		displayErrorMessage = getErrorMessage(Err)
		Wscript.Echo displayErrorMessage 	
		Err.clear
	end if
End Function


'To Get the Error Message for Given Error Code
'=============================================
Function getErrorMessage(Err)
	hexErrorCode = "0x" & hex(Err.Number)
	errorMessage = newLineConst & newLineConst
	errorMessage = errorMessage & "Exception occured while running the Script. (ManageEngine ServiceDesk Plus)"
	errorMessage = errorMessage & newLineConst
	errorMessage = errorMessage & newLineConst & newLineConst

	if(hexErrorCode="0x800C0005") Then
		resolution = "The ServiceDesk Plus ondemand server is not reachable from this machine.Check the server name and port number in the script."
	elseif(hexErrorCode="0x80004005") Then
		resolution = "The ServiceDesk Plus ondemand server is not reachable from this machine.Check the server name and port number in the script."
	elseif(hexErrorCode="0x80070005") Then
		resolution = "The ServiceDesk Plus ondemand server is not reachable from this machine.Check the server name and port number in the script."
	else
		errorMessage = errorMessage & "Error Code : 0x" & hex(Err.Number)
		errorMessage = errorMessage & newLineConst
		errorMessage = errorMessage & "Error Desc : " & Err.description
		errorMessage = errorMessage & newLineConst
		resolution = "For resolution please report the above Error Message to " & supportMailID
	end if

	errorMessage = errorMessage & resolution
	errorMessage = errorMessage & newLineConst
	getErrorMessage = errorMessage
End Function
Function GetFQDN(computerName)

        ' Returns Fully Qualified Domain Name
        ' from reverse DNS lookup via nslookup.exe
        Set objWMISvc = GetObject( "winmgmts:\\.\root\cimv2" )
        Set colItems = objWMISvc.ExecQuery( "Select * from Win32_ComputerSystem", , 48 )
        For Each objItem in colItems
                strComputerDomain = objItem.Domain
                WScript.Echo "Computer Domain: " & strComputerDomain
        Next

        getFQDN = computerName & "." & strComputerDomain
End Function
Function removeInvalidXMLChar(xmldata)
	
	Dim strLen
	Dim isValidChar
	Dim current
	Dim retdata

	retdata = xmldata
	strLen = len(xmldata)
	for i=1 to strLen
		current = AscW(Mid(xmldata,i,1))
        if current < 0 then
            current = 65536 + current
        end if
		isValidChar = false
		isValidChar = isValidChar or CBool(current = HexToDec("9"))
		isValidChar = isValidChar or CBool(current = HexToDec("A"))
		isValidChar = isValidChar or CBool(current = HexToDec("D"))
		isValidChar = isValidChar or (CBool(current >= HexToDec("20")) and CBool(current <= HexToDec("D7FF")))
		isValidChar = isValidChar or (CBool(current >= HexToDec("E000")) and CBool(current <= HexToDec("FFFD")))
		isValidChar = isValidChar or (CBool(current >= HexToDec("10000")) and CBool(current <= HexToDec("10FFFF")))
		if(Not isValidChar) then
			retdata = Replace(retdata,chr(current),"")
		End if
	Next
	removeInvalidXMLChar = retdata
End Function

'Hex to decimal
Function HexToDec(hexVal)

	dim dec
	dim strLen
  	dim digit
  	dim intValue
	dim i

	dec = 0
	strLen = len(hexVal)
	for i =  strLen to 1 step -1
 
		digit = instr("0123456789ABCDEF", ucase(mid(hexVal, i, 1)))-1
		if digit >= 0 then
        		intValue = digit * (16 ^ (len(hexVal)-i))
	  		dec = dec + intValue
		else 
 	  		dec = 0
		        i = 0 	'exit for
		end if
	next

  HexToDec = dec
End Function

'printers from registry
'======================
Function getPrinterInfo(data,printercount)
	On Error Resume Next
	objReg.EnumKey HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Print\Providers\",providers 'LanMan Print Services\Servers\",arrSubKeys  ' winsys\Printers\Gemini"
	If NOT ISNULL(providers) then
		For Each provider In providers
			objReg.EnumKey HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Print\Providers\"&provider&"\Servers\",servers
			If NOT ISNULL(servers) then
				For Each server In servers
					objReg.EnumKey HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Print\Providers\"&provider&"\Servers\"&server&"\Printers",printers
					If NOT ISNULL(printers) then
						For Each printer In printers
							objReg.GetStringValue HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Print\Providers\"&provider&"\Servers\"&server&"\Printers\"&printer&"\DsSpooler", "PrinterName", printerName
							printerName = checkAndRemoveServerName(printerName)
							if(Not isNULL(printerName) and printerName<>"" and (Not printersList.Exists(printerName))) then
                                printersList.add printerName,printerName
								data = data & "<Printer_Info "
								data = addCategoryData(data, "Name", printerName)
								objReg.GetStringValue HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Print\Providers\"&provider&"\Servers\"&server&"\Printers\"&printer&"\DsSpooler", "driverName", printDriver
								data = addCategoryData(data, "Model", printDriver)
								objReg.GetMultiStringValue HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Print\Providers\"&provider&"\Servers\"&server&"\Printers\"&printer&"\DsSpooler", "portName", printerPorts

								For Each portName In printerPorts
									printerPort = portName
								Next

								data = addCategoryData(data, "PortName", printerPort)
								objReg.GetStringValue HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Print\Providers\"&provider&"\Servers\"&server&"\Printers\"&printer&"\DsSpooler", "Location", location
								data = addCategoryData(data, "Location", location)
								objReg.GetStringValue HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Print\Providers\"&provider&"\Servers\"&server&"\Printers\"&printer&"\DsSpooler", "Description", description
								data = addCategoryData(data, "Comment", description)
								objReg.GetStringValue HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Print\Providers\"&provider&"\Servers\"&server&"\Printers\"&printer&"\DsSpooler", "serverName", serverName
                                serverName = Replace(serverName,"\\","")
                                dotIndex = InStr(serverName,".")
                                if dotIndex > 0 then
                                    serverName = Left(serverName,dotIndex-1)
                                end if
								data = addCategoryData(data, "ServerName", serverName)
								data = addCategoryData(data, "Network", "Network")
								data = data & "/>"
							End if
						Next
					End if

				Next
			End if
		Next
	End if
	getPrinterInfo = data
	Err.clear
End Function

Function updateSQLEdition(sofName,regMainKey,regSubKey,regObj)
	if ((StrComp(sofName,"microsoft sql server 2000",1) = 0) or (StrComp(sofName,"microsoft sql server 2005",1) = 0) or (StrComp(sofName,"microsoft sql server 2008",1) = 0) or (StrComp(sofName,"microsoft sql server 2008 R2",1) = 0))then
		regObj.GetStringValue regMainKey, regSubKey&"\Microsoft SQL Server\MSSQL.1\Setup", "Edition", sqlEdition  'sql 2005 default instance
		if (Not isNull(sqlEdition) And sqlEdition <> "") then
			'WScript.Echo "2005"
			sofName = sofName&" ("& sqlEdition &")"	
		else
			regObj.GetStringValue regMainKey, regSubKey&"\MSSQLServer\Setup", "Edition", sqlEdition	'sql 2000 default instance
			if (Not isNull(sqlEdition) And sqlEdition <> "") then
				'WScript.Echo "2000"
				sofName = sofName&" ("&sqlEdition&")"	
			else
				regObj.GetMultiStringValue regMainKey, regSubKey&"\Microsoft SQL Server\", "InstalledInstances", sqlInsatlledInstances
				'WScript.Echo "3 "&sqlInsatlledInstances(0)
				For Each sqlInsatlledInstance In sqlInsatlledInstances
					if ( Not isNull(sqlInsatlledInstance) or sqlInsatlledInstance <> "") then
						regObj.GetStringValue regMainKey, "SOFTWARE\Microsoft\Microsoft SQL Server\Instance Names\SQL", sqlInsatlledInstance, sqlInstance
						'WScript.Echo "4 "&sqlInstance

						if (Not isNull(sqlInstance) And sqlInstance <> "") then
							regObj.GetStringValue regMainKey, regSubKey&"\Microsoft SQL Server\"&sqlInstance&"\Setup", "Edition", sqlEdition
							'WScript.Echo "5 "&sqlEdition
							if (Not isNull(sqlEdition) And sqlEdition <> "") then
								sofName = sofName&" ("&sqlEdition&")"
								exit for
							end if
						end if
					end if
				Next
			end if
		End if
	End if
	updateSQLEdition = sofName
End Function

Function getAdobeLicenseKey(wmiObj,regKey,softName)
	On Error Resume Next
	adobeLicKey = ""

	wmiObj.GetStringValue HKEY_LOCAL_MACHINE,regKey,"EPIC_SERIAL",adobeLicKey
	if( isNULL(adobeLicKey) or Trim(adobeLicKey)="")then
		wmiObj.GetStringValue HKEY_LOCAL_MACHINE,regKey,"SERIAL",adobeLicKey
		if(isNULL(adobeLicKey) or Trim(adobeLicKey)="")then
			verIndex=InstrRev(Trim(softName)," ")
			softNameWithOutVersion = Mid(softName,1,verIndex-1)
			version=Mid(softName,verIndex+1,1)
			wmiObj.EnumKey HKEY_LOCAL_MACHINE, "SOFTWARE\Adobe\"&softNameWithOutVersion,adobeArrSubKeys1

			If NOT ISNULL(adobeArrSubKeys1) then

				For Each abobeSubkey1 In adobeArrSubKeys1
					if(inStr(abobeSubkey1,version)=1)then 'if abobeSubkey1 starts with version
						wmiObj.GetStringValue HKEY_LOCAL_MACHINE,"SOFTWARE\Adobe\"&softNameWithOutVersion&"\"&abobeSubkey1&"\Registration","SERIAL",adobeLicKey
						if(not ISNULL(adobeLicKey) and adobeLicKey<>"")then
							exit for
						else
							'WScript.Echo "Adobe LicenceKey is not found"
						End if
					End if
				Next
			End if
			if(ISNULL(adobeLicKey) or Trim(adobeLicKey)="")then
				productIndex=InStr(Trim(softName), " ")
				productName = Mid(softName,1,productIndex-1)
				softNameWithoutProduct = Mid(softName,productIndex+1,verIndex-productIndex-1)
				wmiObj.EnumKey HKEY_LOCAL_MACHINE, "SOFTWARE\Adobe\"&softNameWithoutProduct,adobeArrSubKeys2

				If NOT ISNULL(adobeArrSubKeys2) then

					For Each abobeSubkey2 In adobeArrSubKeys2
						if(inStr(abobeSubkey2,version)=1)then 'if abobeSubkey2 starts with version

							wmiObj.GetStringValue HKEY_LOCAL_MACHINE,"SOFTWARE\Adobe\"&softNameWithoutProduct&"\"&abobeSubkey2&"\Registration","SERIAL",adobeLicKey
							if(not ISNULL(adobeLicKey) and adobeLicKey<>"")then
								exit for
							else
								'WScript.Echo "Adobe LicenceKey is not found"
							End if
						End if
					Next
				End if
			End if


		End if
	End if
	if(ISNULL(adobeLicKey))then
		adobeLicKey=""
	End if
	getAdobeLicenseKey = adobeLicKey
End Function

Function GetDNSDomain(hostName)
    Set objShell = CreateObject("WScript.Shell")
    Set objExec = objShell.Exec("cmd /c nslookup " & hostName)
    While objExec.Status
        WScript.Sleep 100
    Wend
    strOutput = objExec.StdOut.ReadAll
    GetDNSDomain = ""
    set regExp = new RegExp
    regExp.Pattern = ".*Name:[ ]*" & hostName & ".(.*)"
    regExp.IgnoreCase=true
    regExp.Global=true
    set CurrentMatches = regExp.Execute(strOutput)
    if CurrentMatches.Count >= 1 then
	Set CurrentMatch = CurrentMatches(0)
	if CurrentMatch.SubMatches.Count >= 1 then
		GetDNSDomain = CurrentMatch.SubMatches(0)
		GetDNSDomain=Trim(GetDNSDomain)
	End if
    End if
end function

Function GetLastLoggedUser()
    Set objCtx = CreateObject("WbemScripting.SWbemNamedValueSet")
    if (is64BitOS) then
        objCtx.Add "__ProviderArchitecture", 64
    end if
    Set objLocator = CreateObject("Wbemscripting.SWbemLocator")
    Set objServices = objLocator.ConnectServer("localhost","root\default","","",,,,objCtx)
    Set objReg1 = objServices.Get("StdRegProv") 
    objReg1.GetStringValue HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI" , "LastLoggedOnUser" , userName
    GetLastLoggedUser = userName
End Function

Sub printLog(msg)
	WScript.Echo msg
End Sub

Function getBooleanStr(booleanVal)
    booleanStr = "True"
    if(booleanVal=False) then
	booleanStr="False"
    End if
    getBooleanStr = booleanStr
End Function
'
'Version Info
'$Id$