Hi,
I'm having difficulties finding out how to get this script to save my text file into CSV formatted text file. I've tried just changing the *.TXT extension to a *.CSV but it still creates a text file by default. Perhaps there is a special CSV text file command but I'm new to VBScript and I'm trying to modify this script as I'm a Server administrator and I need to be notified when hard drive space starts dipping below 80% of capacity. Any suggestions would be welcomed. Thank you. Frank
Code:
computers = Array( "")
set objFSO = CreateObject("Scripting.FileSystemObject")
if objFSO.FileExists ("c:\Test10.txt") Then
set file_name = objFS
pentextFile("c:\Test10.txt", 2)
Else
set file_name = objFSO.CreateTextFile("c:\Test10.txt")
End If
problem = 0
For Each Computer In computers
On Error Resume Next
Dim cnt
Set objWMIService = GetObject ("winmgmts://" & computer)
if Err <> 0 Then
file_name.WriteLine ( "**" & Err.Number & " " & Err.Description & "**" )
file_name.WriteBlanklines (2)
Err.clear
Else
file_name.WriteLine ("Details For Computer " & Computer)
set colobjdisk = objWMIService.ExecQuery ("Select * FROM Win32_LogicalDisk")
cnt = 0
For Each disk In colobjdisk
file_name.WriteLine ("disk id " & disk.DeviceId & " Type " & disk.DriveType)
Select case disk.DriveType
Case 1
Case 2
Case 3
value = Int(disk.Size/1048576)
threshold = Int(value * .20 )
FreeMegabytes = Int(disk.Freespace/1048576)
If FreeMegabytes < 300 Then
cnt = cnt + 1
problem = problem + 1
file_name.WriteLine ( "Drive " & disk.DeviceId & _
" On Computer " & Computer & " have less then 300 MB")
End If
If FreeMegabytes < threshold Then
cnt = cnt + 1
file_name.WriteLine ( "Drive " & disk.DeviceId & _
" On Computer " & Computer & " is more then 80% Full")
End If
Case 4
Case 5
Case 6
End Select
Next
End If
If cnt = 0 Then
File_name.WriteLine ("The File Systems In this Machine are less Then 80% Full")
End If
file_name.WriteBlankLines (2)
Next
file_name.close
I'm having difficulties finding out how to get this script to save my text file into CSV formatted text file. I've tried just changing the *.TXT extension to a *.CSV but it still creates a text file by default. Perhaps there is a special CSV text file command but I'm new to VBScript and I'm trying to modify this script as I'm a Server administrator and I need to be notified when hard drive space starts dipping below 80% of capacity. Any suggestions would be welcomed. Thank you. Frank
Code:
computers = Array( "")
set objFSO = CreateObject("Scripting.FileSystemObject")
if objFSO.FileExists ("c:\Test10.txt") Then
set file_name = objFS
Else
set file_name = objFSO.CreateTextFile("c:\Test10.txt")
End If
problem = 0
For Each Computer In computers
On Error Resume Next
Dim cnt
Set objWMIService = GetObject ("winmgmts://" & computer)
if Err <> 0 Then
file_name.WriteLine ( "**" & Err.Number & " " & Err.Description & "**" )
file_name.WriteBlanklines (2)
Err.clear
Else
file_name.WriteLine ("Details For Computer " & Computer)
set colobjdisk = objWMIService.ExecQuery ("Select * FROM Win32_LogicalDisk")
cnt = 0
For Each disk In colobjdisk
file_name.WriteLine ("disk id " & disk.DeviceId & " Type " & disk.DriveType)
Select case disk.DriveType
Case 1
Case 2
Case 3
value = Int(disk.Size/1048576)
threshold = Int(value * .20 )
FreeMegabytes = Int(disk.Freespace/1048576)
If FreeMegabytes < 300 Then
cnt = cnt + 1
problem = problem + 1
file_name.WriteLine ( "Drive " & disk.DeviceId & _
" On Computer " & Computer & " have less then 300 MB")
End If
If FreeMegabytes < threshold Then
cnt = cnt + 1
file_name.WriteLine ( "Drive " & disk.DeviceId & _
" On Computer " & Computer & " is more then 80% Full")
End If
Case 4
Case 5
Case 6
End Select
Next
End If
If cnt = 0 Then
File_name.WriteLine ("The File Systems In this Machine are less Then 80% Full")
End If
file_name.WriteBlankLines (2)
Next
file_name.close