Vb Script Not working in NT

October 30, 2009 at 05:03:39
Specs: WINDOWS NT
The script gets the disk space and memory usage data in an xls sheet and place it in the c drive, the second half of the script mails this xls file to the required mail id, this scripts works in windows 2000 and win xp but doesnt work in WINDOWS NT.Can anyone pls help me get this working in WINDOWS NT system..this is very urgent :(

Option Explicit

strLineDate = Date()
strLineTime = Time()


Dim oWsh, oWshSysEnv, objFSO, objWMIService
Dim oDrives, oDrive, objOutFile, colItems, objItem, objEmail
Dim strLineDate, strLineTime, strLineProcessorTime, strLineDriveSpace, strLinePercentCommittedBytesInUse

Set oWsh = WScript.CreateObject("WScript.Shell")
Set oWshSysEnv = oWsh.Environment("PROCESS")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objWMIService = GetObject("winmgmts:\\.\root\CIMV2")

'Gets MEMORY Usage
Set colItems = GetObject("WinMgmts:root/cimv2").ExecQuery("Select * FROM Win32_PerfRawData_PerfOS_Memory ")
For Each objItem In colItems
strLinePercentCommittedBytesInUse = strLinePercentCommittedBytesInUse & " " & objItem.PercentCommittedBytesInUse

strLinePercentCommittedBytesInUse = strLinePercentCommittedBytesInUse / 512 & "MB RAM Used"
Next


'FREE SPACE Report Fetch
Set oDrives = objFSO.Drives
For Each oDrive In oDrives
Select Case oDrive.DriveType
Case 2 'Drives that are fixed
strLineDriveSpace = strLineDriveSpace & " " & oDrive.DriveLetter & "\: " & Round(oDrive.FreeSpace / (1024 * 1024)) & "MB free (" & Round(100 * (oDrive.FreeSpace / oDrive.TotalSize), 2) & " %) "
End Select
Next

'Output to text
Set objOutFile = objFSO.OpenTextFile("C:\APP_MEM_DISK_DATA.csv", 8, True)
objOutFile.WriteLine "Date,Time,Computer Name,Memory Usage (in MB),Drive Free Space"
objOutFile.WriteLine strLineDate & "," & strLineTime & "," & oWshSysEnv("COMPUTERNAME") & "," & strLinePercentCommittedBytesInUse & "," & strLineDriveSpace
objOutFile.Close


Set objEmail = CreateObject("CDO.Message")

objEmail.From = "Valid Mail id is given here"
objEmail.To = "Valid Mail id is given here"
objEmail.Cc = "Valid Mail id is given here"
objEmail.Subject = "Diskspace monitoring Report"
objEmail.Textbody = "The disk space and memory details are attached - Pls refer to APP_MEM_DISK_DATA.csv ."
objEmail.AddAttachment "C:\APP_MEM_DISK_DATA.csv"

objEmail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objEmail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "mail server name is given here which is valid"
objEmail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objEmail.Configuration.Fields.Update

objEmail.Send
WScript.Quit


See More: Vb Script Not working in NT

Report •


#1
October 30, 2009 at 05:47:11
"It doesn't work" is just about as vague as you can get, especially since we don't even know:
- The version of the VBScript engine
- The version of the WScript engine

xls file
It's a cvs file.

Win32_PerfRawData_PerfOS_Memory
Was not added until WinXP. (Actually, it's hard to find any WMI class available before Win2000).

CDO.Message
Was not added until Win2000.

I couldn't find any relevent, OS-bundled method to gather this information on WinNT, but I didn't look too hard.


Report •
Related Solutions


Ask Question