Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Log to text ( last question i swear)

Status
Not open for further replies.

tltechie

Technical User
Apr 25, 2011
17
US
This is how i am echoing the info im requesting but id love for it to go to a text file or some sort of log so it is neater



For Each objSWbemObject in colSWbemObjectSet
wscript.echo "Hard Drive Space",VbCrLf,_
"Megabytes of Free Disk Space on c:\ ", Int(FreeMegaBytes), VbCrLf, _
"Megabytes of Free Disk Space on D:\ " & Int(FreeMegaBytes1),VBCrLF,VBCrLF,"Page File Settings", vbcrlf, "Total Virtual Memory : " & FormatNumber(objSWbemObject.TotalVirtualMemory / CONVERSION_FACTOR, NoDecimals) _
& " (MB)" & vbCrlf & _
"Available Virtual Memory : " & FormatNumber(objSWbemObject.AvailableVirtualMemory / CONVERSION_FACTOR, NoDecimals) _
& " (MB)" & vbCrlf & _
"Total Physical Memory : " & FormatNumber(objSWbemObject.TotalPhysicalMemory / CONVERSION_FACTOR, NoDecimals) _
& " (MB)" & vbCrlf & _
"Total Page File Space : " & FormatNumber(objSWbemObject.TotalPageFileSpace / CONVERSION_FACTOR, NoDecimals) _
& " (MB)" & vbcrlf & vbcrlf & "PRINTERS CURRENTLY MAPPED: " & VbCrLf & VbCrLf & UCASE(StrPrintStatus) & "NETWORK DRIVES CURRENTLY MAPPED: " & VbCrLf & VbCrLf & UCASE(StrDrivePath)
 
Have a look at FileSystemObject

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
everything im finding is doing the code line by line. I know its all wrong but i guess im not understanding.




Dim objFileSystem, objOutputFile
Dim strOutputFile

' generate a filename base on the script name
strOutputFile = "c:\output.txt"

Set objFileSystem = CreateObject("Scripting.fileSystemObject")
Set objOutputFile = objFileSystem.CreateTextFile(strOutputFile, TRUE)

objOutputFile.WriteLine("Hello world (" & Now & ")echo "Hard Drive Space",VbCrLf,_
"Megabytes of Free Disk Space on c:\ ", Int(FreeMegaBytes), VbCrLf, _
"Megabytes of Free Disk Space on D:\ " & Int(FreeMegaBytes1),VBCrLF,VBCrLF,"Page File Settings", vbcrlf, "Total Virtual Memory : " & FormatNumber(objSWbemObject.TotalVirtualMemory / CONVERSION_FACTOR, NoDecimals) _
& " (MB)" & vbCrlf & _
"Available Virtual Memory : " & FormatNumber(objSWbemObject.AvailableVirtualMemory / CONVERSION_FACTOR, NoDecimals) _
& " (MB)" & vbCrlf & _
"Total Physical Memory : " & FormatNumber(objSWbemObject.TotalPhysicalMemory / CONVERSION_FACTOR, NoDecimals) _
& " (MB)" & vbCrlf & _
"Total Page File Space : " & FormatNumber(objSWbemObject.TotalPageFileSpace / CONVERSION_FACTOR, NoDecimals) _
& " (MB)" & vbcrlf & vbcrlf & "PRINTERS CURRENTLY MAPPED: " & VbCrLf & VbCrLf & UCASE(StrPrintStatus) & "NETWORK DRIVES CURRENTLY MAPPED: " & VbCrLf & VbCrLf & UCASE(StrDrivePath")
objOutputFile.Close

Set objFileSystem = Nothing

WScript.Quit(0)
 
objOutputFile.WriteLine "Hard Drive Space" & VbCrLf & _
"Megabytes of Free Disk Space on c:\ " & Int(FreeMegaBytes) & VbCrLf & _
"Megabytes of Free Disk Space on D:\ " & Int(FreeMegaBytes1) & VBCrLF & VBCrLF & "Page File Settings" & vbcrlf & "Total Virtual Memory : " & FormatNumber(objSWbemObject.TotalVirtualMemory / CONVERSION_FACTOR, NoDecimals) _
& " (MB)" & vbCrlf & _
"Available Virtual Memory : " & FormatNumber(objSWbemObject.AvailableVirtualMemory / CONVERSION_FACTOR, NoDecimals) _
& " (MB)" & vbCrlf & _
"Total Physical Memory : " & FormatNumber(objSWbemObject.TotalPhysicalMemory / CONVERSION_FACTOR, NoDecimals) _
& " (MB)" & vbCrlf & _
"Total Page File Space : " & FormatNumber(objSWbemObject.TotalPageFileSpace / CONVERSION_FACTOR, NoDecimals) _
& " (MB)" & vbcrlf & vbcrlf & "PRINTERS CURRENTLY MAPPED: " & VbCrLf & VbCrLf & UCASE(StrPrintStatus) & "NETWORK DRIVES CURRENTLY MAPPED: " & VbCrLf & VbCrLf & UCASE(StrDrivePath")


Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Also, for a log file, instead of using "CreateTextFile", I would use OpenTextFile, with the Append flag set:
Code:
ForAppending = 8
Set objOutputFile = objFileSystem.OpenTextFile(strOutputFile, ForAppending, True)
 
i get unterminated string constent when i use this.
 
Replace this:
& UCASE(StrDrivePath")
with this:
& UCASE(StrDrivePath)

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
SERIOUSLY! I cant believe i missed that. Also you guys are awesome! My script is "flawless". THANK YOU SO MUCH
 
I used the word "flawless" to describe a script of mine to my colleague. It produced an error while demostrating. I will never live that down.

-Geates

"I hope I can feel and see the change - stop the bleed inside a feel again. Cut the chain of lies you've been feeding my veins; I've got nothing to say to you!"
-Infected Mushroom
 
to Geates

" It produced an error while demostrating."

when that happens, I call it a feature

Justin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top