rgerhards wrote:OK, that clarifies. Maybe a stupid question, but: did you make sure that "c:\test.txt" exists and is accessible? If not, please create such a file with notepad.
Please let us know the outcome.
Rainer
Hi,
Yes, the file is there and never set any permission.
Below is the full code for the script.
Thanks for your patience.
' Sample code for monitoring windows disk space
'
' This script reports the drive usage of all fixed drives on the system
' it is run. The report will be sent via plain text email to a specified
' recipient address (see last line in file).
'
' This sample can be used in a production environment to set up an
' unattended disk utilization report system.
'
' For more information contact Adiscon at
http://www.adiscon.com/
'
' Support for SimpleMail is available at
http://www.simplemail.adiscon.com/
'
' Constants for drive types
Const Unknown = 0
Const Removable = 1
Const Fixed = 2
Const Remote = 3
Const CDROM = 4
Const RAMDisk = 5
' general constants
Const MailServer = "mail.singnet.com.sg" ' Mail Server to use for SimpleMail
Const MailServerPort = "25" ' SMTP Port used at Mail server (25 is default)
' Send a mail message
Sub SendMail(Sender, Recipient, Subject, Message)
set o = WScript.CreateObject("Adiscon.SimpleMail.1")
o.MailServer = MailServer
o.Port = MailServerPort
o.Sender = Sender
o.AttachFile "C:\test.txt", "test.txt"
o.Recipient = Recipient
o.Subject = Subject
o.MessageText = Message
a = o.SendEx
' we do not check the return state here - it wouldn't help if we detect
' an error! This script is intended to run in the background, so there is
' little we can do.
End Sub
' get current computer name (from system environment variables)
Function GetCurrentComputerName
set oWsh = WScript.CreateObject("WScript.Shell")
set oWshSysEnv = oWsh.Environment("PROCESS")
GetCurrentComputerName = oWshSysEnv("COMPUTERNAME")
End Function
'====================================================================================
' Begin main code
'====================================================================================
str = ""
set oFs = WScript.CreateObject("Scripting.FileSystemObject")
set oDrives = oFs.Drives
strComputerName = GetCurrentComputerName ' get name only once for performance reasons
for each oDrive in oDrives
Select case oDrive.DriveType
Case Fixed
str = str & strComputerName & "," & oDrive.DriveLetter & "," & oDrive.TotalSize & "," & oDrive.FreeSpace & vbcrlf
End Select
next
SendMail "sinkingspace@hotmail.com", "sinkingspace@hotmail.com", "Drive Space Report", str