Computing.Net > Forums > Windows NT > Vb Script Not working in NT

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Vb Script Not working in NT

Reply to Message Icon

Name: karpasad
Date: October 30, 2009 at 05:03:39 Pacific
OS: WINDOWS NT
Subcategory: General
Tags: windows NT, Vb Script, objFSO
Comment:

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



Sponsored Link
Ads by Google

Response Number 1
Name: Razor2.3
Date: October 30, 2009 at 05:47:11 Pacific
Reply:

"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.


0
Reply to Message Icon

Related Posts

See More





Use following form to reply to current message:

Login or Register to Reply
LoginRegister


Sponsored links

Ads by Google


Results for: Vb Script Not working in NT

mouse is not working in nt www.computing.net/answers/windows-nt/mouse-is-not-working-in-nt/19143.html

KEYBOARD DOES NOT WORK IN NT www.computing.net/answers/windows-nt/keyboard-does-not-work-in-nt/11465.html

MODEM DOES NOT WORK IN NT 4.0 SERV. www.computing.net/answers/windows-nt/modem-does-not-work-in-nt-40-serv/2788.html