none
Cod, RRS feed

  • Pergunta

  •  

    Estou tendo problemas com o meu, ele roda mas nao esta salvando aonde pedi, vou postar abaixo

     

    Code Snippet

    On error resume Next
    Const ForReading = 1
    Const ForAppending = 8

    Dim strLogDir
    Dim strCompName
    Dim strUserName
    Dim site

    strComputer = "."

    '### Se for servidor aborta o script ###

    Set os = GetObject("winmgmts:").InstancesOf("Win32_OperatingSystem")
    For Each obj In os
       Set prps = obj.Properties_
       OSLang = prps("OSLanguage").value
       BldNum = prps("BuildNumber").value
    Next

    Select Case BldNum
     Case "2600" OPERATINGSYSTEM = "WINDOWS-XP"
     Case "2195" OPERATINGSYSTEM = "WINDOWS-2000"
     Case "1381" OPERATINGSYSTEM = "WINDOWS-NT"
     Case "3790" OPERATINGSYSTEM = "Windows 2003"
    End Select

    If OPERATINGSYSTEM <> "WINDOWS-XP" Then
     wscript.quit()
    End If

    Set WshShell = WScript.CreateObject("WScript.Shell")
    Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
    Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_ComputerSystem")
    Set colProcessors = objWMIService.ExecQuery("Select * from Win32_Processor")
    Set colDiskDrives = objWMIService.ExecQuery ("Select * from Win32_DiskDrive")
    Set colOSes = objWMIService.ExecQuery("Select * from Win32_OperatingSystem")
    Set IPConfigSet = objWMIService.ExecQuery ("Select * from Win32_NetworkAdapterConfiguration Where IPEnabled=TRUE")

    '--------------------- Verifica se já rodou se já finaliza o script -----------------

    regkey = "HKCU\Software\Inventario\HardWare\Executado"
    regval = -1
    regval = WshShell.RegRead(regkey)

    If regval = "Sim" then 'Estação já foi inventariada finaliza script

     wscript.quit()
     
    Else 'Executa o inventário

    strCompName = WshShell.ExpandEnvironmentStrings("%COMPUTERNAME%")
    strUserName  = WshShell.ExpandEnvironmentStrings("%USERNAME%")


    strLogDir = "\\m0008\sv08doc\Administrativo\Tecnologia da Informação\Controles e Documentos\Inventario"
    strLogFile = "inventario"


    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set objTextFile = objFSO.CreateTextFile(strLogDir & "\" & strCompName & ".log", True)
    objTextFile.WriteLine "----------------------------------------- Inventário Iniciado: " & Date & " - " & time & " ----------------------------------------- "
    objTextFile.WriteLine "User Name: " & strUserName
    objTextFile.WriteLine "Computer Name: " & strCompName

    For Each IPConfig in IPConfigSet
        If Not IsNull(IPConfig.IPAddress) Then
            For i=LBound(IPConfig.IPAddress) to UBound(IPConfig.IPAddress)
                objTextFile.WriteLine "IP Adress: " &  IPConfig.IPAddress(i)
            Next
        End If
    Next

    'Modelo e fabricante
    For Each objItem In colItems
      objTextFile.WriteLine "Computer Manufacturer: " & objItem.Manufacturer
      objTextFile.WriteLine "Computer Model: " & objItem.Model
      objTextFile.WriteLine "Total Physical Memory: " & objItem.TotalPhysicalMemory
      objTextFile.WriteLine "System Type: " & objItem.SystemType
      objTextFile.WriteLine "Number Of Processors: " & objItem.NumberOfProcessors
    Next

    'Processador
    For Each objProcessor in colProcessors
      objTextFile.WriteLine "Processor Manufacturer: " & objProcessor.Manufacturer
      objTextFile.WriteLine "Processor Name: " & Trim(objProcessor.Name)
      objTextFile.WriteLine "Processor Description: " & objProcessor.Description
      objTextFile.WriteLine "Processor ID: " & objProcessor.ProcessorID
      objTextFile.WriteLine "Address Width: " & objProcessor.AddressWidth
      objTextFile.WriteLine "Data Width: " & objProcessor.DataWidth
      objTextFile.WriteLine "Family: " & objProcessor.Family
      objTextFile.WriteLine "Maximum Clock Speed: " & objProcessor.MaxClockSpeed
    Next

    'Hard Disk
    For each objDiskDrive in colDiskDrives 
        objTextFile.WriteLine "Har Disk Caption: " & vbTab &  objDiskDrive.Caption
        objTextFile.WriteLine "Interface Type: " & vbTab & objDiskDrive.InterfaceType
        objTextFile.WriteLine "Manufacturer: " & vbTab & objDiskDrive.Manufacturer
        objTextFile.WriteLine "Hard Disk Model: " & vbTab &  objDiskDrive.Model
        objTextFile.WriteLine "Size: " & vbTab &  objDiskDrive.Size    
    Next

    'Sistema Operacional
    For Each objOS in colOSes
      objTextFile.WriteLine "OS Caption: " & objOS.Caption 'Name
      objTextFile.WriteLine "OS Version: " & objOS.Version 'Version & build
      objTextFile.WriteLine "OS Build Number: " & objOS.BuildNumber 'Build
      objTextFile.WriteLine "OS Build Type: " & objOS.BuildType
      objTextFile.WriteLine "OS Type: " & objOS.OSType
      objTextFile.WriteLine "Other Type Description: " & objOS.OtherTypeDescription
      objTextFile.WriteLine "OS Service Pack: " & objOS.ServicePackMajorVersion & "." & objOS.ServicePackMinorVersion
    Next

    'Marca estação para não rodar novamente

     regkey = "HKCU\Software\Inventario\HardWare\Executado"
     regval = "Sim"
     WshShell.regWrite regkey, regval, "REG_SZ"

    objTextFile.WriteLine "----------------------------------------- Inventário Finalizado: " & Date & " - " & time & "------------------------------"
    objTextFile.Close

    End If

     

     

    bruno.macagnani@biobrasilsa.com.br

    Favor responder nesse email se possivel


     

    quarta-feira, 18 de junho de 2008 12:29