0% found this document useful (0 votes)
26 views9 pages

Inventario de Equipos y Sistemas

This document contains code for generating an inventory report on a computer system. It collects hardware, software, and network configuration information using WMI and the Windows registry, and writes the results to multiple CSV files stored locally or on a network share. The information collected includes computer name, manufacturer, OS details, software licensing, and network adapter configuration.

Uploaded by

Gerardo Ortega
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views9 pages

Inventario de Equipos y Sistemas

This document contains code for generating an inventory report on a computer system. It collects hardware, software, and network configuration information using WMI and the Windows registry, and writes the results to multiple CSV files stored locally or on a network share. The information collected includes computer name, manufacturer, OS details, software licensing, and network adapter configuration.

Uploaded by

Gerardo Ortega
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

Const ForWriting = 2

On Error Resume Next

Set objNTInfo = [Link]("WinNTSystemInfo")


strFileName = [Link]
[Link] "Iniciando Inventario de: " & strFileName

If [Link] <> 0 Then

Set objNTInfo = [Link]( "[Link]" )


strFileName = [Link]( "%COMPUTERNAME%" )
[Link] "Iniciando Inventario de" & strFileName

[Link]

End If

Dim d : d = Date()
Dim dateStr : dateStr = Year(d) & "-" & Right("00" & Month(d), 2) & "-" &
Right("00" & Day(d), 2)

On Error Resume Next

strComputer = "."
strUserName = "Administrador"
strPassword = "*Rollo48*" 'Poner la contrase�a entre las comillas
strPath = "\\[Link]\Test"

Set objFSO = [Link]("[Link]")


Set objNet = [Link]("[Link]")

[Link] "", strPath, false, strUserName, strPassword


If [Link] <> 0 Then

fullpath = [Link](folderName)
[Link] "El inventario se guardar� de forma local en: " & fullpath

Else

fullpath = strPath
[Link] "El inventario se guardar� en el recurso: " & fullpath

[Link]

End If

'-----------------------------------------------------EQUIPO
--------------------------------------

strFullName = fullpath & "\" & "01_HW_" & strFileName & "_" & dateStr
Set objLogFile = [Link](strFullName & ".csv", ForWriting, True)

[Link]
[Link] "EQUIPO VIA WMI"
[Link]

[Link] "Caption" & vbtab


[Link] "Domain" & vbtab
[Link] "Manufacturer" & vbtab
[Link] "Model" & vbtab
[Link] "NumberOfLogicalProcessors" & vbtab
[Link] "NumberOfProcessors" & vbtab
[Link] "System Type" & vbtab

[Link]

On Error Resume Next

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")


Set colItems = [Link]( _
"SELECT * FROM Win32_ComputerSystem",,48)

For Each objItem in colItems

[Link] [Link] & vbtab


[Link] [Link] & vbtab
[Link] [Link] & vbtab
[Link] [Link] & vbtab
[Link] [Link] & vbtab
[Link] [Link] & vbtab
[Link] [Link] & vbtab
[Link]
Next

If [Link] <> 0 Then


[Link]
[Link] "Error Equipo WMI: " & [Link] & vbtab
[Link] "Error (Hex): " & Hex([Link]) & vbtab
[Link] "Source: " & [Link] & vbtab
[Link] "Description: " & [Link]
[Link]
[Link]
End If

[Link]
[Link] "EQUIPO VIA REGISTRO"
[Link]

[Link] "Nombre del Equipo" & vbtab


[Link] "Fabricante del Equipo" & vbtab
[Link] "Modelo" & vbtab
[Link] "Num de Procesadores" &vbtab
[Link] "Virtual Machine Name" &vbtab
[Link] "Physical Host Name" &vbtab

[Link]

On Error Resume Next

Const HKLM = &H80000002


Set objReg = GetObject("winmgmts://" & strComputer & "/root/default:StdRegProv")

strRegKey = "SYSTEM\CurrentControlSet\Control\"
strRegSub1 = "SystemInformation"
strRegSub2 = "ComputerName\ComputerName"
strRegSub3 = "Session Manager\Environment"
strRegKey1 = "SOFTWARE\Microsoft\Virtual Machine\Guest\Parameters"

[Link] HKLM, strRegKey & strRegSub2, "ComputerName", strValue


[Link] strValue & vbtab

[Link] HKLM, strRegKey & strRegSub1, "SystemManufacturer",


strValue
[Link] strValue & vbtab

[Link] HKLM, strRegKey & strRegSub1, "SystemProductName",


strValue
[Link] strValue & vbtab

[Link] HKLM, strRegKey & strRegSub3, "NUMBER_OF_PROCESSORS",


strValue
[Link] strValue & vbtab

[Link] HKLM, strRegKey1 , "VirtualMachineName", strValue


[Link] strValue & vbtab

[Link] HKLM, strRegKey1 , "PhysicalHostName", strValue


[Link] strValue & vbtab

[Link]

If [Link] <> 0 Then


[Link]
[Link] "Error Equipo Registro: " & [Link] & vbtab
[Link] "Error (Hex): " & Hex([Link]) & vbtab
[Link] "Source: " & [Link] & vbtab
[Link] "Description: " & [Link]
[Link]
[Link]
End If

[Link]
[Link] "FIN DE REPORTE"
[Link]

[Link]
'-----------------------------------------------------SISTEMA
OPERATIVO----------------------------

strFullName = fullpath & "\" & "02_SO_" & strFileName & "_" & dateStr
Set objLogFile = [Link](strFullName & ".csv", ForWriting, True)

[Link]
[Link] "SISTEMA OPERATIVO VIA WMI"
[Link]

[Link] "BuildType" & vbtab


[Link] "Caption" & vbtab
[Link] "CSDVersion" & vbtab
[Link] "Description" & vbtab
[Link] "NumberOfLicensedUsers" & vbtab
[Link] "SerialNumber" & vbtab
[Link] "OSArchitecture" & vbtab
[Link]

On Error Resume Next

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")


Set colItems1 = [Link]( _
"SELECT * FROM Win32_OperatingSystem",,48)

For Each objItem in colItems1


[Link] [Link] & vbtab
[Link] [Link] & vbtab
[Link] [Link] & vbtab
[Link] [Link] & vbtab
[Link] [Link] & vbtab
[Link] [Link] & vbtab
[Link] [Link] & vbtab

[Link]
Next

If [Link] <> 0 Then


[Link]
[Link] "Error Sistema Operativo WMI: " & [Link] & vbtab
[Link] "Error (Hex): " & Hex([Link]) & vbtab
[Link] "Source: " & [Link] & vbtab
[Link] "Description: " & [Link]
[Link]
[Link]
End If

[Link]
[Link] "SISTEMA OPERATIVO REGISTRO"
[Link]

[Link] "Sistema Operativo" & vbtab


[Link] "ServicePack" & vbtab
[Link] "Edicion" & vbtab
[Link] "Instalacion"

[Link]

On Error Resume Next


Set objReg = GetObject("winmgmts://" & strComputer & "/root/default:StdRegProv")

strRegKey = "SOFTWARE\Microsoft\Windows NT\CurrentVersion"

[Link] HKLM, strRegKey, "ProductName", strValue


[Link] strValue & vbtab

[Link] HKLM, strRegKey, "CSDVersion", strValue


[Link] strValue & vbtab

[Link] HKLM, strRegKey, "EditionID", strValue


[Link] strValue & vbtab

[Link] HKLM, strRegKey, "InstallationType", strValue


[Link] strValue
[Link]

If [Link] <> 0 Then


[Link]
[Link] "Error Sistema Operativo Registro: " & [Link] & vbtab
[Link] "Error (Hex): " & Hex([Link]) & vbtab
[Link] "Source: " & [Link] & vbtab
[Link] "Description: " & [Link]
[Link]
[Link]
End If

[Link]
[Link] "FIN DE REPORTE"
[Link]

[Link]

'-------------------------------------------LICENCIAMIENTO DE
WINDOWS--------------------------------

strFullName = fullpath & "\" & "03_Lic_" & strFileName & "_" & dateStr
Set objLogFile = [Link](strFullName & ".csv", ForWriting, True)

[Link]
[Link] "LICENCIAIENTO"
[Link]

[Link] "Description" & vbtab


[Link] "LicenseFamily" & vbtab
[Link] "LicenseIsAddon" & vbtab
[Link] "LicenseStatus" & vbtab
[Link] "Name" & vbtab
[Link] "PartialProductKey" & vbtab

[Link]

On Error Resume Next

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")


Set colItems2 = [Link]( _
"SELECT * FROM SoftwareLicensingProduct",,48)

For Each objItem in colItems2


[Link] [Link] & vbtab
[Link] [Link] & vbtab
[Link] [Link] & vbtab
[Link] [Link] & vbtab
[Link] [Link] & vbtab
[Link] [Link] & vbtab
[Link]
Next

If [Link] <> 0 Then


[Link]
[Link] "Error Licenciamiento WMI: " & [Link] & vbtab
[Link] "Error (Hex): " & Hex([Link]) & vbtab
[Link] "Source: " & [Link] & vbtab
[Link] "Description: " & [Link]
[Link]
[Link]
End If

[Link]
[Link] "FIN DE REPORTE"
[Link]

[Link]
'--------------------------------------------CONFIGURACION DE
RED-----------------------------------

strFullName = fullpath & "\" & "04_Red_" & strFileName & "_" & dateStr
Set objLogFile = [Link](strFullName & ".csv", ForWriting, True)

[Link]
[Link] "TARJETAS DE RED"
[Link]

[Link] "Caption" & vbtab


[Link] "Description" & vbtab
[Link] "DHCPServer" & vbtab
[Link] "DNSDomain" & vbtab
[Link] "DNSHostName" & vbtab
[Link] "IPXAddress" & vbtab
[Link] "MACAddress" & vbtab
[Link] "IPAddress" & vbtab

[Link]

On Error Resume Next

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")


Set colItems4 = [Link]( _
"SELECT * FROM Win32_NetworkAdapterConfiguration",,48)

For Each objItem in colItems4


[Link] [Link] & vbtab
[Link] [Link] & vbtab
[Link] [Link] & vbtab
[Link] [Link] & vbtab
[Link] [Link] & vbtab
[Link] [Link] & vbtab
[Link] [Link] & vbtab

If isNull([Link]) Then
[Link] "" & vbtab
Else
[Link] Join([Link], ",") & vbtab
End If

[Link]
Next

If [Link] <> 0 Then


[Link]
[Link] "Error WMI: " & [Link] & vbtab
[Link] "Error (Hex): " & Hex([Link]) & vbtab
[Link] "Source: " & [Link] & vbtab
[Link] "Description: " & [Link]
[Link]
[Link]
End If

[Link]
[Link] "FIN DE REPORTE"
[Link]

[Link]

'-------------------------------------------------PRODUCTOS WMI
------------------------------------

strFullName = fullpath & "\" & "05_Prod_" & strFileName & "_" & dateStr
Set objLogFile = [Link](strFullName & ".csv", ForWriting, True)

[Link]
[Link] "PRODUCTOS VIA WMI"
[Link]

[Link] "Caption" & vbtab


[Link] "Vendor" & vbtab
[Link] "Version" & vbtab
[Link] "InstallDate" & vbtab
[Link] "InstallState"

[Link]

On Error Resume Next

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")


Set colItems3 = [Link]( _
"SELECT * FROM Win32_Product",,48)

For Each objItem in colItems3


[Link] [Link] & vbtab
[Link] [Link] & vbtab
[Link] [Link] & vbtab
[Link] [Link] & vbtab
[Link] [Link]
[Link]
Next

If [Link] <> 0 Then


[Link]
[Link] "Error Productos: WMI: " & [Link] & vbtab
[Link] "Error (Hex): " & Hex([Link]) & vbtab
[Link] "Source: " & [Link] & vbtab
[Link] "Description: " & [Link]
[Link]
[Link]
End If

[Link]
[Link] "FIN DE REPORTE"
[Link]
[Link]

'--------------------------------------------PRODUCTOS REGISTRO
------------------------------------

[Link]
[Link] "PRODCUTOS VIA REGISTRO"
[Link]

[Link] "Display Name" & vbtab


[Link] "Display Version" & vbtab
[Link] "Install Date" & vbtab

[Link]

On Error Resume Next

Set objReg = GetObject("winmgmts://" & strComputer & "/root/default:StdRegProv")

Const strBaseKey = _
"Software\Microsoft\Windows\CurrentVersion\Uninstall\"
[Link] HKLM, strBaseKey, arrSubKeys

For Each strSubKey In arrSubKeys

intRet = [Link](HKLM, strBaseKey & strSubKey, _


"DisplayName", strValue)

intRet2 = [Link](HKLM, strBaseKey & strSubKey, _


"DisplayVersion", strValue2)

intRet3 = [Link](HKLM, strBaseKey & strSubKey, _


"InstallDate", strValue3)

If intRet <> 0 Then


intRet = [Link](HKLM, strBaseKey & strSubKey, _
"QuietDisplayName", strValue)
End If

If (strValue <> "") and (intRet = 0) Then


[Link] strValue & vbtab
[Link] strValue2 & vbtab
[Link] strValue3 & vbtab
[Link]
End If

Next

If [Link] <> 0 Then


[Link]
[Link] "Error Productos: Registro: " & [Link] & vbtab
[Link] "Error (Hex): " & Hex([Link]) & vbtab
[Link] "Source: " & [Link] & vbtab
[Link] "Description: " & [Link]
[Link]
[Link]
End If

[Link]
[Link] "FIN DE REPORTE"
[Link]

[Link]

[Link] "Inventario Completo"

You might also like