[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Need a write to text file solution . . .

Posted on 2006-06-12
2
Medium Priority
?
896 Views
Last Modified: 2012-05-05
Currently this is my script:

On Error Resume Next

Const wbemFlagReturnImmediately = &h10
Const wbemFlagForwardOnly = &h20

arrComputers = Array("floyd_adamsxp","ALEX_KHAZAN_XP")
For Each strComputer In arrComputers
   WScript.Echo
   WScript.Echo "=========================================="
   WScript.Echo "Computer: " & strComputer
   WScript.Echo "=========================================="

   Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
   Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_BIOS", "WQL", _
                                          wbemFlagReturnImmediately + wbemFlagForwardOnly)

   For Each objItem In colItems
        WScript.Echo "Name: " & objItem.Name
       WScript.Echo "Model: " & objItem.Model
Next
Set colSMBIOS = objWMIService.ExecQuery _
    ("Select * from Win32_SystemEnclosure")
For Each objSMBIOS in colSMBIOS
    Wscript.Echo "Asset Tag: " & objSMBIOS.SMBIOSAssetTag
Next
Set colBIOS = objWMIService.ExecQuery _
    ("Select * from Win32_BIOS")
For each objBIOS in colBIOS
     Wscript.Echo "Serial Number: " & objBIOS.SerialNumber
   Next
Next


Function WMIDateStringToDate(dtmDate)
WScript.Echo dtm:
      WMIDateStringToDate = CDate(Mid(dtmDate, 5, 2) & "/" & _
      Mid(dtmDate, 7, 2) & "/" & Left(dtmDate, 4) _
      & " " & Mid (dtmDate, 9, 2) & ":" & Mid(dtmDate, 11, 2) & ":" & Mid(dtmDate,13, 2))
End Function

What I would like to do is export the data to a text file, but I've been having a difficult time doing it for some reason.  Please help.  Lots of points!
0
Comment
Question by:campbe07
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 
LVL 35

Accepted Solution

by:
[ fanpages ] earned 2000 total points
ID: 16885578
Hi,

How about something like...

Dim objFileSystemObject
Dim objFSO_TextFile
Dim strLog_Filename

strLog_Filename                         = "C:\Output.txt"

Set objFileSystemObject                    = CreateObject("Scripting.FileSystemObject")

If Not (objFileSystemObject.FileExists(strLog_Filename)) Then
   Set objFSO_TextFile                    = objFileSystemObject.CreateTextFile(strLog_Filename)
   Set objFSO_TextFile                    = Nothing
End If  

Set objFSO_TextFile                    = objFileSystemObject.OpenTextFile(strLog_Filename, 2) ' 2 = ForWriting
'Set objFSO_TextFile                    = objFileSystemObject.OpenTextFile(strLog_Filename, 8) ' 8 = ForAppending

On Error Resume Next

Const wbemFlagReturnImmediately = &h10
Const wbemFlagForwardOnly = &h20

arrComputers = Array("floyd_adamsxp","ALEX_KHAZAN_XP")
For Each strComputer In arrComputers

objFSO_TextFile.WriteLine ""
objFSO_TextFile.WriteLine "=========================================="
objFSO_TextFile.WriteLine "Computer: " & strComputer
objFSO_TextFile.WriteLine "=========================================="

   Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
   Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_BIOS", "WQL", _
                                          wbemFlagReturnImmediately + wbemFlagForwardOnly)

   For Each objItem In colItems
        objFSO_TextFile.WriteLine "Name: " & objItem.Name
        objFSO_TextFile.WriteLine "Model: " & objItem.Model
   Next
Set colSMBIOS = objWMIService.ExecQuery _
    ("Select * from Win32_SystemEnclosure")
For Each objSMBIOS in colSMBIOS
        objFSO_TextFile.WriteLine "Asset Tag: " & objSMBIOS.SMBIOSAssetTag
Next
Set colBIOS = objWMIService.ExecQuery _
    ("Select * from Win32_BIOS")
For each objBIOS in colBIOS
    objFSO_TextFile.WriteLine "Serial Number: " & objBIOS.SerialNumber
   Next
Next

objFSO_TextFile.Close

Set objFSO_TextFile                    = Nothing
Set objFileSystemObject                    = Nothing

Function WMIDateStringToDate(dtmDate)
WScript.Echo dtm:
     WMIDateStringToDate = CDate(Mid(dtmDate, 5, 2) & "/" & _
     Mid(dtmDate, 7, 2) & "/" & Left(dtmDate, 4) _
     & " " & Mid (dtmDate, 9, 2) & ":" & Mid(dtmDate, 11, 2) & ":" & Mid(dtmDate,13, 2))
End Function

BFN,

fp.
0
 
LVL 35

Expert Comment

by:[ fanpages ]
ID: 16890112
I trust that suggestion met your requirements.

Thanks for closing the question.

BFN,

fp.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

649 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