none
VBS Inventario RRS feed

  • Pergunta

  • Boa Tarde

    Fiz uma customização num arquivo de inventário .vbs, mas ainda estou com um problema, segue abaixo o arquivo e minha dúvida.

    - Como posso pegar o serial do windows por este script? Até achei algumas coisas na internet, mas so como message box, queria deixar dentro deste script.

    Obrigado

    On Error Resume Next
    
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    
      Set objNetwork = CreateObject("WScript.Network")
      STRcomputer =objNetwork.ComputerName
      STRTipoServer = "MS"
      'Set dtmConvertedDate = CreateObject("WbemScripting.SWbemDateTime")
      On Error Resume Next
      Set objFSO = CreateObject("Scripting.FileSystemObject")
      Set objtextfile = objFSO.deleteFile("\\v3m-0027\Programas\Inventario\" & STRcomputer & ".HTML")
      Set objtextfile = objFSO.CreateTextFile("\\v3m-0027\Programas\Inventario\" & STRcomputer & ".HTML", Forwritting)
      Objtextfile.writeline "<html>"
      Objtextfile.writeline "<!-----Inventario de Computador----->"
      Objtextfile.writeline "<!-----Filipe Denny----->"
      Objtextfile.writeline "<!-----2018----->"
      Objtextfile.writeline "<!-----Versão 1.0----->"
      Objtextfile.writeline "<TFOOT STYLE='font-weight:bold; color:#FFFFFF'>"
      Objtextfile.writeline "<TR>"
      Objtextfile.writeline "<TD COLSPAN=5 ALIGN='center'>"
      Objtextfile.writeline "</B>"
      Objtextfile.writeline "</TR>"
      Objtextfile.writeline "</TFOOT>"
    
      Lin_log = 4
      Set objNetwork = CreateObject("WScript.Network")
    
      objtextfile.WriteLine "<center><a name='#menu'></center></a>"
      objtextfile.WriteLine "<br>"
      objtextfile.WriteLine "<center><H1><b> Inventario de Computador </b></h1></center>"
      objtextfile.WriteLine "<!WKS" & STRcomputer & "Fim_WKS>"
      objtextfile.WriteLine "<center><H1><b>" & STRcomputer & "</b></h1></center>"
      '
      Objtextfile.writeline "<Font face='arial'><ol>"
      Objtextfile.writeline "<Font face='arial'><h5><li><a href='#SO'>Sistema Operacional</a></li></h5>"
      Objtextfile.writeline "<Font face='arial'><h5><li><a href='#proc'>Processadores</a></li></h5>"
      Objtextfile.writeline "<Font face='arial'><h5><li><a href='#bios'>Bios e Hardware</a></li></h5>"
       Objtextfile.writeline "<Font face='arial'><h5><li><a href='#usuarios'>Usuarios Locais</a></li></h5>"
      Objtextfile.writeline "<Font face='arial'><h5><li><a href='#software'>Softwares Instalados</a></li></h5>"
      Objtextfile.writeline "</ol></font>"
      '
      set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" _
             & STRcomputer & "\root\cimv2")
      Set colItems = objWMIService.ExecQuery("Select * from Win32_OperatingSystem")
      objtextfile.WriteLine "<ul>"
       objtextfile.WriteLine "<li><b><h2><a name='#SO'> Sistema Operacional</a></h2></b>"
      For Each objItem In colItems
       dtmConvertedDate.Value = objItem.InstallDate
        dtmInstallDate = dtmConvertedDate.GetVarDate
       objtextfile.WriteLine "<ul>"
       objtextfile.WriteLine "<!SO" & objItem.Caption & "Fim_SO>"
        objtextfile.WriteLine "<Font face='arial'><li><pre>" & objItem.Caption & "</font>"
          objtextfile.WriteLine "<Font face='arial'><li>Versão..............................: " &  objItem.Version & "</font>"
        objtextfile.WriteLine "<Font face='arial'><li>Service Pack....................: " &  objItem.ServicePackMajorVersion & "</font>"
       objtextfile.WriteLine "<Font face='arial'><li>Serial Numbe...................: " & objItem.SerialNumber & "</font>"
      Next
      Set ZoneSet = GetObject("winmgmts:").InstancesOf ("Win32_TimeZone")
      for each System in ZoneSet
      objtextfile.WriteLine "<Font face='arial'><li>Time Zone........................:" & System.StandardName & "</font></pre>"
      next
      objtextfile.WriteLine "</ul>"
      objtextfile.WriteLine "</font></ul>"
      Objtextfile.writeline "<font size=1 face='Helvetica' color=blue><a href='#menu'>Menu</a></font>"
      '
      ' Coletando Processadores
      Set colItems = objWMIService.ExecQuery("Select * from Win32_Processor")
      objtextfile.WriteLine "<ul>"
       objtextfile.WriteLine "<li><b><h2><a name='#proc'> Processadores</a></h2></b>"
    
      For Each objItem In colItems
       objtextfile.WriteLine "<Font face='arial'><ul>"
       objtextfile.WriteLine "<Font face='arial'><li>" & objItem.Description
       Objtextfile.writeline "<!Processador>"
       objtextfile.WriteLine "<Font face='arial'>" & objItem.Name
       Objtextfile.writeline "<!Fim_Proc>"
       objtextfile.WriteLine "<Font face='arial'>" & objItem.MaxClockSpeed & " MHZ"
       objtextfile.WriteLine "</ul>"
      Next
      objtextfile.WriteLine "</ul></font>"
      Objtextfile.writeline "<font size=1 face='Helvetica' color=blue><a href='#menu'>Menu</a></font>"
      '
      ' Coletando Informações da BIOS
      Set colBIOS = objWMIService.ExecQuery("Select * from Win32_BIOS")
      objtextfile.WriteLine "<ul>"
       objtextfile.WriteLine "<li><b><a name='#bios'>Fabricante / Modelo</a></b>"
    
      For Each objbios In colBIOS
       objtextfile.WriteLine "<Font face='arial'><ul>"
       objtextfile.WriteLine "<!Fabricante>"
       objtextfile.WriteLine "<li><pre>Fabricante : " & objbios.Manufacturer
       objtextfile.WriteLine "<!Fim_Fabricante>"
       objtextfile.WriteLine "<!Serie>"
       objtextfile.WriteLine "<li>Serie     : " & objbios.SerialNumber
       objtextfile.WriteLine "<!Fim_Serie>"
       objtextfile.WriteLine "</ul>"
      Next
    
      ' Coletando Modelo do Equipamento
      Set colSettings = objWMIService.ExecQuery("Select * from Win32_ComputerSystem")
      For Each objComputer In colSettings
       objtextfile.WriteLine "<ul><Font face='arial'>"
       objtextfile.WriteLine "<!Modelo>"
       objtextfile.WriteLine "<li><pre>Modelo Equipamento : " & objComputer.Model & "</pre>"
       objtextfile.WriteLine "<!Fim_Modelo>"
       objtextfile.WriteLine "</ul>"
      Next
      objtextfile.WriteLine "</ul></font>"
      objtextfile.WriteLine "</ul>"
      w_tipos = Array("Unknown", "Other", "DRAM,Synchronous DRAM", "Cache DRAM", "EDO,EDRAM", "VRAM", "SRAM", _
         "RAM", "ROM", "Flash", "EEPROM", "FEPROM", "EPROM", "CDRAM", "3DRAM", "SDRAM", "SGRAM", _
         "RDRAM", "DDR")
      totalslots = 0
      objtextfile.WriteLine "<ul>"
       objtextfile.WriteLine "<li><b><h2> Memória</h2></b>"
    
      Set SlotMem = objWMIService.ExecQuery _
       ("Select * from Win32_PhysicalMemoryArray")
       For Each objItem In SlotMem
        totalslots = totalslots + objItem.MemoryDevices
       Next
      totalpentes = 0
      Set colItems = objWMIService.ExecQuery("Select * from Win32_PhysicalMemory")
      cont_mem=0
      For Each objItem In colItems
       objtextfile.WriteLine "<Font face='arial'><ul>"
       objtextfile.WriteLine " <li>" & objItem.Tag
       objtextfile.WriteLine " " & Int(objItem.Capacity / 1024 / 1024)
       objtextfile.WriteLine " " & w_tipos(objItem.MemoryType)
       objtextfile.WriteLine " " & objItem.BankLabel
       objtextfile.WriteLine " " & "Ativa"
       totalpentes = totalpentes + 1
       objtextfile.WriteLine "</ul>"
      cont_mem = cont_mem + objItem.Capacity
      Next
    
       objtextfile.WriteLine "<!Memoria" & Int(cont_mem / 1024 / 1024) & "Fim_Mem>"
    
      For i = totalpentes + 1 To totalslots
       objtextfile.WriteLine "<Font face='arial'><ul>"
       objtextfile.WriteLine " <li> Memoria " & i - 1
       objtextfile.WriteLine " Vazio"
       objtextfile.WriteLine "</ul>"
      Next
      Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
      Set colItems = objWMIService.ExecQuery( _
       "SELECT * FROM Win32_PageFileUsage",,48)
      objtextfile.WriteLine "</ul>"
      objtextfile.WriteLine "<ul><br>"
      objtextfile.WriteLine "<Font face='arial'><b> Arquivo de Paginação</b><br>"
      objtextfile.WriteLine "<table border=2 width=500>"
      objtextfile.WriteLine "<tr><td><center>localização</center></td><td><center>Tamanho</center></td><td><center>Utilização Atual</center></td><td><center>" & _
      "Pico de Utilização</center></td></tr>"
      For Each objItem In colItems
       wlinha = " "
       wlinha = "<center><tr><td>"
       wlinha=wlinha & objItem.Description & "</td></center><td><center>"
       wlinha=wlinha & objItem.AllocatedBaseSize & "MB" & "</td></center><td><center>"
       wlinha=wlinha & objItem.CurrentUsage & "MB"& "</td></center><td><center>"
       wlinha=wlinha & objItem.PeakUsage & "MB" & "</td></center></tr>"
       objtextfile.WriteLine wlinha
      Next
      objtextfile.WriteLine "</table>"
      objtextfile.WriteLine "</ul>"
      Objtextfile.writeline "<font size=1 face='Helvetica' color=blue><a href='#menu'>Menu</a></font>"
      '
      'Coleta usuarios locais
      Set colAccounts = GetObject("WinNT://" & STRcomputer & "")
      Set colGroups = GetObject("WinNT://" & STRcomputer & "")
      colAccounts.Filter = Array("user")
      colGroups.Filter = Array("group")
      objtextfile.WriteLine "<ul>"
      objtextfile.WriteLine "<li><b><h2><a name='#usuarios'> Usuarios Locais</a></h2></b>"
      objtextfile.WriteLine "</ul>"
      objtextfile.WriteLine "<table border=2 width=1000>"
      objtextfile.WriteLine "<tr><td><center>Login</center></td><td><center>Nome Completo</center></td><td><center>Descriçao</center>" & _
      "</td><td><center>Status</center></td><td><center>Grupos</center></td></tr>"
      For Each objUser In colAccounts
       Wgrupo = " "
       If objUser.AccountDisabled then
      wstatus = "Inativa"
       Else
      wstatus = "Ativa"
       End if
       For Each objGroup In colGroups
        For Each objuserMBR In objGroup.Members
         If objuserMBR.Name = objUser.Name Then
          Wgrupo = Wgrupo & objGroup.Name & "<br>"
         End If
        Next
       Next
       If Len(objUser.FullName) <= 1 Then
        wfulname = "-"
       Else
       wfulname = objUser.FullName
       End If
       If Len(objUser.Description) <= 1 then
      wdescricao = "-"
       else
      wdescricao = objUser.Description
       end if
       objtextfile.WriteLine "<tr><td>" & objUser.Name & "</td><td>" & " " _
       & wfulname & "</td><td>" _
       & wdescricao & "</td><td>" _
       & wstatus & "</td><td>" _
       & Wgrupo & "</td></tr> "
      Next
      objtextfile.WriteLine "</ul>"
      objtextfile.WriteLine "</table>"
      Objtextfile.writeline "<font size=1 face='Helvetica' color=blue><a href='#menu'>Menu</a></font>"
      '
      'Coleta Software
      Const HKLM = &H80000002 'HKEY_LOCAL_MACHINE
      strKey = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\"
      strEntry1a = "DisplayName"
      strEntry1b = "QuietDisplayName"
      strEntry2 = "InstallDate"
      strEntry3 = "VersionMajor"
      strEntry4 = "VersionMinor"
      strEntry5 = "EstimatedSize"
    
      objtextfile.WriteLine "<ul>"
      objtextfile.WriteLine "<li><b><h2><a name='#software'> Softwares Instalados</a></h2></b>"
      objtextfile.WriteLine "</ul>"
      'objtextfile.WriteLine "<table border=2>"
      objtextfile.WriteLine "<tr><td>Software / Hotfix</td></tr>"
      Set objReg = GetObject("winmgmts://" & STRcomputer & _
      "/root/default:StdRegProv")
      objReg.EnumKey HKLM, strKey, arrSubkeys
      For Each strSubkey In arrSubkeys
      ' wlinha = "<tr><td>"
       wlinha=""
      intRet1 = objReg.GetStringValue(HKLM, strKey & strSubkey, _
       strEntry1a, strValue1)
      If intRet1 <> 0 Then
       objReg.GetStringValue HKLM, strKey & strSubkey, _
       strEntry1b, strValue1
      End If
      If strValue1 <> "" Then
       wlinha = wlinha + strValue1 '+ "</td><td>"
      End If
      objReg.GetDWORDValue HKLM, strKey & strSubkey, _
      strEntry3, intValue3
      objReg.GetDWORDValue HKLM, strKey & strSubkey, _
       strEntry4, intValue4
      If intValue3 <> "" Then
       wlinha = wlinha + intValue3 + "." + intValue4 '"</td></tr>"
      End If
      If Len(wlinha) > 8 Then
       objtextfile.WriteLine wlinha + "<br>"
      End If
      Next
      objtextfile.WriteLine "</ul>"
      'objtextfile.WriteLine "</table>"
      Objtextfile.writeline "<font size=1 face='Helvetica' color=blue><a href='#menu'>Menu</a></font>"
      '
    wscript.echo "FIM"


    segunda-feira, 9 de abril de 2018 18:59

Todas as Respostas