Posted on 2009-04-22
Last Modified: 2012-05-06
I would like to have the timeand date also printed in txt file.
I cant seem to find a objcomputer.time&date. How do one actually find these properties or is it methods?
Its difficult to know what to use, is there a list somewhere to check what X do for obj.Computer.X?

For Each objComputer in colComputer
strComputer = objComputer.Name
TimeDate = objComputer.Time

Thanks very much! /D
Question by:Dabosa
    LVL 67

    Expert Comment

    As an example:

    strComputer = "."
    Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
    Set colItems = objWMIService.ExecQuery("Select * From Win32_LocalTime")
    For Each objItem in colItems
        Wscript.Echo "Month: " & objItem.Month
        Wscript.Echo "Day: " & objItem.Day
        Wscript.Echo "Year: " & objItem.Year
        Wscript.Echo "Hour: " & objItem.Hour
        Wscript.Echo "Minute: " & objItem.Minute
        Wscript.Echo "Second: " & objItem.Second

    Open in new window

    LVL 67

    Accepted Solution

    With the other question's code...
     FilePath = "\\servername\folder\"
    Const HKEY_CLASSES_ROOT = &H80000000
    Dim objFSO : Set objFSO = CreateObject("Scripting.FileSystemObject")
    Dim objTextFile, BIOSData, OSData, CSData, DTData, strComputer
    If objFSO.FolderExists ("C:\Program Files\Adobe\Reader 9.0\Reader") Then 
    End If
    Sub  DoUpdate()
      Set objTextFile = objFSO.OpenTextFile(FilePath & "Acrobat9Installed.txt",8)
      objTextFile.WriteLine strComputer & vbTab & DTData & vbtab & CSData & vbTab & BIOSData & vbTab & OSData
      Set objRegistry = GetObject("winmgmts:\\.\root\default:StdRegProv")
      strKeyPath = "SOFTWARE\Adobe\Acrobat\Exe"
      strValueName = ""
      strValue = """C:\Program Files\Adobe\Reader 9.0\Reader\AcroRd32.exe"""
      objRegistry.SetStringValue HKEY_CLASSES_ROOT, strKeyPath, strValueName, strValue
    End Sub
    Sub DoMissing()
      Set objTextFile = objFSO.OpenTextFile(FilePath & "Acrobat9NOTInstalled.txt",8)
      objTextFile.WriteLine strComputer & & vbTab & DTData & vbtab & CSData & vbTab & BIOSData & vbTab & OSData
    End Sub
    Sub GetDetails()
      Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
      Set colBIOS = objWMIService.ExecQuery  ("SELECT * FROM Win32_BIOS")
      For Each objBIOS in colBIOS
        BIOSData = objBIOS.Manufacturer & vbtab & objBIOS.SerialNumber & vbtab & objBIOS.SMBIOSBIOSVersion 
      Set colData = objWMIService.ExecQuery ("SELECT * From Win32_LocalTime")
      For Each objItem in colData
        DTData = objItem.Month & objItem.Day & objItem.Year & vbTab & objItem.Hour & objItem.Minute & objItem.Second
      Set colSettings = objWMIService.ExecQuery  ("SELECT * FROM Win32_OperatingSystem")
      For Each objOperatingSystem in colSettings
        OSData = objOperatingSystem.Name & vbtab & objOperatingSystem.Version & vbtab & objOperatingSystem.ServicePackMajorVersion & vbtab & _
             objOperatingSystem.Manufacturer & vbtab & objOperatingSystem.WindowsDirectory & vbtab & objOperatingSystem.FreePhysicalMemory & vbtab & _
             objOperatingSystem.TotalVirtualMemorySize & vbtab & objOperatingSystem.FreeVirtualMemory 
      Set colComputer = objWMIService.ExecQuery ("SELECT * FROM Win32_ComputerSystem")
      For Each objComputer in colComputer
        strComputer = objComputer.Name
        CSData = objComputer.Username & vbtab & objComputer.Manufacturer & vbtab & objComputer.Model & vbtab &  objComputer.CurrentTimeZone
    End Sub

    Open in new window


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Do You Know the 4 Main Threat Actor Types?

    Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

    Not long ago I saw a question in the VB Script forum that I thought would not take much time. You can read that question (Question ID  ( Here (http…
    Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    12 Experts available now in Live!

    Get 1:1 Help Now