Results 1 to 5 of 5

Thread: VBS Script To Get Machine Information And Send To Excel

  1. #1
    Join Date
    Sep 2009
    Posts
    5

    VBS Script To Get Machine Information And Send To Excel

    Hello All,

    I found this script below and it works great but, I have a text file with all the PC's I want to get the infomation on. It is C:\temp\computers.txt. Can someone asssit me in this? Thanks



    strComputer = InputBox ("Enter Machine Name")
    Set objExcel = CreateObject("Excel.Application")
    objExcel.Visible = True
    objExcel.Workbooks.Add
    objExcel.Cells(1, 1).Value = "Name"
    objExcel.Cells(2, 1).Value = "Caption"
    objExcel.Cells(3, 1).Value = "Version"
    objExcel.Cells(4, 1).Value = "Registered User"
    objExcel.Cells(5, 1).Value = "Serial Number"
    objExcel.Cells(6, 1).Value = "CSD Version"
    objExcel.Cells(7, 1).Value = "Description"
    objExcel.Cells(8, 1).Value = "Last Boot Up Time"
    objExcel.Cells(9, 1).Value = "Local Date Time"
    objExcel.Cells(10, 1).Value = "Organization"
    objExcel.Cells(11, 1).Value = "Domain"
    objExcel.Cells(12, 1).Value = "Manufacturer"
    objExcel.Cells(13, 1).Value = "Model"
    objExcel.Cells(14, 1).Value = "Number Of Processors"
    objExcel.Cells(15, 1).Value = "Primary Owner Name"
    objExcel.Cells(16, 1).Value = "System Type"
    objExcel.Cells(17, 1).Value = "Total Physical Memory"
    objExcel.Cells(18, 1).Value = "User Name"
    objExcel.Cells(19, 1).Value = "Caption"
    objExcel.Cells(20, 1).Value = "Manufacturer"
    objExcel.Cells(21, 1).Value = "Name"
    objExcel.Cells(22, 1).Value = "Release Date"
    objExcel.Cells(23, 1).Value = "Serial Number"
    objExcel.Cells(24, 1).Value = "SMBIOS BIOS Version"
    objExcel.Cells(25, 1).Value = "Version"
    Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
    Set colItems = objWMIService.ExecQuery("Select * from Win32_OperatingSystem")
    For Each objItem in colItems
    objExcel.Cells(1, 2).Value = objItem.CSName
    objExcel.Cells(2, 2).Value = objItem.Caption
    objExcel.Cells(3, 2).Value = objItem.Version
    objExcel.Cells(4, 2).Value = objItem.RegisteredUser
    objExcel.Cells(5, 2).Value = objItem.SerialNumber
    objExcel.Cells(6, 2).Value = objItem.CSDVersion
    objExcel.Cells(7, 2).Value = objItem.Description
    objExcel.Cells(8, 2).Value = objItem.LastBootUpTime
    objExcel.Cells(9, 2).Value = objItem.LocalDateTime
    objExcel.Cells(10, 2).Value = objItem.Organization
    Next
    Set colItems = objWMIService.ExecQuery("Select * from Win32_ComputerSystem")
    For Each objItem in colItems
    objExcel.Cells(11, 2).Value = objItem.Domain
    objExcel.Cells(12, 2).Value = objItem.Manufacturer
    objExcel.Cells(13, 2).Value = objItem.Model
    objExcel.Cells(14, 2).Value = objItem.NumberOfProcessors
    objExcel.Cells(15, 2).Value = objItem.PrimaryOwnerName
    objExcel.Cells(16, 2).Value = objItem.SystemType
    objExcel.Cells(17, 2).Value = (objItem.TotalPhysicalMemory /1024) & " MB"
    objExcel.Cells(18, 2).Value = objItem.UserName
    Next
    Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
    Set colItems = objWMIService.ExecQuery("Select * from Win32_BIOS")
    For Each objItem in colItems
    objExcel.Cells(19, 2).Value = objItem.Caption
    objExcel.Cells(20, 2).Value = objItem.Manufacturer
    objExcel.Cells(21, 2).Value = objItem.Name
    objExcel.Cells(22, 2).Value = objItem.ReleaseDate
    objExcel.Cells(23, 2).Value = objItem.SerialNumber
    objExcel.Cells(24, 2).Value = objItem.SMBIOSBIOSVersion
    objExcel.Cells(25, 2).Value = objItem.Version
    Next
    objExcel.Range("A1:A25").Select
    objExcel.Selection.Font.ColorIndex = 11
    objExcel.Selection.Font.Bold = True
    objExcel.Cells.EntireColumn.AutoFit
    MsgBox "Done"

  2. #2
    Join Date
    Nov 2008
    Posts
    1,022

    Re: VBS Script To Get Machine Information And Send To Excel

    You can use WMI in a VBScript program to retrieve text file information. So to retrieve the information, the code should be something like below:

    Code:
    Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "C:\temp\computers.txt")

  3. #3
    Join Date
    Sep 2009
    Posts
    5

    Re: VBS Script To Get Machine Information And Send To Excel

    Thank you for your help but, I have one more question.

    the code below works great but, It opens an excel workbook for each PC in my list. How can I have it so, It add all the info from my pcs in one workbook?

  4. #4
    Join Date
    Nov 2008
    Posts
    1,022

    Re: VBS Script To Get Machine Information And Send To Excel

    Do you mean by your code given in your first post? If it is so then it creates the new Excel workbook because this is how you have coded it.

    Set objExcel = CreateObject("Excel.Application")

  5. #5
    Join Date
    Sep 2009
    Posts
    5

    Re: VBS Script To Get Machine Information And Send To Excel

    I am new at this. how can I change it so it add all my PC in one workbook?

Similar Threads

  1. Running script on remote machine
    By SuderMan in forum Windows Server Help
    Replies: 12
    Last Post: 25-08-2010, 06:51 PM
  2. Script to add a machine to domain
    By martinez7251 in forum Windows Software
    Replies: 1
    Last Post: 11-05-2010, 11:23 PM
  3. Script execution machine available by mail
    By HardWeaR in forum Software Development
    Replies: 3
    Last Post: 11-12-2009, 02:01 PM
  4. Check if process is running on Local Machine using VB script
    By Aspen in forum Software Development
    Replies: 3
    Last Post: 03-09-2009, 09:46 PM
  5. Send A Test Fax to check a Fax machine
    By MagicAlonso in forum Hardware Peripherals
    Replies: 3
    Last Post: 29-07-2009, 10:56 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,982,791.03178 seconds with 16 queries